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

0.3.6pl1 onPrepareDeath infinity loop when preventing death

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.
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:
yeeeeeeees, i got the same problem, then i posted it in bug section and got...

66310264444198934337.jpg


elf said:
PrepareDeath prevents from death, Death prevents from corpse dropping.
You need to return false in Prepare~. Anyway, cannot reproduce- was testing it few days ago.

so... i found a alternative way for prevent player from die, if you need it pm me
 
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if (type == STATSCHANGE_HEALTHLOSS) then
        if getCreatureHealth(cid) <= value then
            --if (isPlayer(attacker) == true) then
                --Your script here.
                return false
            --end
        end
    end
    return true
end

use the brain for the rest 8D
 
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if (type == STATSCHANGE_HEALTHLOSS) then
        if getCreatureHealth(cid) <= value then
            --if (isPlayer(attacker) == true) then
                --Your script here.
                return false
            --end
        end
    end
    return true
end

use the brain for the rest 8D



Use the brain for the rest
 
Back
Top