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

Lua onPrepareDeath not triggering.

kird

New Member
Joined
Jul 3, 2010
Messages
78
Reaction score
1
Hello there and thanks in advance,

I've been updating a server i started long time ago and i've encounterd a problem i can't seem to find the solution to.

I've created an 'onPrepareDeath' creature event but it doesnt seem to trigger.
I'm using Mystic spirit v0.2 which already made me change my script since it doesnt support 'onStatsChange' events, and now it won't trigger the onPrepareDeath events.

Is there any problem with the mystic Spirit server, i'm missing?

This is the code i have in case you need to look at it, but im fairly certain that it is correct and i'm not getting any error in my console either.

creaturescripts/scripts/palma_OB.lua
Lua:
local temple_pos ={x = 1136, y = 1203, z = 7}
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
	if getCreatureHealth(cid) <= 0 and isPlayer(cid) then
        doTeleportThing(cid, temple_pos, true)
              doRemoveCondition(cid, CONDITION_INFIGHT)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
		doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
        return false
    end
	return true
end

creaturescripts.xml
Lua:
<event type="preparedeath" name="palmaOB" event="script" value="palma_OB.lua"/>

login.lua
Lua:
registerCreatureEvent(cid, "palmaOB")

thanks,
Kird~
 
if you add: print("Executed") after function onPrepareDeath(....) does it print that in console?

Try removing this condition maybe: getCreatureHealth(cid) <= 0
 
Thanks for the reply, but unfortunetly it doesnt print anything in my console with print("Executed").

Is it maybe because v0.2 doesnt support onPrepareDeath?
 
i'm glad to hear that.

But now can you guys help me to figure out whats going on in my server?
When a player kills another it just leave a corpse as normal and no event is triggered. What am i doing wrng?

thanks
Kird~
 
Try this:

Lua:
local cyko_tp_pos ={x = 1136, y = 1203, z = 7}
function onPrepareDeath(cid, deathList)
	if isPlayer(cid) then
		if getCreatureHealth(cid) <= 0 then
			doTeleportThing(cid, cyko_tp_pos)
			doRemoveCondition(cid, CONDITION_INFIGHT)
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
			doCreatureAddMana(cid, getCreatureMaxMana(cid), true)
			return false
		end
		return true
	end
end
 
nope, nothing :/

this is actually driving me crazy....what am i doing wrong :/?

this are the whole login.lua and creaturescripts.xml files:

Lua:
function onLogin(cid)
	registerCreatureEvent(cid, "PlayerDeath")
	registerCreatureEvent(cid, "KillSystem")
	registerCreatureEvent(cid, "palmaOB")
	return true
end
XML:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
	<event type="login" name="PlayerLogin" script="login.lua"/>
	<event type="login" name="FirstItems" script="firstitems.lua"/>
	<event type="kill" name="KillSystem" script="killing.lua"/>
	<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
	<!--<event type="preparedeath" name="palmaOB" script="palma_OB.lua"/>-->
	<event type="preparedeath" name="palmaOB" event="script" value="palma_OB.lua"/>
</creaturescripts>
 
Back
Top