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

Kill monster before enter TP

Tofflarn

New Member
Joined
Mar 22, 2008
Messages
360
Reaction score
1
Location
Sweden
Well im working on a real Inq quest, and i need a script that when a team have killed the monster they can enter the teleport!
Something that add a storage value or something. Something like real Arena? Or maybe when team killed the boss a tp is created in a pos!


Would be awesome if someone could try this! Im don't think im alone to need this scripts!
so please help :)
 
Code:
function onStepIn(cid, item, frompos, item2, topos)
	local pos = {  -- Positions to scan for monsters.
		{x=666, y=777, z=7, stackpos=253},	
		{x=667, y=777, z=7, stackpos=253},
		{x=668, y=777, z=7, stackpos=253},
		{x=669, y=777, z=7, stackpos=253}
	}

	local canGo = true -- player can go before scan

	-- scanning floors
	for i=1, #pos do
	    -- is there monster in pos??  : )
		if(isMonster(getThingFromPos(pos[i].uid)) == TRUE)then
		canGo = false -- if is monster on scanned floor player cannot go!
		end
	end

	if(canGo == false)then -- cannot go? move back!  : )
		doTeleportThing(cid, frompos) -- teleport back! you must kill monsters!
	end
end
 
Last edited:
Is every x,y,z for one single monster, and what means with stackpos?.


and what should i put in action.xml? :P or movements?

And should the tp have any action id?
 
Last edited:
I've made this fast so i can't tell for sure if it works..

Code:
function onKill(cid, target)
local minutes = 1 -- How long people will be able to pass the teleport
local seconds = 30 -- This is in a addition with minutes
local monstername = "Hellgorak" -- Put the Monster name in there which has to be defeated
	if (isMonster(target) == TRUE) then
		if (getCreatureName(target) == monstername) then
			setGlobalStorageValue(500,1)
			addEvent(timeToPas,(1000*60*minutes) + (1000*seconds))
		else
			return FALSE
		end
	else
		return FALSE
	end
	return TRUE
end

function timeToPas()
	setGlobalStorageValue(500,-1)
	return TRUE
end

open your login.lua and put the following thing in..

Code:
registerCreatureEvent(cid, "nameofdefeatedmonster")

and also put this into creaturescripts.xml

Code:
<event type="kill" name="nameofthedefeatedmonster" script="nameofthefile.lua"/>

and this is the second part for it...

Code:
function onStepIn(cid, item, frompos, item2, topos)
local teleporter = xxxx -- actionid of the tp
local getValue = x -- only TRUE or FALSE work on it (shall the player get a storagevalue so it can be noticed that he has defeated that boss?)
local storagevalue = xxx -- storagevalue which he'll get if the option "getValue" is set as "TRUE"
local pos = {x=,y=,z=} -- position where he should be teleported
	if item.actionid == teleporter then
		if getGlobalStorageValue(500) == TRUE then
			doTeleportThing(cid,pos,0)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
			if (getValue == TRUE) then
				setPlayerStorageValue(cid,storagevalue,1)
			elseif (getValue == FALSE) then
				return TRUE
			end
		else
			doPlayerSendCancel(cid,"You have to defeat the Boss first to get through this.")
		end
	end
	return TRUE
end

and this goes into movements.xml ....

Code:
<movevent event="StepIn" actionid="itemactionid" script="nameofthefile.lua"/>

Hope it works like you wanted :)

kind regards, Evil Hero
 
Last edited:
Updated the "onStepIn" script

I've forgot to add pos = xxxxx
just copy and paste the updated one, sorry for that misstake :p

kind regards, Evil Hero
 
[16/11/2008 23:42:59] Warning: [Event::loadScript] Can not load script. data/movements/scripts/Annihilon.lua
[16/11/2008 23:42:59] data/movements/scripts/Annihilon.lua:9: unexpected symbol near ','


error :S
 
