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

onKill

Swiff

Member
Joined
Apr 6, 2009
Messages
366
Reaction score
12
Location
Sweden
It's more of a question than a request.

I see many scripts using the onKill or onDeath.

I'm planning to do some onKill -"monstername" doCreateTeleport x,y,z setCountdown 20 seconds
when "Countdown"==0 doremoveitem x,y,z

I don't know if you understand that but here's question:

I couldn't find a "function" to put into the lib called "onKill" or "onDeath" and it isn't in my lua lib yet. I use TFS 0.3.6pl1(cryingDamson) - console

So, I don't know if i'm looking for a function or a lua script outside the lib..
I haven't really understood if I need the functions to use the function i.e. you may include a function in scripts if you declare what it does, but if you use the function as a "function" without declaring how it works, it needs somewhere to get that information from...

So. I'm a bit confused about this "onKill and onDeath". Could someone explain it to me, and maybe help me with the script I need:

It's an event, a boss spawns(or is alredy put there through a mapeditor), how you get there doesen't matter, I'll see to that, but what I want is that you have to kill the boss that spawns before you can get out from this room. Much like the "In service of yalahar" boss from real Tibia. It creates a teleport that leads to a reward room when the boss have been killed.

Thanks in advance, would be happy to just understand how the function works, if I need to look for the function or search for a script without implenting the function to my lib...

(Yeah I searched and looked through some scripts about onKil land onDeath but I didn't get any wiser).
 
LUA:
local m = {
		["XXXX"] = { -- Monster Here
			time = 10, -- Seconds
			to = { x = 1018, y = 1179, z = 7 }, -- Where Teleport Goes
			tp = { x = 1031, y = 1175, z = 6 } -- Where Teleport Creates
		}
	}

function onKill(cid, target)
	local monster = m[getCreatureName(target)]
		local function deleteTeleport()
			local teleport = getTileItemById(monster.tp, 1387)
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)
				doSendMagicEffect(monster.tp, CONST_ME_POFF)
				doSendAnimatedText(monster.tp, "Closed", TEXTCOLOR_RED)
			end
			return true
		end
	if(isPlayer(target) == true) then
		return true
	elseif(not monster) then
		return true
	else
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 6000)
		doSendMagicEffect(monster.tp, CONST_ME_ENERGYAREA)
		doCreatureSay(cid, "You have 60 seconds to enter the teleport!", TALKTYPE_ORANGE_1)
	end
	return true
end

u mean like that?
 
Yeah, not sure how

LUA:
time == 10
and
LUA:
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)
and
LUA:
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 6000)
is connected or how it works.

But to me it looks like the teleport will dissapear when the monster dies, also is it enough to put a monster name in there if there's just 1 monster with that name on the map?

I will test it now anyways. Er.. If I knew where to put this code ;P
 
Yeah, not sure how

LUA:
time == 10
It's the time in seconds for you to enter in the teleport, just 1 '='

and
LUA:
			if(teleport.uid > 0) then
				doRemoveItem(teleport.uid)

You shouldn't worry about that.

and
LUA:
		doCreateTeleport(1387, monster.to, monster.tp)
		addEvent(deleteTeleport, monster.time * 6000)

That will create a teleport and then add an addEvent which will delete it after the seconds you put in variable time.

also is it enough to put a monster name in there if there's just 1 monster with that name on the map?

Yes, you have to, else the script won't work.

Er.. If I knew where to put this code ;P

data/creaturescripts/scripts/name.lua
data/creaturescripts/creaturescripts.xml
XML:
<event type="kill" name="KillTp" event="script" value="name.lua"/>
 
Back
Top