[Release] Simple Jail Script


This script was created by myself and @xander1998

Script runs off steam ID’s.

You WILL need to change the coordinates for your jail due to having a custom map.

[ Client.lua ]

local jailed = false

local defaultTime = 60

AddEventHandler('jailPlayer', function(ptime)
    defaultTime = ptime
    if not jailed then
        local ped = GetPlayerPed(PlayerId())
        SetEntityCoordsNoOffset(ped, 1798.65, 2483.26, -122.702, false, false, false, true)
        jailed = true

function TeleportOutJail()
    SetEntityCoords(GetPlayerPed(PlayerId()), 1851.12, 2585.54, 45.672, 0.0, 0.0, 0.0, false)
    SetEntityInvincible(GetPlayerPed(PlayerId()), false)

    while true do
        if jailed then
            SetEntityInvincible(GetPlayerPed(PlayerId()), true)
            for i = 1, defaultTime do
               --Citizen.Trace("TIME LEFT: " .. tostring(defaultTime - i))
                if defaultTime - i == 0 then
                    jailed = false

[ Server.lua ]

leo = {

RegisterCommand('jail', function(source, args)
    local PlyID = tonumber(args[1])
	local PlyTime = tonumber(args[2])
		for i = 1, #leo do
			if GetPlayerIdentifiers(source)[1] == leo[i] then
				TriggerClientEvent('jailPlayer', PlyID, PlyTime)

For the lazy people here’s the download :slight_smile:

JailSystem.zip (1.3 KB)


Looking good, a few suggestions and comments:

  • Have a command in-game/console to automatically add them to the LEO whitelist part. (Have this so admins with the ace permission can do said command)

  • If you leave the server to attempt to leave the jail, it spawns you back into the jail when you spawn back into the server, and extends the jail time?

A part from that, looking good, haven’t tested. Also, no DL zip/link?


Really didn’t see the need to zip such a small file.
As I stated this was just a simple script to RP a jail, But with some tweaks it can go much further.


At least make it easier for people to download? By zipping?


Added a download just for you sir. :stuck_out_tongue:


Anyone know a good spawn coord set for the default prison offhand?


Coords for Bolingbroke
X: 1641.27
Y: 2530.39
Z: 45.5649


You should add a command suggestion:

TriggerEvent('chat:addSuggestion', '/jail', 'Jails a person.', {{ name="ID", help="ID of the person to jail."}, { name="Time", help="Jailtime in seconds."}})


Does this have any kind of combat logging feature? will they still be jailed if they exit before finishing their jail sentence?


No. There isn’t a combat feature in the script.


Thanks Xander, you’re very helpful and you answer people asking questions about your scripts very fast, appreciate people like you in this community!


So how exactly do i jail said person?


Type /jail PlayerID Seconds


Sweet, thanks for the quick response :slight_smile:


would it be possible to add a password to this script, in the server.lua, were would a put like a password so only LEO’s can jail people


I would suggest not using a password option due to “security”, but to answer your question yes it can be done.