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

MoveEvent TFS 1.4 citizenship with temple teleport

UberLerd

Member
Joined
Dec 24, 2017
Messages
29
Solutions
1
Reaction score
19
Hello everyone,

By default the TFS 1.4 citizen.lua script doesn't work, and it requires some modification so that you can set an actionID on the teleporters.

While we're at it, we can also modify the script so that when a player walks onto a citizenship teleporter, they get teleported to the new temple position. (I feel it's a nice effect)

We'll be setting the start range of citizen actionIDs at 30020 and the end range at 30100. This will give you a nice range of 80 town IDs to work with as your world grows.

The default movement event in movements.xml doesn't need to be modified, but yours should look like this.
XML:
    <!-- Citizen teleport -->
    <movevent event="StepIn" itemid="1387" script="citizen.lua" />

And we're going to change the default citizen.lua script from this:
Lua:
function onStepIn(creature, item, position, fromPosition)
    if item.actionid > actionIds.citizenship and item.actionid < actionIds.citizenshipLast then
        if not creature:isPlayer() then
            return false
        end
        local town = Town(item.actionid - actionIds.citizenship)
        if not town then
            return false
        end
        creature:setTown(town)
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are now a citizen of " .. town:getName() .. ".")
    end
    return true
end

To this!
Lua:
function onStepIn(creature, item, position, fromPosition)

actionIds.citizenship = 30020;
actionIds.citizenshipLast = 30100;

    if item.actionid > actionIds.citizenship and item.actionid < actionIds.citizenshipLast then
        if not creature:isPlayer() then
            return false
        end
        local town = Town(item.actionid - actionIds.citizenship)
        if not town then
            return false
        end
        creature:setTown(town)
        creature:teleportTo(creature:getTown():getTemplePosition())
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are now a citizen of " .. town:getName() .. ".")
    end
    return true
end

All that's left to do is add action IDs to your teleporters. For example, in Thais my town ID is 2, so I'll set the actionID of that teleporter to 30022.
2022-05-18 10_34_53-map1.otbm_ - Remere's Map Editor.png

And you're done. Congratulations on your working citizenship script with a nice teleport effect.
2022-05-18 10_36_46-OTCv8 - Uberlerd.png
 
Back
Top