• 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 Script] Help with func onDeath (solved)

StormRusher

New Member
Joined
Dec 23, 2009
Messages
138
Reaction score
0
Well i am having problems with onDeath function, i dont wanna use the onKill because it execute the script each time a player kill someone, then if 2 players kill one player, the script will be executed twice...

USING TFS 0.3.5

i wanna do that:
when a player dies send a animatedtext ("DEAD") to his position.

i dont know if this function still working on 0.3.5, if not, someone please tell me an equivalent

thanks (hope you understand me) :)
 
Last edited:
Credit to Sync and Cykotitan. Minor edit by me.

Not tested

Code:
local t = {
	{"Smashed!", 189},
	{"Dead!", 190},
	{"Owned!", 18},
	{"Pwnt!", 215}
}
function onDeath(cid, corpse, killer)
	if(isPlayer(killer) == TRUE) then
		local rand = math.random(#t)
		doSendAnimatedText(getThingPos(cid), t[rand][1], t[rand][2])
		doSendMagicEffect(getThingPos(target), math.random(32))
	end 
	return TRUE    
end
 
Hmm didnt work,

in creaturescripts.xml:
PHP:
<event type="death" name="killeffect" event="script"
value="killeffect.lua"/>

in login.lua:
PHP:
registerCreatureEvent(cid, "killeffect")

does it right?
 
Last edited:
Yes that's how you would register the event.

Small Change. Think it should work. If not my best guess would be just edit the advanced player death broadcast with reward script and take out the stuff you don't want it to do.

Code:
local t = {
	{"Smashed!", 189},
	{"Dead!", 190},
	{"Owned!", 18},
	{"Pwnt!", 215}
}
function onDeath(cid, corpse, killer)
	if(isPlayer(cid) == TRUE) then
		local rand = math.random(#t)
		doSendAnimatedText(getThingPos(cid), t[rand][1], t[rand][2])
		doSendMagicEffect(getThingPos(cid), math.random(32))
	end 
	return TRUE
 
Back
Top