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

Lua script to auto teleport char to X coords at x lvl

puhefihi

New Member
Joined
Sep 28, 2011
Messages
84
Reaction score
0
hey everyone basicly i need to teleport a character when they hit 55 to coords x32028, y32272, z6.. no matter where they are. Basicly i have my server and rook and your in rook till lvl 50.. BUT i want players to leave by themselves.. but if they dont leave when they hit lvl 55 i want to auto teleport them to those coords.. is it possible ?.

so when it says "congratulation you reached lvl 55" or what ever it says.. you go Pooof and end up at x32028, 32272, z6 :D. Thnx guys will rep of course.
 
try this

data/creaturescripts/scripts/teleportlevel.lua
Code:
local town15 = 2
local town50 = 3

function onAdvance(cid, skill, oldLevel, newLevel)
name = getCreatureName(cid)

if skill == SKILL__LEVEL and newLevel == 15 then
    doTeleportThing(cid, getTownTemplePosition(town15))

elseif skill == SKILL__LEVEL and newLevel == 50 then
    doTeleportThing(cid, getTownTemplePosition(town50))
end
return TRUE
end

data/creaturescripts/scripts/login.lua
Code:
registerCreatureEvent(cid, "teleportlevel")

data/creaturescripts/creaturescripts.xml
Code:
<event type="advance" name="teleportlevel" script="teleportlevel.lua"/>
 
so basicly didnt work, made potions not useable. made tons of error in server window.

Scratch that will test again, apperantly i changed 2 thigns at ounce and didnt realize.
 
Last edited:
Try this instead:

Code:
function onAdvance(cid, skill, oldLevel, newLevel)
local tpPos = {x=????, y=????, z=?} -- [COLOR=#008080]Enter your desired coordinates here.[/COLOR]

if skill == SKILL__LEVEL and newLevel == 55 then
doTeleportThing(cid, tpPos, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "[COLOR=#ff0000]Congratulations.[/COLOR]") -- [COLOR=#008080]Edit this message however you want.[/COLOR]
end
return TRUE
end
 
what do i save it in ? like what files. and that looks more exactly what im looking for. the first one made no sense to me. lol Ty.
 
ok just testing somethign now prob test it next 5 minutes tops.

ok when i put it in the scripts

data/creaturescripts/scripts/teleportlevel.lua <-- i create that folder.

data/creaturescripts/scripts/login.lua <-- when i put it in that script. i have to put it before the "end" right ?.

like this ?

function onLogin(cid)
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "teleportlevel")
return TRUE
end

----------------
and for the last one ?

<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="login" name="FirstItems" script="firstitems.lua"/>
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
<event type="advance" name="teleportlevel" script="teleportlevel.lua"/>
</creaturescripts>

looks good right ?

soryr am new at tibia scripting.. use to conquer online :D
ok and for the last one
 
[20/10/2011 12:45:49] Warning: [Event::checkScript] Can not load script. /scripts/teleportlevel.lua
[20/10/2011 12:45:49] cannot open data/creaturescripts/scripts/teleportlevel.lua: No such file or directory

i get that error in server window
 
Of course it needs ".lua"

I think I get your message two-way, so here's a tip if you have problems with showing formats.
If you don't have your computer set up to show file extensions:
Control Panel > Folder Options > View > [ ] Hide extensions for known file types or [x] Show file extensions.

The file should in any way be called exactly as you put in creaturescripts.xml, here: script="teleportlevel.lua"
 
so far not working, but i am checking the messages i get from lvling up i copied it and pasted it 100 percent. as well as the name of the files.
 
ok so im back to this error..
when i take out the .lua i dont have this error ALthough i already copied another lua file renamed it and took everyout and copied your script in
any ideas ? . i get the congrats u reached X lvl . but stil lable to hunt and what not.
 
15:04 You lose 3 hitpoints due to an attack by a wyrm.
15:04 You advanced from Level 54 to Level 55. <--- thats my congratz message
15:04 Loot of a wyrm: 61 gold coins, dragon ham, 57 gold coins
15:04 You lose 150 hitpoints due to an attack by a wyrm.
 
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="login" name="FirstItems" script="firstitems.lua"/>
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
<event type="advance" name="teleportlevel" script="teleportlevel.lua"/>
</creaturescripts>

thats my creaturescript.xml
 
function onLogin(cid)
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "teleportlevel")
return TRUE
end

thats my login
 
function onAdvance(cid, skill, oldLevel, newLevel)
local tpPos = {x=32028, y=32272, z=6}

if skill == SKILL__LEVEL and newLevel == 55 then
doTeleportThing(cid, tpPos, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced from Level 54 to Level 55")
end
return TRUE
end

thats my teleportlevel as a lua file :p which should make it .lua. LOL.

and this script is in the same file as my log in script or same directory i mean
 
Back
Top