[Release] esx_jail

you have to add it to policejob locals en.lua so you dont see translation no more just what you name it as but it has to put like mine is other wise it wont show right

Thank you so much!

GodMode doesnt work in jail. All the prisioners are killing between them.

1 Like

Hey! Did you make it work?

Im trying to make it so you can open the doors as anyone using the lockpicks from esx_lockpick and have it trigger the police, can anyone help me with what code i should add and where? im relatively new to coding for FiveM

Hello there! I’m trying to change the option to teleport the prisoner to the release point after time served.
The plan is to look for the script if the prisoner is more than 100 m away from prison it doesn’t teleport him back.

Can you send me your ideas as reply? I’m stuck.

The idea is to use this base string: " if GetDistanceBetweenCoords(GetEntityCoords(playerPed), JailLocation.x, JailLocation.y, JailLocation.z) > 10 then "

try this


local IsJailed = false
local unjail = false
local JailTime = 0
local fastTimer = 0
local JailLocation = Config.JailLocation

ESX = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

RegisterNetEvent('esx_jail:jail')
AddEventHandler('esx_jail:jail', function(jailTime)
	if IsJailed then -- don't allow multiple jails
		return
	end

	JailTime = jailTime
	local playerPed = PlayerPedId()
	if DoesEntityExist(playerPed) then
		Citizen.CreateThread(function()
		
			-- Assign jail skin to user
			TriggerEvent('skinchanger:getSkin', function(skin)
				if skin.sex == 0 then
					TriggerEvent('skinchanger:loadClothes', skin, Config.Uniforms['prison_wear'].male)
				else
					TriggerEvent('skinchanger:loadClothes', skin, Config.Uniforms['prison_wear'].female)
				end
			end)
			
			-- Clear player
			SetPedArmour(playerPed, 0)
			ClearPedBloodDamage(playerPed)
			ResetPedVisibleDamage(playerPed)
			ClearPedLastWeaponDamage(playerPed)
			ResetPedMovementClipset(playerPed, 0)
			
			ESX.Game.Teleport(playerPed, JailLocation)
			IsJailed = true
			unjail = false
			while JailTime > 0 and not unjail do
				playerPed = PlayerPedId()

				RemoveAllPedWeapons(playerPed, true)
				if IsPedInAnyVehicle(playerPed, false) then
					ClearPedTasksImmediately(playerPed)
				end

				if JailTime % 120 == 0 then
					TriggerServerEvent('esx_jail:updateRemaining', JailTime)
				end

				Citizen.Wait(20000)
--need to test
				-- Is the player trying to escape?
				if GetDistanceBetweenCoords(GetEntityCoords(playerPed), JailLocation.x, JailLocation.y, JailLocation.z) > 50 then
				--	ESX.Game.Teleport(playerPed, JailLocation)
					TriggerEvent('chat:addMessage', { args = { _U('judge'), _U('escape_attempt') }, color = { 147, 196, 109 } })
					SendDistressSignal()
				end
				
				JailTime = JailTime - 20
			end

			-- jail time served
			TriggerServerEvent('esx_jail:unjailTime', -1)
			ESX.Game.Teleport(playerPed, Config.JailBlip)
			IsJailed = false

			-- Change back the user skin
			ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
				TriggerEvent('skinchanger:loadSkin', skin)
			end)
		end)
	end
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1)

		if JailTime > 0 and IsJailed then
			if fastTimer < 0 then
				fastTimer = JailTime
			end

			draw2dText(_U('remaining_msg', ESX.Math.Round(fastTimer)), { 0.175, 0.955 } )
			fastTimer = fastTimer - 0.01
		else
			Citizen.Wait(1000)
		end
	end
end)

RegisterNetEvent('esx_jail:unjail')
AddEventHandler('esx_jail:unjail', function(source)
	unjail = true
	JailTime = 0
	fastTimer = 0
end)

-- When player respawns / joins
AddEventHandler('playerSpawned', function(spawn)
	if IsJailed then
		ESX.Game.Teleport(PlayerPedId(), JailLocation)
	else
		TriggerServerEvent('esx_jail:checkJail')
	end
end)

-- When script starts
Citizen.CreateThread(function()
	Citizen.Wait(2000) -- wait for mysql-async to be ready, this should be enough time
	TriggerServerEvent('esx_jail:checkJail')
end)

-- Create Blips
Citizen.CreateThread(function()
	local blip = AddBlipForCoord(Config.JailBlip.x, Config.JailBlip.y, Config.JailBlip.z)
	SetBlipSprite (blip, 188)
	SetBlipDisplay(blip, 4)
	SetBlipScale  (blip, 1.9)
	SetBlipColour (blip, 4)
	SetBlipAsShortRange(blip, true)

	BeginTextCommandSetBlipName('STRING')
	AddTextComponentString(_U('blip_name'))
	EndTextCommandSetBlipName(blip)
end)

function draw2dText(text, pos)
	SetTextFont(4)
	SetTextProportional(1)
	SetTextScale(0.45, 0.45)
	SetTextColour(255, 255, 255, 255)
	SetTextDropShadow(0, 0, 0, 0, 255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	SetTextOutline()

	BeginTextCommandDisplayText('STRING')
	AddTextComponentSubstringPlayerName(text)
	EndTextCommandDisplayText(table.unpack(pos))
end

function SendDistressSignal()
	local playerPed = PlayerPedId()
	PedPosition		= GetEntityCoords(playerPed)
	
	local PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z }

	ESX.ShowNotification(_U('distress_sent'))

    TriggerServerEvent('esx_addons_gcphone:startCall', 'police', 'Tentative d\'evasion', PlayerCoords, {

		PlayerCoords = { x = PedPosition.x, y = PedPosition.y, z = PedPosition.z },
	})
end

DId you found the answer yet? I having a same issue

Nope ,doesnt works :confused:

how do i change the position of timer?

edit: found out

am unable to get this to work for esx_policejob is anyone able to help me a bit more?

You just need to follow the indications on the first post.

i have and when i try it in game then menu doesnt even pull up, so there is some issue thats making the police script crash – edit- im pretty new to scripting period, all self taught , been doing great with my server though, just some minor things i have bene unable to figure out, for now i just mod the polce, and they can jail.

1 Like

You can use the Scrambler PLEASE look at our Pullrequests

That message pops up and also when I put in a number nothing happens. Player doesn’t get sent to jail

i know im a bit late and if anyone is still even on this script but im facing an issue. whenever i go to open the jail menu in the F6 for the police job, it doesnt let me type then the menu for jailing glitches out. its like the menu isnt even on my screen but it is

Looking for a little help with esx jail for some reason you get released from jail a minute to 30secs early everytime notice last night went to jail for 4 min was release with 132secs left anyone have any tips on how to fix the timers?

need anti combatlog

el pumpo I love all your scripts it works all well, it’s great art. However on this script I had some problems, time level; if a person disconnects and reconnects, the prison time is reset, (he must remake the time completely). 2: When you reconnect, the clothes are no longer those of the prison.3: the unjail mode works halfway, the guy gets the message but does not end up outside the prison … I looked 3 times if you made this script, I thought it was was suspicious because normally everything works. I tested on a server 100% clean …
ps: I admire you very much you are the best fivem editor.

it’s good i’ve found your perfect upgraded version from A to Z just a problem with the sql in server.lua (in esx_jailer) change isDead by is_dead for the new esx_ambulancejob. But know that I admire you elpumpo :slight_smile: