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

stopEvent

Xagul

deathzot.net
Joined
Jun 30, 2008
Messages
1,295
Solutions
3
Reaction score
1,043
I am having a small problem, I have a spell that makes you unable to move and when the spell buff is gone it allows you to move again. The problem is when a player dies before it sets their noMove to false it sends an error to the console because it cannot find the creature. I am using this script right now:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 5000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	if getCreatureNoMove(cid) == TRUE then
		doPlayerSendCancel(cid, "Spell is already active.")
		return FALSE
	else
		doCreatureSetNoMove(cid, TRUE)
		addEvent(doCreatureSetNoMove, 5000, cid, FALSE)
		doCombat(cid, combat, var)
	end
	return TRUE
end

I thought maybe I could check to see if the player was found and if not then it would use stopEvent however I cant figure out how stopEvent works xD
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 5000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local function x(cid)
	return isPlayer(cid) and doCreatureSetNoMove(cid, false)
end

function onCastSpell(cid, var)
	if getCreatureNoMove(cid) then
		doPlayerSendCancel(cid, "Spell is already active.")
		return false
	else
		doCreatureSetNoMove(cid, true)
		addEvent(x, 5000, cid)
		doCombat(cid, combat, var)
	end
	return true
end
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 5000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 10)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local function x(cid)
	return isPlayer(cid) and doCreatureSetNoMove(cid, false)
end

function onCastSpell(cid, var)
	if getCreatureNoMove(cid) then
		doPlayerSendCancel(cid, "Spell is already active.")
		return false
	else
		doCreatureSetNoMove(cid, true)
		addEvent(x, 5000, cid)
		doCombat(cid, combat, var)
	end
	return true
end
addEvent(doCreatureSetNoMove, 5000, cid, false) xdxd
 
Back
Top