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

Teleport= Monster Alive, dont pass.

Manimecker

New Member
Joined
May 6, 2010
Messages
52
Reaction score
0
I need a script or something else for a quest that I'm doing, I need that the teleport can't be used if the monster of that room still alive.

Using: TFS 0.3.6 with Gesior 0.3.6 Mysql.
 
Lua:
local positions = { -- add the room tiles here
	{x=1349, y=826, z=13},
	{x=1350, y=826, z=13},
}

local tp = {x=1359, y=825, z=13} -- where the teleport is created
local tpto = {x=1350, y=807, z=13} -- where you tp to

function isPositionInArray(haystack, needle)
	for i = 1, #haystack do
		if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
			return true
		end
	end
end

function onKill(cid, target, flags)
	if getCreatureName(target):lower() == "YOUR MONSTER NAME HERE" then
		local myPos = getThingPos(cid)
		if isPositionInArray(positions, myPos) then
			doCreateTeleport(1387, tpto, tp)
			doBroadcastMessage("You got 1 minute to enter the portal before it dissapears.")
			addEvent(onRemove, 1 * 60 * 1000)
		end
	end
	return true
end

function onRemove()
		 doRemoveItem(getTileItemById(tp, 1387).uid)
         doSendMagicEffect(tp, CONST_ME_POFF)
return true
end

All credits to cykotitan for the script.
 
One thing, I don't want the teleport dissapear, just it don't be able to teleport the player if the mosnter still alive.

Thank you, but I need help with that.
 
fixed monster kill script:
Lua:
local positions = {
	{x=1349, y=826, z=13}, -- tiles to check
	{x=1350, y=826, z=13}, -- tiles to check
}

local storage = 60000

function isPositionInArray(haystack, needle)
	for i = 1, #haystack do
		if haystack[i].x == needle.x and haystack[i].y == needle.y and haystack[i].z == needle.z then
			return true
		end
	end
end

function onKill(cid, target, flags)
	if getCreatureName(target):lower() == "MONSTER NAME HERE" then
		local myPos = getThingPos(cid)
		if isPositionInArray(positions, myPos) then
			setPlayerStorageValue(cid,storage,1)
			doPlayerSendTextMessage(cid,22,'You got 1 minute to enter the teleport!')
			addEvent(ResetStorage, 1*60*1000)
		end
	end
	return true
end

function ResetStorage()
	setPlayerStorageValue(cid,storage,0)
return TRUE
end

Add this to creaturescripts.xml
Lua:
<event type="kill" name="MonsterKill" event="script" value="SCRIPTNAME.lua"/>

Also add this to login.lua (in creaturescripts/scripts)
Lua:
registerCreatureEvent(cid, "MonsterKill")

Give the teleport an actionid in map editor which is represented below:
Lua:
local cfg = {
	actionid = 10000, -- action id set on tp (in mapeditor)
	storage = 60000, -- storage
	destination = {x=1, y=1, z=1} -- where you tp to if you killed the monster
	}

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if item.actionid == cfg.actionid then
	if getPlayerStoragevalue(cid, cfg.storage) > 0 then
			doTeleportThing(cid, cfg.destination)
			doSendMagicEffect(cfg.destination,10)
	else
			doTeleportThing(cid, fromPosition, true)
	end
	return TRUE
end

Now add this to movements.xml:
Lua:
<movevent type="StepIn" actionid="10000" event="script" value="SCRIPT NAME.lua"/>

not tested, should work, only works with the killer though so not with multiple people.

This will give you a storage for 60 seconds after killing the monster and you may only enter the teleport within that period of time and after the 60 seconds you will lose the storage.
 
Last edited:
Back
Top