[Release] ESX Database Jail Script - With pNotify. No more Combat Logging!

Can you port this for non ESX use just regular Essential?

Any fix for that “RELEASED=” bug in db?

Its not a bug, it says released when they have been released.

if i jail you. and you get released then it is shown released in db.
but if i jail you one more time. and you get released. the db wont show released on you then.
so you will always spawn outside the police station every time you login.
the only way to fix it is by deleting in the db.

I solved the bug, maybe i will release it. It’s easy if you search well

change in serverJailer

RegisterServerEvent("JailUpdate")
AddEventHandler("JailUpdate", function(newTime)
	local player = source
print("SOURCE="..source)
        player = source
print("TIME REMAINING="..newTime)
	local identifier = GetPlayerIdentifiers(player)[1]
	MySQL.Async.execute("UPDATE jail SET J_Time=@TIME WHERE identifier=@identifier", {["@TIME"] = newTime, ['@identifier'] = identifier})
        if newTime == 0 then
            local player = source
	    local identifier = GetPlayerIdentifiers(player)[1]
	    local newID = "RELEASED=" .. identifier
		local tempo = 0
	    MySQL.Async.execute("UPDATE jail SET J_Time=@TIME WHERE identifier=@identifier", {["@TIME"] = tempo, ['@identifier'] = identifier})
	    MySQL.Async.execute("UPDATE jail SET identifier=@ID WHERE identifier=@identifier", {["@ID"] = newID, ['@identifier'] = identifier})
        end
end)

RegisterServerEvent("JailRelease")
AddEventHandler("JailRelease", function(source)
print("PLAYER "..source.."IS NOW RELEASED")
	local player = source
	local identifier = GetPlayerIdentifiers(player)[1]
	local newID = "RELEASED=" .. identifier
	local tempo = 0
	MySQL.Async.execute("UPDATE jail SET J_Time=@TIME WHERE identifier=@identifier", {["@TIME"] = tempo, ['@identifier'] = identifier})
	MySQL.Async.execute("UPDATE jail SET identifier=@ID WHERE identifier=@identifier", {["@ID"] = newID, ['@identifier'] = identifier})
end)

RegisterServerEvent("JailReleaseTime")
AddEventHandler("JailReleaseTime", function()
print("PLAYER "..source.."IS NOW RELEASED")
	local player = source
	local identifier = GetPlayerIdentifiers(player)[1]
	local newID = "RELEASED=" .. identifier
	local tempo = 0
	MySQL.Async.execute("UPDATE jail SET J_Time=@TIME WHERE identifier=@identifier", {["@TIME"] = tempo, ['@identifier'] = identifier})
	MySQL.Async.execute("UPDATE jail SET identifier=@ID WHERE identifier=@identifier", {["@ID"] = newID, ['@identifier'] = identifier})
end)

unjail command

if cm[1] == "/unjail" then
			if xPlayer.job.name == 'police' then
				CancelEvent()
				local tPID = tonumber(cm[2])
				if GetPlayerName(tPID) ~= nil then
					print("".. GetPlayerName(tPID).. " foi libertado por ".. GetPlayerName(source))
					TriggerClientEvent("UnJP", tPID)
					TriggerEvent("JailRealease", tPID)
					newTime = 0
				end

this is n portuguese, cause i made it to my server

2 Likes
MySQL.Async.execute("DELETE FROM jail WHERE identifier=@identifier", {['@identifier'] = identifier})

Better Way

1 Like

where we need to put that can you explain more

Works very well with the above edit… :slight_smile: But the ` at the end has to be deleted… :wink:

1 Like

Yes, little mistake, if you know what you are doing you notice is a mistake. Sorry for that edited

1 Like

Can I update the github with that fix, I was going to fix myself, but I don’t work with fivem anymore.

Yes you can brooo, np

Thanks man, I was 2 lazy to fix it myself lol

Can you send me a copy of the one you’re using in your server atm. I can’t seem to download it off my github…

How come we can not put spaces in the reason, is there a way to we can allow that for example
/jail 1 5 |Assualt LEO x1 | Attempt Murder x1 | ect…"

Currently spaces are not supported is there a way to allow them.

Just make it so its so the info doesn’t save as a char atm it saves as a char I think , make it save as a string.

@Cheleber a little bit big confusing… is your download link up to date or we must inclode your scripts…?

Got this error all time i release on:
PLAYER 1IS NOW RELEASED
[ERROR] [MySQL] An error happens on MySQL for query “UPDATE jail SET identifier=@ID WHERE identifier=@identifier {@identifier=steam:xxx;@ID=RELEASED=steam:xxx}”: Duplicate entry ‘RELEASED=steam:xxx’ for key ‘PRIMARY’

First this is not my resource.

Second the right should be:

MySQL.Async.execute("DELETE FROM jail WHERE identifier=@identifier", {['@identifier'] = identifier})

not

Update

WHat are you meaning with that? changing something after 4 mins before???

Oh you are fater like me sorry i must read at first txh ! WOW! fast answert

where i insert this line, please?

RegisterServerEvent("JailUpdate")
AddEventHandler("JailUpdate", function(newTime)
	local player = source
print("SOURCE="..source)
        player = source
print("TIME REMAINING="..newTime)
	local identifier = GetPlayerIdentifiers(player)[1]
	MySQL.Async.execute("UPDATE jail SET J_Time=@TIME WHERE identifier=@identifier", {["@TIME"] = newTime, ['@identifier'] = identifier})
        if newTime == 0 then
        local player = source
	    local identifier = GetPlayerIdentifiers(player)[1]
	    MySQL.Async.execute("DELETE FROM jail WHERE identifier=@identifier", {['@identifier'] = identifier})
        end
end)

RegisterServerEvent("JailRelease")
AddEventHandler("JailRelease", function(source)
    print("PLAYER "..source.."IS NOW RELEASED")
	local player = source
	local identifier = GetPlayerIdentifiers(player)[1]
	local tempo = 0
	MySQL.Async.execute("DELETE FROM jail WHERE identifier=@identifier", {['@identifier'] = identifier})
end)

RegisterServerEvent("JailReleaseTime")
AddEventHandler("JailReleaseTime", function()
print("PLAYER "..source.."IS NOW RELEASED")
	local player = source
	local identifier = GetPlayerIdentifiers(player)[1]
	local tempo = 0
	MySQL.Async.execute("DELETE FROM jail WHERE identifier=@identifier", {['@identifier'] = identifier})
end)