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

Lua Jail System, read.

Jafab

Learning Graphic Design
Joined
Jun 30, 2010
Messages
339
Reaction score
5
Location
Miami, FL
Hey guys i'm using this script in my server:
--[[
OTLAND.NET / CREDITS
CREATED BY:
master-m
EDITED BY:
Lithium: Shorten.
Velik: Missing parts. Tested code.
Colandus: Missing end. Works for both TFS and Evolutions. Added more "checks". Shorten alot.
]]

-- Start the function --
function onSay ( cid, words, param )

-- Edit these positions bewlow --

-- The permission you need to jail someone --
grouprequired = 2

-- StorageValue that the player gets --
jailedstoragevalue = 1338

-- Set the position of the jail: --
jailpos = { x = 953, y = 495, z =7 }

-- Set the position once unjailed: --
unjailpos = { x = 881, y = 1051, z = 7 }

-- Stop edting unless you know what you are doing --

-- Executes the code below if it is the word is /jail --
if words == '/jail' then

-- Checks if the player is allowed to jail someone, said a playername to jail and looks if the player isn't in jail already --
if getPlayerGroupId ( cid ) >= grouprequired and param ~= "" and getPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue ) == -1 then

-- The actual code --

-- Gets the name of the one who jails someone --
jailer = getPlayerName ( cid )

-- Teleporting the person to jail --
doTeleportThing ( getPlayerByName ( param ), jailpos, 0 )

-- Sends a message to the jailed person --
doPlayerSendTextMessage ( getPlayerByName ( param ), 25, 'You have been jalied by '..jailer..'' )

-- Sends a message to the one who jails someone --
doPlayerSendTextMessage ( cid, 21, "You just jailed "..param.."." )

-- Gives the player a storage value to remember that he is jailed --
setPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue, 1 )

-- end of the actual code --


-- What to do if the player don't have the permission --
elseif getPlayerGroupId ( cid ) < grouprequired then

-- Sends the player a message that he doesn't have permission to jail someone --
doPlayerSendTextMessage ( cid, 21, "You are not permitted to jail anyone." )

-- What to do if the player is already jailed --
elseif getPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue ) ~= -1 then

-- Sends the player a message if the player is already jailed --
doPlayerSendTextMessage ( cid, 21, "This Player is already jailed." )

-- What to do if the player didn't fill in a name --
else
-- Sends the player a message that he forgot to fill in a playername --
doPlayerSendTextMessage ( cid, 21, "You need to fill in a playername!" )

-- Ends the checks --
end

-- Executes the code below if it is the word is /unjail --
elseif words == '/unjail' then

-- Checks if the player is allowed to unjail someone, said a playername to unjail and looks if the player isn't in unjailed already --
if getPlayerGroupId ( cid ) >= grouprequired and param ~= "" and getPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue ) == 1 then

-- The actual code --

-- Gets the name of the one who unjails someone --
unjailer = getPlayerName ( cid )

-- Teleporting the person outside the jail --
doTeleportThing ( getPlayerByName ( param ), unjailpos, 0 )

-- Sends a message to the unjailed person --
doPlayerSendTextMessage ( getPlayerByName ( param ), 25, 'You have been unjailed by '..unjailer..'' )

-- Sends a message to the one who unjailed someone --
doPlayerSendTextMessage ( cid, 21,"You just unjailed "..param.."." )

-- Removes the players storage value so we know that he isn't jailed anymore. --
setPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue, -1 )

-- end of the actual code --


-- What to do if the player don't have the permission --
elseif getPlayerGroupId ( cid ) < 4 then

-- Sends the player a message that he doesn't have permission to unjail someone --
doPlayerSendTextMessage ( cid, 21, "You cannot unjail someone!" )

-- What to do if the player is already unjailed --
elseif getPlayerStorageValue ( getPlayerByName ( param ), jailedstoragevalue ) ~= 1 then

-- Sends the player a message if the player is already unjailed --
doPlayerSendTextMessage ( cid, 21, "This Player is already unjailed." )

-- What to do if the player didn't fill in a name --
else

-- Sends the player a message that he forgot to fill in a playername --
doPlayerSendTextMessage ( cid, 21, "You need to fill in a playername!" )

-- Ends the checks --
end

-- Ends the ( un ) jailing part --
end

-- Ends the function --
end

But when i say /jail "Player i get this ingame:
20:31 This Player is already jailed.

And this in the .exe:
[25/03/2011 20:31:42] [Error - TalkAction Interface]
[25/03/2011 20:31:42] data/talkactions/scripts/jailing.lua:eek:nSay
[25/03/2011 20:31:42] Description:
[25/03/2011 20:31:42] (luaGetCreatureStorage) Creature not found
 
try this script:
Lua:
-- Default jail time in seconds --
default_jail = 300
-- The permission you need to jail someone --
grouprequired = 2
-- StorageValue that the player gets --
jailedstoragevalue_time = 1338
jailedstoragevalue_bool = 1339
-- Set the position of the jail: --
jailpos = { x = 1034, y = 1002, z =7 }
-- Set the position once unjailed: --
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! Make sure to follow the rules from now on !')
            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
 
Back
Top