• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Jail System

comedinha

Well-Known Member
Joined
Apr 27, 2008
Messages
52
Reaction score
84
Location
Brazil
Distro: 1.0
Description: The script done by FreaksOt where i modified and made some changes.


Changes:
- When he holds the player is no longer in a fixed location, you can configure to put it into other cells.
- Time may or may not be fixed, you just enter /jail (player name) for a fixed time or /jail (player name), (time) to put it to a specific time.
-- OBS: The time is set in seconds. (120 seconds = 2 minutes)


TAG:
Code:
<talkaction log="yes" words="/jail" separator=" " script="jail.lua" />
<talkaction log="yes" words="/unjail" separator=" " script="jail.lua" />

Script: Texts in PT-BR
data/talkaction/jail.lua
Code:
grouprequired = 2
jailedstoragevalue_time = 1338
jailedstoragevalue_bool = 1339
local jailpos = { 
    [1] = {x = 59, y = 52, z =6},
    [2] = {x = 59, y = 52, z =5},
    [3] = {x = 55, y = 47, z =6},
    [4] = {x = 55, y = 47, z =5},
    [5] = {x = 55, y = 52, z =6},
    [6] = {x = 55, y = 52, z =5},
    [7] = {x = 59, y = 47, z =5},
    [8] = {x = 63, y = 52, z =5}
}
local unjailpos = { x = 63, y = 54, z =6 }
jail_list = {}
jail_list_work = 0

function checkJailList(param)
    addEvent(checkJailList, 1000, {})
    for targetID,player in ipairs(jail_list) do
        if isPlayer(player) == TRUE then
            if getPlayerStorageValue(player, jailedstoragevalue_time) < os.time() then
                doTeleportThing(player, unjailpos, TRUE)
                setPlayerStorageValue(player, jailedstoragevalue_time, 0)
                setPlayerStorageValue(player, jailedstoragevalue_bool, 0)
                table.remove(jail_list,targetID)
                doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, 'You got out of jail, try not to do evil things next time to avoid being arrested again. Take care friend.')
            end
        else
            table.remove(jail_list,targetID)
        end
    end
end

