• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Set town after death

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
936
Solutions
2
Reaction score
57
Hello,
trying to set custome town after character dies so i have this in my config
Code:
    'towns' => array(
        0 => 'No town',
        1 => 'City',
        2 => 'Born',
        3 => 'Death'
    ),
and then i trying to set town id 3 after player dies in citizen.lua because you need to do it in citizen.lua but im not sure so
LUA:
function onStepIn(creature, item, position, fromPosition)
    if item.actionid > 30020 and item.actionid < 30050 then
        local player = creature:getPlayer()
        if player == nil then
            return false
        end

        local town = Town(item.actionid - 30023)
        player:setTown(town)
    end
    return true
end
But it doesnt work because it teleports in town 2
TFS 1.2
 
Solution
Look, what will determinate your townId is your MAP Towns Ids, not your website townId.

This actionId script dont have sense for me. If a actionId is 30040 - 30023 = 3?

LUA:
player:setTown(Town(3)) -- Town Id number to set a Town.
 
Last edited:
Look, what will determinate your townId is your MAP Towns Ids, not your website townId.

This actionId script dont have sense for me. If a actionId is 30040 - 30023 = 3?

LUA:
player:setTown(3) -- Town Id number to set a Town.
I dont know i found info in otland that you have to change
local town = Town(item.actionid - 30023)
which is id 3 and btw
player:setTown(3)
doesnt change anything.
 
Well still same, checked rme just to make sure position and id are good so have more ideas?
This script is for citizen portal only works when you step into it, and the action id is so you can use the script multiple times in different cities with only setting the action id differently.

Why not just registerEvent in login.lua then do an onDeath script like this?
LUA:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
    creature:setTown(Town(3))
    return true
end
 
This script is for citizen portal only works when you step into it, and the action id is so you can use the script multiple times in different cities with only setting the action id differently.

Why not just registerEvent in login.lua then do an onDeath script like this?
LUA:
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
    creature:setTown(Town(3))
    return true
end
Still nothing
 
Solution
Something is wrong on your end then. Make sure you have temple position set correctly for town id 3 in RME.

Also it's probably best to put this line of code in your pre-exisiting PlayerDeath script in creaturescripts.

After this line:
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/169eaadb28fa879c067008b5d7d0920284b96e84/data/creaturescripts/scripts/playerdeath.lua#L10)

Put:
player:setTown(Town(3))
Yea im sure 100% its correct id in rme. Yea it works now, btw why you wanted to add
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
in player.lua when there is playerdeath.lua? Whats the difference would be? I want to know just for future extra knowledge.
 
Yea im sure 100% its correct id in rme. Yea it works now, btw why you wanted to add
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified)
in player.lua when there is playerdeath.lua? Whats the difference would be? I want to know just for future extra knowledge.
If by player.lua you mean login.lua, you can see that PlayerDeath is already being registered in login.lua.
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/169eaadb28fa879c067008b5d7d0920284b96e84/data/creaturescripts/scripts/login.lua#L33)

My original idea was for you to make a new onDeath script, add in creaturescripts.xml and then register it in login.lua like PlayerDeath but i later realized it's easier to just include it in the pre-existing PlayerDeath onDeath script.
 
Back
Top