Code:
			doPlayerSendTextMessage(cid,"You where granted to leave this place."),21)
change to:
Code:
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place."))
 
Code:
			doPlayerSendTextMessage(cid,"You where granted to leave this place."),21)
change to:
Code:
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place."))

Updated the Script but found another little error had an extra ")" after the text >.<

seems correct now.

kind regards, Evil Hero
 
The scripts almost working. When i try to enter the tp without killing the monster i get the message. but when i kill the monster same thing happends. I don't get any storage value.

some errors,
[17/11/2008 12:11:57] Lua Script Error: [CreatureScript Interface]
[17/11/2008 12:11:57] data/creaturescripts/scripts/morga.lua:onKill

[17/11/2008 12:11:57] data/creaturescripts/scripts/morga.lua:5: attempt to call global 'isMonster' (a nil value)
[17/11/2008 12:11:57] stack traceback:
[17/11/2008 12:11:57] data/creaturescripts/scripts/morga.lua:5: in function <data/creaturescripts/scripts/morga.lua:1>




Creaturescripts:
function onKill(cid, target)
local minutes = 1 -- How long people will be able to pass the teleport
local seconds = 30 -- This is in a addition with minutes
local monstername = "Morgaroth" -- Put the Monster name in there which has to be defeated
if (isMonster(target) == TRUE) then
if (getCreatureName(target) == monstername) then
setGlobalStorageValue(5000,1)
addEvent(timeToPas,(1000*60*minutes) + (1000*seconds))
else
return FALSE
end
else
return FALSE
end
return TRUE
end

function timeToPas()
setGlobalStorageValue(5000,-1)
return TRUE
end


and movements
function onStepIn(cid, item, frompos, item2, topos)
local teleporter = 8001 -- actionid of the tp
local getValue = true -- only TRUE or FALSE work on it (shall the player get a storagevalue so it can be noticed that he has defeated that boss?)
local storagevalue = 5000 -- storagevalue which he'll get if the option "getValue" is set as "TRUE"
local pos = {x=91,y=126,z=7} -- position where he should be teleported
if item.actionid == teleporter then
if getGlobalStorageValue(5000) == TRUE then
doTeleportThing(cid,pos,0)
doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
if (getValue == TRUE) then
setPlayerStorageValue(cid,storagevalue,1)
elseif (getValue == FALSE) then
return TRUE
end
else
doPlayerSendCancel(cid,"You have to defeat the Boss first to get through this.")
end
end
return TRUE
end


whan do you think is wrong? i changed the storage value from 500 to 5000? should it change anything?
 
which server are you using...since the error says that your server doesn't have the function "isMonster"

you could try to change the line to "if (isPlayer(target) ~= TRUE) then" that would be a way to fix it...

and you have to change the "true" to "TRUE" since there is a difference with capitals :p

EDIT:

Script:

Code:
function onKill(cid, target)
local minutes = 1 -- How long people will be able to pass the teleport
local seconds = 30 -- This is in a addition with minutes
local monstername = "Hellgorak" -- Put the Monster name in there which has to be defeated
	if (isPlayer(target) ~= TRUE) then
		if (getCreatureName(target) == monstername) then
			setGlobalStorageValue(5000,1)
			addEvent(timeToPas,(1000*60*minutes) + (1000*seconds))
		else
			return FALSE
		end
	else
		return FALSE
	end
	return TRUE
end

function timeToPas()
	setGlobalStorageValue(5000,-1)
	return TRUE
end

kind regards, Evil Hero
 
Try this instead, everything is configurated already (but not tested)