function onSay(cid, words, param)
    if not Player(cid):getGroup():getAccess() then
        return false
    end
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return false
    end
    local t = param:split(", ")
    if jail_list_work == 0 then
        jail_list_work = addEvent(checkJailList, 1000, {})
    end
    local jail_time = -1
    for word in string.gmatch(tostring(t[1]), "(%w+)") do
        if tostring(tonumber(word)) == word then
            jail_time = tonumber(word)
        end
    end
    local isplayer = getPlayerByName(t[1])
    if isPlayer(isplayer) ~= TRUE then
        isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+1))
        if isPlayer(isplayer) ~= TRUE then
            isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+2))
            if isPlayer(isplayer) ~= TRUE then
                isplayer = getPlayerByName(string.sub(t[1], string.len("jail_time")+3))
            end
        end
    end
    local default_jail = 30
    if(t[2]) then
        default_jail = t[2]
    end
    if jail_time ~= -1 then
        jail_time = jail_time * 60
    else
        jail_time = default_jail
    end
   
    if (words == '/jail') then
        if isPlayer(isplayer) == TRUE then
            doTeleportThing(isplayer, jailpos[math.random(#jailpos)], TRUE)
            setPlayerStorageValue(isplayer, jailedstoragevalue_time, os.time()+jail_time)
            setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 1)
            table.insert(jail_list,isplayer)
            doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You arrested the player '.. getCreatureName(isplayer) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
            doPlayerSendTextMessage (isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'You were arrested for '.. getCreatureName(cid) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player does not exist or is offline.")
        end
    elseif (words == '/unjail') then
        if isPlayer(isplayer) == TRUE then
            if getPlayerStorageValue(isplayer, jailedstoragevalue_bool) == 1 then
                doTeleportThing(isplayer, unjailpos, TRUE)
                setPlayerStorageValue(isplayer, jailedstoragevalue_time, 0)
                setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 0)
                table.remove(jail_list,targetID)
                doPlayerSendTextMessage(isplayer, MESSAGE_STATUS_CONSOLE_ORANGE, 'The player '.. getCreatureName(cid) ..' brought you out of jail. See you soon!')
                doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You removed out the player '.. getCreatureName(isplayer) ..'of the jail.')
            else
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player is not stuck.")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This player does not exist or is offline.")
        end
    end
    return false
end

Config:
Code:
local jailpos = { -- Place the saddles where the player will appear.
local unjailpos = { x = 63, y = 54, z =6 } -- Where it will go.
local default_jail = 30 -- Standard Time.

Créditos:
FreaksOt
Comedinha (Bruno Carvalho)
 
he doesnt work :S

try this one

add a file in data/talkactions/scripts and name it jail.lua paste this:

Code:
-- Default jail time in seconds --
default_jail = 60
-- The permission you need to jail someone --
grouprequired = 3
-- StorageValue that the player gets --
jailedstoragevalue_time = 1000000000000000000000000000000000000
jailedstoragevalue_bool = 1339
-- JAIL POSITION: --
jailpos = { x = 1011, y = 1013, z =8 }
-- TEMPLE POSITION: --
unjailpos = { x = 1000, y = 1000, z =7 }
-- auto kicker, dont edit
jail_list = {}
jail_list_work = 0

function checkJailList(param)
addEvent(checkJailList, 1000, {})
for targetID,player in ipairs(jail_list) do
if isPlayer(player) == TRUE then
if getPlayerStorageValue(player, jailedstoragevalue_time) < os.time() then
doTeleportThing(player, unjailpos, TRUE)
setPlayerStorageValue(player, jailedstoragevalue_time, 0)
setPlayerStorageValue(player, jailedstoragevalue_bool, 0)
table.remove(jail_list,targetID)
doPlayerSendTextMessage(player,MESSAGE_STATUS_CONSOLE_ORANGE,'You were kicked from jail! See you later ')
end
else
table.remove(jail_list,targetID)
end
end
end

function onSay(cid, words, param)
if jail_list_work == 0 then
jail_list_work = addEvent(checkJailList, 1000, {})
end
if param == '' and (words == '!unjail' or words == '/unjail') then
if getPlayerStorageValue(cid, jailedstoragevalue_time) > os.time() then
doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You are jailed until ' .. os.date("%H:%M:%S", getPlayerStorageValue(cid, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
else
if getPlayerStorageValue(cid, jailedstoragevalue_bool) == 1 then
table.insert(jail_list,cid)
doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You will be kicked from jail in one second.')
else
doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You are not jailed.')
end
end
return TRUE
end
local jail_time = -1
for word in string.gmatch(tostring(param), "(%w+)") do
if tostring(tonumber(word)) == word then
jail_time = tonumber(word)
end
end
local isplayer = getPlayerByName(param)
if isPlayer(isplayer) ~= TRUE then
isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+1))
if isPlayer(isplayer) ~= TRUE then
isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+2))
if isPlayer(isplayer) ~= TRUE then
isplayer = getPlayerByName(string.sub(param, string.len(jail_time)+3))
end
end
end
if jail_time ~= -1 then
jail_time = jail_time * 60
else
jail_time = default_jail
end
if words == '!jail' or words == '/jail' then
if getPlayerGroupId ( cid ) >= grouprequired then
if isPlayer(isplayer) == TRUE then
doTeleportThing(isplayer, jailpos, TRUE)
setPlayerStorageValue(isplayer, jailedstoragevalue_time, os.time()+jail_time)
setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 1)
table.insert(jail_list,isplayer)
doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You jailed '.. getCreatureName(isplayer) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
doPlayerSendTextMessage ( isplayer, MESSAGE_INFO_DESCR, 'You have been jailed by '.. getCreatureName(cid) ..' until ' .. os.date("%H:%M:%S", getPlayerStorageValue(isplayer, jailedstoragevalue_time)) .. ' (now is: ' .. os.date("%H:%M:%S", os.time()) .. ').')
return TRUE
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player with this name doesn\'t exist or is offline.")
return FALSE
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have access to unjail other players.")
return FALSE
end
elseif words == '!unjail' or words == '/unjail' then
if getPlayerGroupId ( cid ) >= grouprequired then
if isPlayer(isplayer) == TRUE then
doTeleportThing(isplayer, unjailpos, TRUE)
setPlayerStorageValue(isplayer, jailedstoragevalue_time, 0)
setPlayerStorageValue(isplayer, jailedstoragevalue_bool, 0)
table.remove(jail_list,targetID)
doPlayerSendTextMessage(isplayer,MESSAGE_STATUS_CONSOLE_ORANGE,getCreatureName(cid) .. ' let you go out from jail! See you later')
doPlayerSendTextMessage ( cid, MESSAGE_INFO_DESCR, 'You unjailed '.. getCreatureName(isplayer) ..'.')
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player with this name doesn\'t exist or is offline.")
return FALSE
end
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have access to unjail other players.")
return FALSE
end
end
return FALSE
end

and talkactions.xml add this:

Code:
    <talkaction log="yes" words="/jail" access="3" event="script" value="jail.lua"/>
    <talkaction log="yes" words="/unjail" access="3" event="script" value="jail.lua"/>
 
Its still doesnt work he founds /jail but if i do a name behind it you see it in local chat
 
Back
Top