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

TFS 1.X+ Teleport Player per Vocation on item use

helium101

New Member
Joined
Sep 15, 2016
Messages
8
Reaction score
1
I am having trouble with a script I'm attempting to write that will send a player to a certain coordinate based on their vocation upon use of an item. Apologies in advanced if this script is a mess, I'm a hobbyist and am doing my best to learn.

I'm running TFS 1.3 for Tibia 10.98.

This is what the script looks like thus far:
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

if not(isPlayer(cid)) then return true end
    if (player:getVocation():getID() == 1) or (player:getVocation():getID() == 5) then
        function(player)
        doCreatureSay(cid, "Welcome, Sorcerer!", TALKTYPE_ORANGE_1)
        player:teleportTo(Position(32179, 31899, 8)) 
        end
    elseif (player:getVocation():getID() == 2) or (player:getVocation():getID() == 6) then
        function(player)
        doCreatureSay(cid, "Welcome, Druid!", TALKTYPE_ORANGE_1)
        player:teleportTo(Position(32175, 31905, 8))
        end
    elseif (player:getVocation():getID() == 3) or (player:getVocation():getID() == 7) then
        function(player)
        doCreatureSay(cid, "Welcome, Paladin!", TALKTYPE_ORANGE_1)
        player:teleportTo(Position(32184, 31890, 8))
        end
    elseif (player:getVocation():getID() == 4) or (player:getVocation():getID() == 8) then
        function(player)
        doCreatureSay(cid, "Welcome, Knight!", TALKTYPE_ORANGE_1)
        player:teleportTo(Position(32175, 31890, 8))
        end
    end
end
 
1. isPlayer(cid) will be false because cid isn't used anywhere in this script, plus it is impossible for this script to register without a player object
2. you don't need to call getId() 8 times, use a variable local id = player:getVocation():getId()
3. you don't need to wrap those welcome and teleports inside of functions, remove function(player) and the corresponding end
4. change doCreatureSay to player:say("Welcome, XXXX!", TALKTYPE_MONSTER)
 
Back
Top