[Release] esx_jail

esx_jail

A basic jail script. The current code is not maintained by me, but from whatever is left of the ESX community.

Installation

  1. Clone the project and add it to your resorces directory
  2. Add the project to your server.cfg
  3. Import esx_jail.sql in your database
  4. Select language in config.lua
  5. (Optional) See below on how to jail via esx_policejob

How to jail

  • Use the esx_jail:sendToJail(target, jailTime) server side trigger
  • Use the /jail playerID jailTime command (only admins)
  • Use the /unjail playerID to unjail a player (only admins)

Add to menu

  • you’ll have to unjail the target player first
    Example in esx_policejob: client/main.lua:
	{label = _U('fine'),			value = 'fine'},
	{label = _U('jail'),			value = 'jail'}

...

	elseif action == 'fine' then
		OpenFineMenu(closestPlayer)
	elseif action == 'license' then
		ShowPlayerLicense(closestPlayer)
	elseif action == 'jail' then
		JailPlayer(GetPlayerServerId(closestPlayer))
	end
---

function JailPlayer(player)
	ESX.UI.Menu.Open(
		'dialog', GetCurrentResourceName(), 'jail_menu',
		{
			title = _U('jail_menu_info'),
		},
	function (data2, menu)
		local jailTime = tonumber(data2.value)
		if jailTime == nil then
			ESX.ShowNotification(_U('invalid_amount'))
		else
			TriggerServerEvent("esx_jail:sendToJail", player, jailTime * 60)
			menu.close()
		end
	end,
	function (data2, menu)
		menu.close()
	end
	)
end
14 Likes

If I jail someone for 3 minutes, it sets it to 180 seconds in the database. But, the next time it updates (every 30 seconds), it sets it to -1 in the database. So if someone disconnects at that point they will be released upon relog.

3 Likes

Ok I’ve just fixed the problem, sorry!

Hey. im trying to use your script. the problem it wont work. i press F6 and the jail is not named. next is, i can not jail anyone. Idk but u written Use the esx_jailer:sendToJail(source, jailTime) server side trigger. What exactly does this mean?

1 Like

Yep, seems good now, that sneaky -1…

1 Like

Yes, you obviously have to edit the esx_policejob/client/main.lua file, look my policejob for example

Very nice base jail script. I made a couple tweaks for it to fit my needs exactly, but definitely an improvement to what I was using. Thanks for sharing.

1 Like

Very nice stuff mate, great script !! Wanna see how you will implement jailbreak, but anyways this is working like a charm, thanks !

1 Like

How is this better than any other jail script?
I am legitimately curious because I might want to use it.

so i am using this and it seems to be super nice i like it alot. im a little confused tho because i am admin in ESX but it throws me this huge error when i try to do /jail and if i try to unjail someone who is jailed it dosent work kind of a big issues for me the code seems to be there tho so idk why its not working

1 Like

Thank you! now it works. Seems like i made a , to much ^^

Same problem for me. /jail and /unjail do not work. Iam a admin on the server

So this script is working for me! However I noticed that only admins can jail and not the police, How can I change that?

this is only the chat commands. The menu works fine for the police

well I couldnt get the menu to work :confused:

is the f6 menu dont come up for all?

Exactly! I tried to put it the client main.lua but the menu didnt show up

If you guys do what he says it work

Lol guys I’ve told you to use the server side trigger! Look at my example that I’ve mentioned in the comments on how you can add it to the police job menu, it’s not automatic.

If you want to jail using the commands (which I don’t recommend) you’ll have to change the server side main.lua, this line and change admin to user