function onThink(interval, lastExecution)
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureHealth(pid) < 30 then
doSendMagicEffect(getThingPos(pid), 32)
end
end
return true
end
function onThink(interval, lastExecution)
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureHealth(pid) < 30 then
doSendMagicEffect(getThingPos(pid), 32)
end
end
return true
end
Why would you define it as a global var?
LUA:function onThink(interval, lastExecution) for _, pid in ipairs(getPlayersOnline()) do if getCreatureHealth(pid) < 30 then doSendMagicEffect(getThingPos(pid), 32) end end return true end
function onStatsChange(cid, attacker, type, combat, value)
if(isPlayer(cid) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS) then
value = 30
if(value >= getCreatureHealth(cid)) then
doSendMagicEffect(getThingPosition(cid), CONST_ME_SLEEP)
return false
end
end
return true
end
<event type="statschange" name="LowHealth" event="script" value="lowhealth.lua"/>
registerCreatureEvent(cid, "LowHealth")
[18/12/2010 17:51:34] [Error - CreatureScript Interface]
[18/12/2010 17:51:35] data/creaturescripts/scripts/lowhealth.luanStatsChange
[18/12/2010 17:51:35] Description:
[18/12/2010 17:51:35] attempt to index a number value
[18/12/2010 17:51:35] stack traceback:
[18/12/2010 17:51:35] [C]: in function 'doSendMagicEffect'
[18/12/2010 17:51:35] data/creaturescripts/scripts/lowhealth.lua:4: in function <data/creaturescripts/scripts/lowhealth.lua:1>
function onStatsChange(cid, attacker, type, combat, value)
for _, pid in ipairs(getCreatureSummons(cid)) do
if(pid and isPlayer(cid) and combat ~= COMBAT_HEALING or type == STATSCHANGE_HEALTHLOSS) then
value = 30
if(value >= getCreatureHealth(pid)) then
doSendMagicEffect(getThingPosition(pid), CONST_ME_STUN)
return false
end
end
end
return true
end
<event type="statschange" name="LowHealthSummon" event="script" value="lowhealthsummon.lua"/>
registerCreatureEvent(cid, "LowHealthSummon")