• 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 problem...help please

kird

New Member
Joined
Jul 3, 2010
Messages
78
Reaction score
1
Well i took this script from mock's post and modified it a bit. It's a script so the players gets teleported to the temple if its health goes to 0. (yes, like in pvp arena script)
Everything goes fine but i just cant modify the players health after it "dies".

It stands on the temple with 0 health and nither the spells or the functions (doAddCreatureHealth) works.

Seems like you cant modify the health variable anymore once your health goes under 0.
what's wrong?

Code:
local templePos = {x = 1011, y = 1008, z = 6}

function onPrepareDeath(cid,aa) -- Script by mock the bear

	doPlayerAddHealth(cid,getCreatureMaxHealth(cid))
	doCreatureAddMana(cid,getCreatureMaxMana(cid))
	doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
        return false
end
It's 0.3.6pl1

Thanx in advance
Kird~
 
Last edited:
what about if the cid is a monster? you want it to teleport to temple oO
LUA:
function onPrepareDeath(cid, deathlist)
    if isPlayer(cid) then
        doCreatureAddHealth(cid,getCreatureMaxHealth(cid)-getCreatureHealth(cid)) 
        doCreatureAddMana(cid, getCreatureMaxMana(cid)-getCreatureMana(cid))
        doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
        return false    
    end
return true
end




 
@up: what for?
EDIT:

LUA:
function onPrepareDeath(cid, deathlist)
    if isPlayer(cid) then
        doRemoveConditions(cid)
        doCreatureAddHealth(cid,getCreatureMaxHealth(cid)-getCreatureHealth(cid)) 
        doCreatureAddMana(cid, getCreatureMaxMana(cid)-getCreatureMana(cid))
        doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
        return false    
    end
return true
end

 
Last edited:
Its for a OB System, there will be no mosnters, anyway i'll use ur advice

@unKnown666--I tried this function,and worked 2 days ago, but i was afraid of the server lagging because of an event checking on statschange on every player in the server.
is that possble or I am wrong with that?

Thnx for the replis btw
 
Its for a OB System, there will be no mosnters, anyway i'll use ur advice

@unKnown666--I tried this function,and worked 2 days ago, but i was afraid of the server lagging because of an event checking on statschange on every player in the server.
is that possble or I am wrong with that?

Thnx for the replis btw
what about mine? it worked?
 
My script is working already, its just that the function doPLayerAddHealth doesnt work on this script. Didn't test yours, bt i guess if you only added the isPlayer line it'll work

btw, im gonna use the statsChange function, lets see how it beheaves
Thnx both of you for ur help
 
return true must always be before the end of all creature scripts
ahm use mine, it's the one you're looking for
 
Im sry but you are wrong this time.
When you use the onPrepareDeat function if it returns true the char will die, in the other hand if it return false the char won't die its when u can use all those teleport and addhealth functions etc..
 
lol you don't get it, anyways return true must always be there, when we want to make the creature not to die we use return false, but return true has to be down there
 
mhmm
U think it might be the problem for the addCreatureHealth not working?
appart from that the whole script is working
 
No
I mean, it works fine except for the addPlayerHealth
it gets tpped but stands on the tmple with 0 health, and the console is looping over this script as the char has 0 health all the time.
Neither addPlayerHealth or healing spells in-game seems to be changeing the health variable.

But its not your script, all i used ended up the same way
 
well, lets see then

local templePos = {x = 1011, y = 1008, z = 6} --USELESS

function onPrepareDeath(cid,aa) -- Script by mock the bear --aa should be deathlist, but it doesn't matter, it isn't being used

doPlayerAddHealth(cid,getCreatureMaxHealth(cid)) --maybe won't work, doPlayerAddHealth doesn't exist!
doCreatureAddMana(cid,getCreatureMaxMana(cid)) --maybe it will work
doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
return false --WRONG, MONSTERS, PLAYERS, EVERYONE WONT DIE AND MONSTERS WILL DEBUG, THEY DONT HAVE TEMPLE!
end --MISSING RETURN TRUE
return false is badly placed

compare:

LUA:
  function  onPrepareDeath(cid, deathlist)
    if isPlayer(cid) then
        doRemoveConditions(cid)
        doCreatureAddHealth(cid,getCreatureMaxHealth(cid)-getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid)-getCreatureMana(cid))
        doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
        return false    
    end
return true
end
 
doPlayerAddhealth does exist, else it would debug
anyway, i tries doPlayerAddHealth as doCreatureAddHealth wasnt working either.

And its not this script, i tried a whole bunch of pvp-arena scripts and everytime is the same.
It seems like doCreatureAddHealth isn't compatible with onPrepareDeath
 
Back
Top