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

Solved Portal of Citizenship

X X X

Newb
Joined
Jul 26, 2015
Messages
148
Reaction score
13
Hello. Does anybody know how to make a portal of citizenship, so when I step in the portal it sets my hometown? Help would be very much appreciated :D
Thank you!
 
What TFS version?
Generally.. set an actionid that is not used on the map editor, then make a movement script.
Make it teleport the player to the temple position of the town, and set the players town id.
 
What TFS version?
Generally.. set an actionid that is not used on the map editor, then make a movement script.
Make it teleport the player to the temple position of the town, and set the players town id.
This is my first OT... Do you have the script for that?
 
Code:
function onStepIn(cid, item, position, fromPosition)
    if item.actionid > 30020 and item.actionid < 30050 then
        local player = Player(cid)
        if not player then
            return false
        end
        local town = Town(item.actionid - 30020)
        player:setTown(town)
    end

    return true
end
Found in 0.2.15 data/movements/scripts/citizen.lua
Action id must be 30020+town number
I.E.
Thais is town #1
Set the action id of the TP in thais to 30021
Venore is town #2
Set the action id of the TP in venore to 30022, etc etc
 
Set Unique ID of the teleporter and make a new town in map editor and change the town ID.

Code:
--- Unique ID // Town ID ---

local config = {
    [50001] = 1,
}


function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    local townId = config[item.uid]
    if not townId then
        return true
    end

    local town = Town(townId)
    if not town then
        return true
    end

    player:setTown(town)
    player:teleportTo(town:getTemplePosition())
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You are now a citizen of ' .. town:getName() .. '.')
    return true
end
 
Code:
function onStepIn(cid, item, position, fromPosition)
    if item.actionid > 30020 and item.actionid < 30050 then
        local player = Player(cid)
        if not player then
            return false
        end
        local town = Town(item.actionid - 30020)
        player:setTown(town)
    end

    return true
end
Found in 0.2.15 data/movements/scripts/citizen.lua
Action id must be 30020+town number
I.E.
Thais is town #1
Set the action id of the TP in thais to 30021
Venore is town #2
Set the action id of the TP in venore to 30022, etc etc
Thanks :)
 
Ok so I'm using the code that you gave me @Bogart

My portal is correct, it looks like this:
12:18 You see a magic forcefield.
ItemID: [1387], ActionID: [30022].
Position: [X: 30461] [Y: 30035] [Z: 6].

And the server gives me this error:
[27/07/2015 12:16:19] Lua Script Error: [MoveEvents Interface]
[27/07/2015 12:16:19] data/movements/scripts/citizen.lua:onStepIn
[27/07/2015 12:16:19] data/movements/scripts/citizen.lua:3: attempt to call global 'Player' (a nil value)
[27/07/2015 12:16:19] stack traceback:
[27/07/2015 12:16:19] [C]: in function 'Player'
[27/07/2015 12:16:19] data/movements/scripts/citizen.lua:3: in function <data/movements/scripts/citizen.lua:1>

What's wrong?
 
Yes, it was 0.2.15. I originally had that script and it didn't work, so I changed it to Bogarts, but I just replaced it with the old script and it worked! Thanks guys
 
Back
Top