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
local config = {
playerCheck = "yes",
summonCheck = "yes"
}
config.playerCheck = getBooleanFromString(config.playerCheck)
config.summonCheck = getBooleanFromString(config.summonCheck)
function onThink(interval, lastExecution, thinkInterval)
if(config.playerCheck) then
for _, pid in ipairs(getPlayersOnline()) do
if(getCreatureHealth(pid) <= 30) then
doSendMagicEffect(getThingPosition(pid), CONST_ME_SLEEP)
end
end
end
if(config.summonCheck) then
for _, pid in ipairs(getPlayersOnline()) do
for _, sid in ipairs(getCreatureSummons(pid)) do
if(getCreatureHealth(sid) <= 30) then
doSendMagicEffect(getThingPosition(sid), CONST_ME_STUN)
end
end
end
end
return true
end
<globalevent name="lowhealth" interval="1" script="lowhealth.lua"/>
function onThink(cid, interval)
if isPlayer(cid) and getCreatureHealth(cid) <= 30 then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_SLEEP)
end
return true
end
<event type="think" name="LowHealth" event="script" value="lowhealth.lua"/>
registerCreatureEvent(cid, "LowHealth")
In the end, it's about the same. The only difference is that you can specify a custom interval when using globalevents.which is kinda idiotic in my eyes