• Vote in May Mapping Competition to select a winner!
  • 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]

Cosades

Banned User
Joined
Jan 1, 2012
Messages
28
Best answers
4
Reaction score
7
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.
 
OP
CesarZ

CesarZ

Member
Joined
Sep 20, 2012
Messages
83
Best answers
0
Reaction score
8
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.
 

Cosades

Banned User
Joined
Jan 1, 2012
Messages
28
Best answers
4
Reaction score
7
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
 
OP
CesarZ

CesarZ

Member
Joined
Sep 20, 2012
Messages
83
Best answers
0
Reaction score
8
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
 

mackerel

Well-Known Member
Joined
Apr 26, 2017
Messages
385
Best answers
17
Reaction score
67
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:

bilet

New Member
Joined
Jun 26, 2009
Messages
12
Best answers
0
Reaction score
0
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
 
OP
CesarZ

CesarZ

Member
Joined
Sep 20, 2012
Messages
83
Best answers
0
Reaction score
8
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:

Sparkles

snek
Joined
Mar 1, 2009
Messages
285
Best answers
24
Reaction score
122
Location
Norway, Tromsø
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.
 
OP
CesarZ

CesarZ

Member
Joined
Sep 20, 2012
Messages
83
Best answers
0
Reaction score
8
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.
 

Sparkles

snek
Joined
Mar 1, 2009
Messages
285
Best answers
24
Reaction score
122
Location
Norway, Tromsø
and then it set up on the Movement.XML like this?

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



Post automatically merged:



and didnt work.
<movevent event="StepIn" actionid="30021" script="citizen.lua" />
and set actionid to 30021
 
Top