(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
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.
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?
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.
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
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.