• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Death effect requested

Zatacka

Mapper, Basic Scripter
Joined
May 12, 2009
Messages
222
Reaction score
15
Location
Sweden
I want to have an effect on death, anyone who knows how?
SOLVED
 
Last edited:
You could use the function onPrepareDeath (cid, lastHitKiller, mostDamageKiller)
or even
LUA:
function onStatsChange(cid, attacker, type, combat, value)
    if (type == STATSCHANGE_HEALTHLOSS) then
 
nice, but where do i put it and what do i write in .xml file, please a tut maybe

Alright a tutorial.. here you go

There are two creature scripts that have to do with players dying, you have function "function onDeath(cid, corpse, deathList)" & "function onPrepareDeath(cid, deathList)", if you use onDeath cid won't exist anymore since he is dead, and if you use onPrepareDeath cid will exist because its preparing for death.

Next, you want to send an effect for when you die, so you need to use the function doSendMagicEffect(pos, effect), so you'll need to know the position of the player, you'll use getCreaturePosition(cid) to get his location, and then you can use an effect aswell such as CONST_ME_DEATHAREA, CONST_ME_MAGIC_RED, etc..

Next if you want you can add animated text to say 'Owned!' above the head, so you'll need to use doSendAnimatedText(pos, text, color), once again you'll get the creatures position with getCreaturePosition, pick a text and put it inside a quotation mark, like this " ", and lastly you pick a color, something like COLOR_GREEN, COLOR_PINK, COLOR_TEAL.. etc

Now you can pick to return true or false, true = player dies, and false = player never dies, so its pretty obvious here what you need

and then you end the script.. it's simple
 
Use This One.
XML:
<event type="preparedeath" name="onPrepareDeath" event="script" value="preparedeath.lua"/>



LUA:
local function sendLetter(p)
local pos = p.pos
local letter = p.letter
doSendAnimatedText(pos, letter, TEXTCOLOR_WHITE)
end

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
doSendMagicEffect(getPlayerPosition(cid), 49)
local letters = {"Owned!"}
for i = 1, #letters do
addEvent(sendLetter, i * 150, {pos = getCreaturePosition(cid), letter = letters[i]})
end
return true
end

register it on login.lua (NO FORGET THAT)
 
Back
Top