Code:
function onKill(cid, target)
local minutes = 1 -- How long people will be able to pass the teleport
local seconds = 30 -- This is in a addition with minutes
local monstername = {["Hellgorak"] = 1,["Annihilion"] = 2,["Golgordan"] = 3,["Latrivan"] = 4,["Madareth"] = 5,["Ushuriel"] = 6,["Zugurosh"] = 7}
	if (isPlayer(target) ~= TRUE) then
		if monstername[getCreatureName(target)] then
			monster = monstername[getCreatureName(target)]
			setGlobalStorageValue(5000 + monster,1)
			local function timeToPass()
				return setGlobalStorageValue(5000 + monster,-1)
			end
			addEvent(timeToPass,(1000*60*minutes) + (1000*seconds))
		else
			return FALSE
		end
	else
		return FALSE
	end
	return TRUE
end

and this is the stepIn now

Code:
function onStepIn(cid, item, frompos, item2, topos)
local teleporter = 8001 -- actionid of the tp
local storagevalue = 5000 -- storagevalue which he'll get if the option "getValue" is set as "TRUE"
local hellgorak = {x=,y=,z=}
local annihilion = {x=,y=,z=}
local golgordan = {x=,y=,z=}
local latrivan = {x=,y=,z=}
local madareth = {x=,y=,z=}
local ushuriel = {x=,y=,z=}
local zugurosh = {x=,y=,z=}
	if item.actionid == teleporter then
		if getGlobalStorageValue(5001) == TRUE then
			doTeleportThing(cid,hellgorak,0)
			setPlayerStorageValue(cid,storagevalue +1,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5002) == TRUE then
			doTeleportThing(cid,annihilion,0)
			setPlayerStorageValue(cid,storagevalue +2,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5003) == TRUE then
			doTeleportThing(cid,golgordan,0)
			setPlayerStorageValue(cid,storagevalue +3,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5004) == TRUE then
			doTeleportThing(cid,latrivan,0)
			setPlayerStorageValue(cid,storagevalue +4,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5005) == TRUE then
			doTeleportThing(cid,madareth,0)
			setPlayerStorageValue(cid,storagevalue +5,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5006) == TRUE then
			doTeleportThing(cid,ushuriel,0)
			setPlayerStorageValue(cid,storagevalue +6,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		elseif getGlobalStorageValue(5007) == TRUE then
			doTeleportThing(cid,zugurosh,0)
			setPlayerStorageValue(cid,storagevalue +7,1)
			doPlayerSendTextMessage(cid,21,"You where granted to leave this place.")
		else
			doPlayerSendCancel(cid,"You may not pass before you defeated the Boss.")
		end
	end
	return TRUE
end

Like I said not tested.


kind regards, Evil Hero
 
Last edited:
[19/11/2008 16:44:25] Lua Script Error: [MoveEvents Interface]
[19/11/2008 16:44:25] data/movements/scripts/morga.lua:onStepIn

[19/11/2008 16:44:25] luaDoPlayerSendCancel(). Player not found


:S


and one more thing, the old script that worked. it gives all players on the server 5000 value when they enter TP. They could be everywhere on the server and still get 5000 value, aslong the monster is killed one time. :S if im right. (They don't get the storagevalue of they don't enter the tp..
hope you know what i mean.. my english is really bad atm.. Im in a hurry.! hope you can help me ! thx alot :D
 
[19/11/2008 16:44:25] Lua Script Error: [MoveEvents Interface]
[19/11/2008 16:44:25] data/movements/scripts/morga.lua:onStepIn

[19/11/2008 16:44:25] luaDoPlayerSendCancel(). Player not found


:S


and one more thing, the old script that worked. it gives all players on the server 5000 value when they enter TP. They could be everywhere on the server and still get 5000 value, aslong the monster is killed one time. :S if im right. (They don't get the storagevalue of they don't enter the tp..
hope you know what i mean.. my english is really bad atm.. Im in a hurry.! hope you can help me ! thx alot :D

Fixed the error was a missing "cid"

and about the value, yes it sets the value for all so people can go threw the tp but after 1 minute and 30 seconds (or what timezone you have set) no one will be able to step into the teleporter, until the monster is defeated again.
 
Back
Top