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

Solved onPrepareDeath(cid, killer); onDeath(cid, corpse, ...) Difference?

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
34
Location
Germany
If found this two functions in creaturescripts. What is the difference between those two? I mean, how are they activated?
 
Last edited:
in short:
onPrepareDeath happens before the player dies
onDeath happens after the player dies

they both activate when a player dies if you have the event registered, one before death, meaning that if you for example add HP in the onPrepareDeath, you save them from actually dying, while the onDeath is really after the player has died and produced a corpse
 
It seems to me that onPrepareDeath is turned on before death and onDeath after death, although I could be wrong.

@up grrr
 
onPrepareDeath
-is a function that does things before the player dies. For example if player is level 50 the items will be not dropped. Here it will stop streak, teleport and remove the creature that killed the player.

LUA:
function onPrepareDeath(cid, deathList)
        if (getCreatureStorage(cid, config.storages.timeLeft) > 0) then
                doTeleportThing(cid, config.position.finish)
                stopEvent(killStreakTimer)
                doSetStorage(config.storages.active, -1)
                doRemoveCreature(getStorage(config.storages.monster1))
                doRemoveCreature(getStorage(config.storages.monster2)) 
                return doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        end
        return true
end

onDeath
- is a function that does things after player's death. Get creatures name, death streak and add a magic effect.

LUA:
function onKill(cid, target, flags)
    if getCreatureName(target):lower() == t.monsterName:lower() then
        doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
        doTeleportThing(cid, t.teleportTo)
        doSendMagicEffect(t.teleportTo, CONST_ME_TELEPORT)
    end
end
 
Last edited by a moderator:
Back
Top