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

Lua Problem Adding creaturescript to server

Obsdark

Member
Joined
Sep 25, 2011
Messages
213
Reaction score
9
¡¡¡Hey oh!!!

i have a doubt about how to add creaturescripts on my server, i must confess than i'll try to learn about it reading the "creaturescript.XML" (like any other human being, i think) but its useless because it doesn't apparead a case for onDeath script

so, that brings us to my question:

How i add one "OnDeath" script to the server?
is, in fact a CreatureScript right?

i really be thanks by any answer, and i'll give rep to the most necesary ones. ;)

¡¡Bless you, Cheers up!!
(Y)(Y)

-Obsdark-
 
(In creaturescripts.xml)
For TFS v0.2, then:
Code:
	<event type="death" name="PlayerDeath" script="playerdeath.lua"/>

For TFS v0.4, then:
Code:
	<event type="death" name="OnDeath" event="script" value="ondeath.lua"/>

And for the script, you'll have to do it yourself, I know very little of ondeath.

Dunno about 0.3 since I don't have that server :P
If it doesn't work, then post your server version.
 
XML:
<event type="death" name="EVENT_NAME" event="script" value="SCRIPT_NAME.lua"/>
You change EVENT_NAME to whatever you want to call in but you have to use this name to register the event before it starts to work, depending on how you want the event to work. For example you may want to make it when a player uses a certain item then they die something else happens you would do this to start with:

Player uses item that runs this script:
LUA:
function onUse(cid, item.....)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT , "onDeath event is now registered.")
registerCreatureEvent(cid, EVENT_NAME)

and obviously you would change SCRIPT_NAME.lua to whatever your onDeath script is called.

the onDeath .lua file needs to start like this:
LUA:
function onDeath(cid, corpse, deathList)

---insert your code here

   return true
end

I hope that all made sense :rolleyes:
 
As Far Carder said you have to "assign" such a creatureevent to a creature.
Usually you have 'creaturescripts/scripts/login.lua' or so, where player events gets registered.
Just add registerCreatureEvent(cid, "eventname") there.
 
Back
Top