devianceone
Lua Scripter
- Joined
- Jan 24, 2009
- Messages
- 756
- Reaction score
- 29
Im trying to prevent a players death by teleporting them and giving them full health, but it doesn't seem to work. The player never gets healed and either dies after teleporting (returning true) or they go into a infinity loop staying alive with 0 hp and being teleported to the same spot over and over (returning false).
im using 0.3.6pl1, running this as a creature event.
No errors, but here is my console output from the print function.
edit: thanks to Nahruto for a fix, but does anybody know how to make it work with onPrepareDeath still?
im using 0.3.6pl1, running this as a creature event.
PHP:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
print("OnPrepareDeath Start")
if isPlayer(cid) == TRUE then
print("OnPrepareDeath Teleport = " .. cid)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
return false
end
print("OnPrepareDeath End")
return true
end
No errors, but here is my console output from the print function.
[22/02/2010 21:56:48] OnPrepareDeath Teleport = 268436749
[22/02/2010 21:56:48] OnPrepareDeath Start
[22/02/2010 21:56:48] OnPrepareDeath Teleport = 268436749
[22/02/2010 21:56:49] OnPrepareDeath Start
... forever
edit: thanks to Nahruto for a fix, but does anybody know how to make it work with onPrepareDeath still?
Last edited: