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

Looking for Town Citizenship Scrip for teleport [TFS 1.0]

Haven't tested it, may not work.

In data/movements/movements.xml add line:
XML:
<movevent event="StepIn" uniqueid="40001" script="citizenship.lua" /> <!-- Town with ID 1 -->

In data/movements/scripts add new file named citizenship.lua:
Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end
    
    local newTownId = item.uid-40000
    local towns = Game:getTowns()
    local newTownName = towns[newTownId]:getName()
    
    if player:getTown():getID() ~= newTownId then
        player:setTown(newTownId)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTownName .. ".")
        return true
    end
    
    return false
end

Dont forget to place teleport with unique id of 40001 on map leading to temple of your town with id 1.
 
Doesn't work.

Haven't tested it, may not work.

In data/movements/movements.xml add line:
XML:
<movevent event="StepIn" uniqueid="40001" script="citizenship.lua" /> <!-- Town with ID 1 -->

In data/movements/scripts add new file named citizenship.lua:
Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end
   
    local newTownId = item.uid-40000
    local towns = Game:getTowns()
    local newTownName = towns[newTownId]:getName()
   
    if player:getTown():getID() ~= newTownId then
        player:setTown(newTownId)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTownName .. ".")
        return true
    end
   
    return false
end

Dont forget to place teleport with unique id of 40001 on map leading to temple of your town with id 1.
 
If not working post the error from console.

Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end
    
    local newTownId = item.uid-40000
    
    if player:getTown():getID() ~= newTownId then
        local newTown = Town(newTownId)
        player:setTown(newTown)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
        return true
    end
    
    return false
end
 
Capture.JPG
Post automatically merged:

If not working post the error from console.

Lua:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if player == nil then
        return false
    end
   
    local newTownId = item.uid-40000
   
    if player:getTown():getID() ~= newTownId then
        local newTown = Town(newTownId)
        player:setTown(newTown)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
        return true
    end
   
    return false
end
 
View attachment 44010
Post automatically merged:

Try this >>>>>>>>>>>>>>>> :D:D:D

Lua:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return false
    end
   
    local newTownId = item.uid - 40000
    if player:getTown():getId() ~= newTownId then
        local newTown = Town(newTownId)
        player:setTown(newTown)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
    end
   
    return true
end
 
Last edited:
I use this.

Code:
function onStepIn(cid, item, position, fromPosition)
    if(item.actionid > 30020 and item.actionid < 30100) then
        local townId = (item.actionid - 30020)
        doPlayerSetTown(cid, townId)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
    end

    return true
end
 
Doesn't Work. It also doesn't show anything on the Console.


Try this >>>>>>>>>>>>>>>> :D:D:D

Lua:
function onStepIn(cid, item, position, fromPosition)
    local player = Player(cid)
    if not player then
        return false
    end
  
    local newTownId = item.uid - 40000
    if player:getTown():getId() ~= newTownId then
        local newTown = Town(newTownId)
        player:setTown(newTown)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
    end
  
    return true
end
Post automatically merged:

Sould i put this lua as a uniqueid=40001 as well or as actionid = 30020

<movevent event="StepIn" uniqueid="40001" script="citizen.lua" />

I use this.

Code:
function onStepIn(cid, item, position, fromPosition)
    if(item.actionid > 30020 and item.actionid < 30100) then
        local townId = (item.actionid - 30020)
        doPlayerSetTown(cid, townId)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
    end

    return true
end
Post automatically merged:

And the Console is telling me something about the "unique ID Duplicated" if the 40001 is duplicated how can i change it to another unique ID? Do i have to make changes in the lua also?
 
Last edited:
Doesn't Work. It also doesn't show anything on the Console.



Post automatically merged:

Sould i put this lua as a uniqueid=40001 as well or as actionid = 30020

<movevent event="StepIn" uniqueid="40001" script="citizen.lua" />


Post automatically merged:

And the Console is telling me something about the "unique ID Duplicated" if the 40001 is duplicated how can i change it to another unique ID? Do i have to make changes in the lua also?
If you use this
Lua:
function onStepIn(cid, item, position, fromPosition)
    if(item.actionid > 30020 and item.actionid < 30100) then
        local townId = (item.actionid - 30020)
        doPlayerSetTown(cid, townId)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
    end

    return true
end
Then you set the action ID on teleporter to 30021 for town 1 and 30022 for town 2 and so on.
 
and then it set up on the Movement.XML like this?

<movevent event="StepIn" actionid="30020" script="citizen.lua" />


If you use this
Lua:
function onStepIn(cid, item, position, fromPosition)
    if(item.actionid > 30020 and item.actionid < 30100) then
        local townId = (item.actionid - 30020)
        doPlayerSetTown(cid, townId)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
    end

    return true
end
Then you set the action ID on teleporter to 30021 for town 1 and 30022 for town 2 and so on.
Post automatically merged:

and then it set up on the Movement.XML like this?

<movevent event="StepIn" actionid="30020" script="citizen.lua" />

and didnt work.
 
Back
Top