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

[Request] Teleport

Of course it is possible:

data/creaturescripts/scripts/scriptname.lua

Code:
[COLOR="DarkBlue"]--- Created by Darkhaos

[COLOR="DarkGreen"]function[/COLOR] onDeath(cid, corpse, killer)

	registerCreatureEvent(cid, "[COLOR="DarkGreen"]monsterTeleport[/COLOR]")

	local creaturename = getCreatureName(cid)
	local in_pos = [COLOR="DarkGreen"]{x=859, y=837, z=6, stackpos=2}[/COLOR]  -- position where the teleport will be created
	local checkIID = getThingfromPos(in_pos)
	local to_pos = [COLOR="DarkGreen"]{x=588, y=1086, z=7, stackpos=1}[/COLOR] -- position that the teleport will send you
	local time = [COLOR="DarkGreen"]10[/COLOR] -- in seconds, time before the teleport disappear
	local tpID = [COLOR="DarkGreen"]1387[/COLOR]
	local actionID = [COLOR="DarkGreen"]5000[/COLOR]

    if creaturename == '[COLOR="DarkGreen"]Demon[/COLOR]' then

		teleport = doCreateTeleport([COLOR="DarkGreen"]tpID[/COLOR], [COLOR="DarkGreen"]to_pos[/COLOR], [COLOR="DarkGreen"]in_pos[/COLOR])
		doSetItemActionId([COLOR="DarkGreen"]teleport[/COLOR], [COLOR="DarkGreen"]actionId[/COLOR])

		doSendMagicEffect([COLOR="DarkGreen"]in_pos[/COLOR], [COLOR="DarkGreen"]CONST_ME_TELEPORT[/COLOR])

		doCreatureSay(cid, [COLOR="Red"]"You now have 3 minutes to pass the teleporter before this disappear"[/COLOR], [COLOR="DarkGreen"]TALKTYPE_ORANGE_1[/COLOR])
		addEvent([COLOR="DarkGreen"]removeTeleport[/COLOR], [COLOR="DarkGreen"](1000*time)[/COLOR])

	
		end 
	end

function removeTeleport()

local in_pos = [COLOR="DarkGreen"]{x=859, y=837, z=6, stackpos=2}[/COLOR]

	if getThingfromPos(in_pos).itemid == [COLOR="DarkGreen"]1387[/COLOR] then
	doRemoveItem(getThingfromPos(in_pos).uid,[COLOR="DarkGreen"]1[/COLOR])
	doSendMagicEffect([COLOR="DarkGreen"]in_pos[/COLOR], [COLOR="DarkGreen"]CONST_ME_POFF[/COLOR])
	return TRUE
	end
end [/COLOR]

add in creaturescripts/scripts/login.lua:
After onLogin
Code:
[COLOR="Navy"]registerCreatureEvent(cid, "[COLOR="DarkGreen"]monsterTeleport[/COLOR]")[/COLOR]

in data/creaturescripts/creaturescripts.xml add:
Code:
[COLOR="Navy"]<event type="[COLOR="DarkGreen"]death[/COLOR]" name="[COLOR="DarkGreen"]monsterTeleport[/COLOR]" script="[COLOR="DarkGreen"]scriptname.lua[/COLOR]"/>[/COLOR]

In the monster (Demon in this example), add under </flags>:
Code:
[COLOR="Navy"]<script>
<event name="[COLOR="DarkGreen"]monsterTeleport[/COLOR]"/>
</script>[/COLOR]

In dada/movements/scripts/scriptname.lua:
Code:
[COLOR="Navy"]function onStepIn(cid, item, position, fromPosition)

local actionId = [COLOR="DarkGreen"]5000[/COLOR]
local storage = [COLOR="DarkGreen"]2550[/COLOR]
local toPos = [COLOR="DarkGreen"]{x=152, y=653, z=6}[/COLOR]
local backPos = [COLOR="DarkGreen"]{x=652, y=152, z=7}[/COLOR]

	[COLOR="DarkGreen"]if[/COLOR] item.actionid == [COLOR="DarkGreen"]actionId[/COLOR] and getPlayerStorageValue(cid) == [COLOR="DarkGreen"]-1[/COLOR] [COLOR="DarkGreen"]then[/COLOR]
		doTeleportThing(cid, [COLOR="DarkGreen"]toPos[/COLOR])
		doSendMagicEffect([COLOR="DarkGreen"]tpPos[/COLOR], [COLOR="DarkGreen"]CONST_ME_TELEPOR[/COLOR])
		setPlayerStorageValue(cid, [COLOR="DarkGreen"]storage[/COLOR], [COLOR="DarkGreen"]1[/COLOR])
	else
		doCreatureSay(cid, [COLOR="Red"]"You cannot pass"[/COLOR], [COLOR="DarkGreen"]TALKTYPE_ORANGE_1[/COLOR])
		doTeleportThing(cid, [COLOR="DarkGreen"]backPos[/COLOR])

	end
end[/COLOR]

and in data/movements/movements.xml:
Code:
[COLOR="Navy"]<movevent event="[COLOR="DarkGreen"]StepIn[/COLOR]" actionid="[COLOR="DarkGreen"]5000[/COLOR]" script="[COLOR="DarkGreen"]scriptname.lua[/COLOR]" />[/COLOR]

:)
 
This isnt giving me the storagevalue :S

EDIT:

HELLO AGAIN

I know wath was the problem, the actionid of the teleport was wrong, i think it must be betwen 100 and 1000. It was taking the default actionid so i change the actionid to 100 and numbers around 100.

Thx for your help the script is working for me now

=D
 
Last edited:
Back
Top