With this jail system you can add more time to someone that's in jail. This is set up for TFS 8.54 distros and not tested unfortunately...
You will first need to execute this in your database...
Then in your 50-function put these codes...
and if you dont have it
In your globalevents
in your talkactions
Be sure to REP+ if you use this.. Thank you
You will first need to execute this in your database...
Code:
ALTER TABLE `players` ADD `jail_time` INT(11) NOT NULL DEFAULT 0;
Then in your 50-function put these codes...
Code:
function checkPlayerJailTime(cid)
local query = 'SELECT `jail_time` FROM `players` WHERE `id` = ..getPlayerId(cid)'
return query
end
function addJailTime(cid, amount)
local query = "INSERT INTO `players` SET `jail_time` = ..checkPlayerJailTime(cid).. + ..amount.. WHERE `id` = ..getPlayerId(cid)"
return query
end
and if you dont have it
Code:
function getPlayerId(cid)
local query = "SELECT `id` FROM `players` WHERE `name` = ..getPlayerName(cid)"
return query
end
In your globalevents
Code:
function onThink(interval, firstExecution, lastExecution)
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(pid, JAILED) == 1 then
addEvent(removePlayer, 60 * 1000)
setPlayerStorageValue(pid, JAILED, 2)
end
end
end
local function removePlayer()
if checkPlayerJailTime(pid) > 1 then
addJailTime(pid, -1)
addEvent(removePlayer, 60 * 1000)
elseif checkPlayerJailTime(pid) == 1 then
addJailTime(pid, -1)
doTeleportThing(pid, getPlayerMasterPos(pid))
doPlayerSendTextMessage(pid, 22, "You have been unjailed.")
end
end
in your talkactions
Code:
local JAILED = 34431
local default_jail_time = 5 -- in minutes
local jail_positions = {
[1] = {x = 1000, y = 1000, z = 7},
[2] = {x = 1000, y = 1000, z = 7},
[3] = {x = 1000, y = 1000, z = 7},
[4] = {x = 1000, y = 1000, z = 7},
[5] = {x = 1000, y = 1000, z = 7},
[6] = {x = 1000, y = 1000, z = 7},
[7] = {x = 1000, y = 1000, z = 7},
[8] = {x = 1000, y = 1000, z = 7},
[9] = {x = 1000, y = 1000, z = 7},
[10] = {x = 1000, y = 1000, z = 7},
[11] = {x = 1000, y = 1000, z = 7},
[12] = {x = 1000, y = 1000, z = 7}
}
function onSay(cid, words, param, channel)
if getPlayerAccess(cid) < 3 then
doPlayerSendCancel(cid, "You cannot execute this talkaction.")
return false
end
if (words == '!jail') then
if (param == '') then
doPlayerSendCancel(cid, "Command requires param")
return true
end
t = string.explode(param, ",")
t[1] = time
if isPlayer(getPlayerByNameWildcard(param)) then
local player = getPlayerByNameWildcard(param)
if (t[1]) then
if getPlayerStorageValue(player, JAILED) == 0 then
local jail_spot = math.random(JAIL_POSITIONS)
for _, pid in ipairs(jail_spot) do
if isPlayer(getThingFromPos(jail_spot).uid) then
jail_spot = math.random(JAIL_POSITIONS)
else
doTeleportThing(player, jail_spot)
end
end
setPlayerJailTime(player, t[1])
setPlayerStorageValue(player, JAILED, 1)
doPlayerSendTextMessage(player, 22, "You have been jailed for "..t[1].." minutes.")
doPlayerSendTextMessage(cid, 22, "You have jailed "..player..".")
else
setPlayerJailTime(player, t[1])
doPlayerSendTextMessage(player, 22, "You have been jailed for "..t[1].." more minutes.")
end
else
if getPlayerStorageValue(player, JAILED) == 0 then
local jail_spot = math.random(JAIL_POSITIONS)
for _, pid in ipairs(jail_spot) do
if isPlayer(getThingFromPos(jail_spot).uid) then
jail_spot = math.random(JAIL_POSITIONS)
else
doTeleportThing(player, jail_spot)
end
end
setPlayerJailTime(player, defualt_jail_time)
setPlayerStorageValue(player, JAILED, 1)
doPlayerSendTextMessage(player, 22, "You have been jailed for "..default_jail_time.." minutes.")
doPlayerSendTextMessage(cid, 22, "You have jailed "..player..".")
else
setPlayerJailTime(player, default_jail_time)
doPlayerSendTextMessage(player, 22, "You have been jailed for "..default_jail_time.." more minutes.")
end
end
else
doPlayerSendCancel(cid, "This is not a player.")
return false
end
end
end
Be sure to REP+ if you use this.. Thank you
Last edited: