-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More jail time #12
Comments
Having this issue also |
This is due to the wrong calculation when you have ServerTimeOffline enabled. You can try this to fix it: On modules/prison/server.lua change function JailPlayer to this function JailPlayer(source, time, index, noSave)
if Prisoners[source] then return end
local index = index or "default"
local prison = Config.Prisons[index]
if not time or not prison then return end
local identifier = GetIdentifier(source)
Prisoners[source] = {
identifier = identifier,
index = index,
time = time,
inventory = TakeInventory(source),
sentence_date = os.time() + (time * 60),
}
SetPlayerMetadata(source, "injail", time)
TriggerClientEvent("pickle_prisons:jailPlayer", source, Prisoners[source])
if noSave then return end
MySQL.Async.execute("DELETE FROM pickle_prisons WHERE identifier=@identifier;", { ["@identifier"] = identifier })
MySQL.Async.execute(
"INSERT INTO pickle_prisons (identifier, prison, time, inventory, sentence_date) VALUES (@identifier, @prison, @time, @inventory, @sentence_date);",
{
["@identifier"] = Prisoners[source].identifier,
["@prison"] = Prisoners[source].index,
["@time"] = Prisoners[source].time,
["@inventory"] = json.encode(Prisoners[source].inventory),
["@sentence_date"] = Prisoners[source].sentence_date,
})
end and event pickle_prisons:initializePlayer to this RegisterNetEvent("pickle_prisons:initializePlayer", function()
local source = source
local identifier = GetIdentifier(source)
MySQL.Async.fetchAll("SELECT * FROM pickle_prisons WHERE identifier=@identifier;", { ["@identifier"] = identifier },
function(results)
local result = results[1]
if result then
local time = result.time
if Config.ServeTimeOffline then
time = math.ceil((result.sentence_date - os.time()) / 60)
end
Prisoners[source] = {
identifier = result.identifier,
index = result.prison,
time = time,
inventory = json.decode(result.inventory),
sentence_date = result.sentence_date,
}
if time <= 0 then
return UnjailPlayer(source)
end
SetPlayerMetadata(source, "injail", time)
TriggerClientEvent("pickle_prisons:jailPlayer", source, Prisoners[source])
end
end)
UpdateLootables(source)
TriggerClientEvent("pickle_prisons:setupInventory", source, { items = Inventory.Items })
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When player quit on jail and come back time get much bigger like 20min to 1000min
The text was updated successfully, but these errors were encountered: