• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Action Spell !

Joined
May 23, 2010
Messages
185
Reaction score
23
Hi guys, how are you?

I having problems with a script:

Code:
function onUse(cid, item, frompos, item2, topos)

if getPlayerMana(cid) >= 30 then
doPlayerAddMana(cid, -30)
doPlayerCastSpell(cid, "ef1")
end
end

The problem is, my magic has a exausted of 4 seconds but everytime thet a click on the action i lost mana, i want do lost mana every 4 seconds not everytime that i click.

Someone?
 
LUA:
function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 5555) > os.time() then
return doPlayerSendCancel(cid, "You are exhaused")
end
if getPlayerMana(cid) >= 30 then
doPlayerAddMana(cid, -30)
doPlayerCastSpell(cid, "ef1")
setPlayerStorageValue(cid, 5555, os.time()+4)
end
end
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if not hasCondition(cid, CONDITION_EXHAUST, EXHAUST_COMBAT) then
		if getPlayerMana(cid) >= 30 then
			doPlayerAddMana(cid, -30, false)
			doPlayerCastSpell(cid, 'ef1')
		else
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
		end
	else
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	end
	return true
end
 
Okay, doPlayerCastSpell doesn't create exhaust then.

LUA:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 4000)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, EXHAUST_COMBAT)

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if not hasCondition(cid, CONDITION_EXHAUST, EXHAUST_COMBAT) then
		if getPlayerMana(cid) >= 30 then
			doPlayerAddMana(cid, -30, false)
			doPlayerCastSpell(cid, 'ef1')
			doAddCondition(cid, exhaust)
		else
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
		end
	else
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
	end
	return true
end
 
Back
Top