[Release] Simple Jail Script


#1

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

RegisterNetEvent('jailPlayer')
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
    end
end)

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

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

[ Server.lua ]

leo = {
	"steam:127001abcdefg",
}

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)
			end
		end
end)

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

JailSystem.zip (1.3 KB)


#2

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?


#3

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.


#4

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


#5

Added a download just for you sir. :stuck_out_tongue:


#6

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


#7

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


#8

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."}})

#9

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


#10

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


#11

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


#12

So how exactly do i jail said person?


#13

Type /jail PlayerID Seconds


#14

Sweet, thanks for the quick response :slight_smile: