• 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!

im trying to get this action script to take mana on use.

Werewolf

Forbidden Ascension
Joined
Jul 15, 2012
Messages
886
Reaction score
123
Code:
local config = {
	requiredMana = 100,
}

if(getCreatureMana(cid) < config.requiredMana) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
		doSendMagicEffect(pos, CONST_ME_POFF)
		return false
	end
	
function target (stuff) 
local cid = stuff.cid     
local thing = getThingfromPos(stuff.toPosition) 
     

    if (stuff.counter == 2) then 
           if isCreature(thing.uid) then 
                doTeleportThing(thing.uid, getCreaturePosition(stuff.cid)) 
        end 
        return TRUE 
    end     
	    doTeleportThing(thing.uid, getCreaturePosition(stuff.cid)) 
        doSendDistanceShoot(stuff.toPosition, getCreaturePosition(stuff.cid), CONST_ANI_WHIRLWINDAXE) 
        doAreaCombatHealth(0, COMBAT_HOLYDAMAGE, stuff.toPosition, 0, -50, -100, CONST_ME_HOLYDAMAGE) 
        stuff.counter = stuff.counter + 1 
        addEvent(target, 200, stuff) 
end 


function onUse(cid, item, fromPosition, itemEx, toPosition) 
    if getTilePzInfo(getCreaturePosition(cid)) == TRUE or getTilePzInfo(toPosition) == TRUE then 
        warnPlayer(cid, "You cannot use this weapon in a protection zone.") 
    else 
        doSendDistanceShoot(getCreaturePosition(cid), toPosition, CONST_ANI_WHIRLWINDAXE) 
		doCreatureAddMana(cid, - config.requiredMana, false)
        local stuff = {cid = cid, toPosition = toPosition, counter = 1}         
        addEvent(target, 300, stuff) 
    end 
    return TRUE 
end

For some reason it does not work, but if i get rid of the
Code:
 if(getCreatureMana(cid) < config.requiredMana) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
		doSendMagicEffect(pos, CONST_ME_POFF)
		return false
	end

Part it works fine, but i want it to consume mana, but its not working when i try to add it, what did i do wrong?
 
D: did not work, when i Put in if(getCreatureMana(cid) < config.requiredMana) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA)
doSendMagicEffect(pos, CONST_ME_POFF)
return false
end

In the script itself, it just stops working all together....
 
Add it under function onUse, also use return true instead of return false, return false gives a "You cannot use this object" message with an action script.
 
Back
Top