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

TalkAction [TFS 1.1] Jail / Unjail System

Summ

(\/)(;,,;)(\/) Y not?
Staff member
Global Moderator
Joined
Oct 15, 2008
Messages
4,152
Solutions
12
Reaction score
1,107
Location
Germany :O
Here is a jail system I just created.
Feel free to ask for suggestions / report bugs.
It works on TFS 1.1 for now.

You can use /jail <playername> to teleport someone to your jail.
You can use /unjail <playername> to bring someone out of the jail / teleport them to their temple.

Check out the config which is annotated with comments.

talkactions.xml
Code:
    <talkaction words="/jail" separator=" " script="jail.lua" />
    <talkaction words="/unjail" separator=" " script="jail.lua" />

jail.lua
Code:
local config = {
    -- List of players that cannot be jailed
    blacklist = {'Summ', 'Admin'},
    -- if true you can even jail other GMs :)
    canJailAccess = true,

    -- if true it will not show the name of the Staff member that used the command
    anonymous = false,

    -- Position of your jail
    jailPosition = Position(101, 116, 7),

    -- if unjailToTemple is set to true it will teleport the player to their hometown
    -- otherwise it will use unjailPosition
    unjailToTemple = true,
    unjailPosition = Position(95, 112, 7)
}


function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local targetPlayer = Player(param)
    if not targetPlayer then
        player:sendCancelMessage('Usage: ' .. words .. ' <playername>')
        return false
    end

    if not config.canJailAccess and targetPlayer:getGroup():getAccess() then
        player:sendCancelMessage('You cannot jail/unjail this player.')
        return false
    end

    local toPosition
    if words == '/jail' then
        toPosition = config.jailPosition
    elseif words == '/unjail' then
        if config.unjailToTemple then
            toPosition = targetPlayer:getTown():getTemplePosition()
        else
            toPosition = config.unjailPosition
        end
    end

    local action = string.sub(words, 2, #words) .. 'ed'
    player:sendCancelMessage('You have ' .. action .. ' ' .. player:getName() .. '.')
    targetPlayer:sendCancelMessage('You have been ' .. action .. (config.anonymous and '' or ' by ' .. targetPlayer:getName()) .. '.')
    targetPlayer:teleportTo(toPosition)
    toPosition:sendMagicEffect(CONST_ME_TELEPORT)
    return false
end

[Tag] summtfs11
 
Last edited:
Config ideas:
-A set time for how long a player will stay in jail until auto teleported to his original temple.
"You have been sent to Jail for 30 minutes"
(The player must probably have it set as storage so he wont relogg and get stuck)

-Check more jailpos if possible so the next "criminal" will be put in the cell beside the first.

Kind Regards,
Eldin.
 
Should be as shown below for the non-anonymous mode to work properly. I switched the targetPlayer name and player name around.

Code:
[LIST=1]
[*]local config = {
[*]    -- List of players that cannot be jailed
[*]    blacklist = {'Summ', 'Admin'},
[*]    -- if true you can even jail other GMs :)
[*]    canJailAccess = true,
[*]

[*]    -- if true it will not show the name of the Staff member that used the command
[*]    anonymous = false,
[*]

[*]    -- Position of your jail
[*]    jailPosition = Position(101, 116, 7),
[*]

[*]    -- if unjailToTemple is set to true it will teleport the player to their hometown
[*]    -- otherwise it will use unjailPosition
[*]    unjailToTemple = true,
[*]    unjailPosition = Position(95, 112, 7)
[*]}
[*]

[*]

[*]function onSay(player, words, param)
[*]    if not player:getGroup():getAccess() then
[*]        return true
[*]    end
[*]

[*]    local targetPlayer = Player(param)
[*]    if not targetPlayer then
[*]        player:sendCancelMessage('Usage: ' .. words .. ' <playername>')
[*]        return false
[*]    end
[*]

[*]    if not config.canJailAccess and targetPlayer:getGroup():getAccess() then
[*]        player:sendCancelMessage('You cannot jail/unjail this player.')
[*]        return false
[*]    end
[*]

[*]    local toPosition
[*]    if words == '/jail' then
[*]        toPosition = config.jailPosition
[*]    elseif words == '/unjail' then
[*]        if config.unjailToTemple then
[*]            toPosition = targetPlayer:getTown():getTemplePosition()
[*]        else
[*]            toPosition = config.unjailPosition
[*]        end
[*]    end
[*]

[*]    local action = string.sub(words, 2, #words) .. 'ed'
[*]    player:sendCancelMessage('You have ' .. action .. ' ' .. targetPlayer:getName() .. '.')
[*]    targetPlayer:sendCancelMessage('You have been ' .. action .. (config.anonymous and '' or ' by ' .. player:getName()) .. '.')
[*]    targetPlayer:teleportTo(toPosition)
[*]    toPosition:sendMagicEffect(CONST_ME_TELEPORT)
[*]    return false
[*]end
[*]
[/LIST]
 
why when i do /jail player it says i jail myself? someone pleaseeee?
 
Back
Top