• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent OnDeath [Release]

dave182

New Member
Joined
Jan 23, 2009
Messages
80
Reaction score
3
Hi, this is an usefull script. It works like this: you kill a monster (whatever you want, just change it on the script) and after that, it opens any object (you can change on the script) for XX minutes. After XX minutes, the object will put to its originally position.

First, you have to go to your data/creaturescripts/creaturescripts.xml folder, you open it and you paste this:

Code:
<event type="death" name="monster" event="script" value="monster.lua"/>

name=monster, you have to change it to the name of the monster you want, if you kill it it opens the object to pass.

Now, you will have to create the script, so go to your data/creaturescripts/scripts folder, copy any creaturescript around there, the name of the script will be the name of the monster you put before, erase anything inside of the script and copy this:

Code:
local function moveStone(p)
if isPlayer(getThingfromPos(p.stonePosition).uid) == TRUE then
doMoveCreature(cid, 2)
end
doSendMagicEffect(p.stonePosition, 13)
doCreateItem(p.stoneid, 1, p.stonePosition)
end

function onDeath(cid, corpse, killer)
local timeLimit = 1000 * 60 * 1
local stonePosition = {x=xxx, y=xxx, z=xx, stackpos=1}
local stoneid = 7825
local stone = getThingfromPos(x=580, y=1612, z=10, stackpos=1)

if stone.itemid == stoneid then
doRemoveItem(stone.uid, 1)
doSendMagicEffect(stonePosition, 13)
addEvent(moveStone, timeLimit, {stonePosition = stonePosition, stoneid = stoneid})
end

return TRUE
end

Explanation:

Code:
local timeLimit = 1000 * 60 * 1
There you will put the time to put the stone again, so 1000 means 1 minute, so after you kill the monster you have 1 minute to pass the thing that you removed. You can change the time, for example, if you put 2000, it means 2 minutes.

Code:
local stonePosition = {x=xxx, y=xxx, z=xx, stackpos=1}
This means the position of the object that you want to remove.

Code:
local stoneid = 7825
7825 means the ID of the object you want to remove, in this case, a monk statue. You can search for any ID and put it there.

Code:
local stone = getThingfromPos(x=xxx, y=xxx, z=xx, stackpos=1)
There you have to put the same coordinates that you put on local stonePosition, because with this the object will appear again.

THIS SCRIPT IS USEFULL FOR QUESTS, YOU CAN ALSO PUT ON YOUR INQUISITION QUEST, IS ANOTHER WAY :) HOPE YOU LIKE IT, PLEASE COMMENTE AND REP++ ME IF IT WORKED :)
 
So if i want it to open a gate for 5 minutes..
and close it when the monster spawn again??? how can i do that

because i changed the spawn rate of the boss.. and it didn't worked..
the gate never opened or closed.
 
Using TFS 0.3.4PL2, got this error:
[Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/d
emon.lua)
data/creaturescripts/scripts/demon.lua:13: ')' expected near '='
Line 13:
local stone = getThingfromPos(x=902, y=978, z=8, stackpos=1)
 
Using TFS 0.3.4PL2, got this error:

Line 13:

Change it to
Code:
local stone = getThingfromPos(stonePosition)
or
Code:
local stone = getThingfromPos({ x = xxx, y = yyy, z = z, stackpos = 1 })
 
So if i want it to open a gate for 5 minutes..
and close it when the monster spawn again??? how can i do that

because i changed the spawn rate of the boss.. and it didn't worked..
the gate never opened or closed.
I think you have to add this line to login.lua, not sure

Code:
registerCreatureEvent(cid, "Monster")
 
Back
Top