Skip to content
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

refactor: (esx-qalle-jail) translated new strings through locales folder #541

Merged
merged 2 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ local Keys = {
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

ESX = nil

PlayerData = {}

local jailTime = 0

CreateThread(function()
Expand Down Expand Up @@ -55,14 +52,12 @@ end)
RegisterNetEvent("esx-qalle-jail:jailPlayer")
AddEventHandler("esx-qalle-jail:jailPlayer", function(newJailTime)
jailTime = newJailTime

Cutscene()
end)

RegisterNetEvent("esx-qalle-jail:unJailPlayer")
AddEventHandler("esx-qalle-jail:unJailPlayer", function()
jailTime = 0

UnJail()
end)

Expand All @@ -75,7 +70,6 @@ end

function UnJail()
InJail()

ESX.Game.Teleport(PlayerPedId(), Config.Teleports["Boiling Broke"])

ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
Expand All @@ -87,7 +81,6 @@ end
function InJail()

--Jail Timer--

CreateThread(function()
while jailTime > 0 do
jailTime = jailTime - 1
Expand All @@ -103,11 +96,9 @@ function InJail()
end

end)

--Jail Timer--

--Prison Work--

CreateThread(function()
while jailTime > 0 do

Expand Down Expand Up @@ -176,9 +167,7 @@ function LoadTeleporters()
end
end
end

Wait(sleepThread)

end
end)
end
Expand Down Expand Up @@ -261,14 +250,11 @@ function DeliverPackage(packageId)
end
end
end

end

end

function OpenJailMenu()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'jail_prison_menu',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'jail_prison_menu',
{
title = "Prison Menu",
align = 'center',
Expand Down Expand Up @@ -318,16 +304,12 @@ function OpenJailMenu()
else
TriggerServerEvent("esx-qalle-jail:jailPlayer", GetPlayerServerId(closestPlayer), jailTime, reason)
end

end

end, function(_, menu3)
menu3.close()
end)
end

end

end, function(_, menu2)
menu2.close()
end)
Expand Down Expand Up @@ -364,9 +346,7 @@ function OpenJailMenu()
menu2.close()
end)
end)

end

end, function(_, menu)
menu.close()
end)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fx_version 'adamant'
game 'gta5'
author 'qalle-git; refactor bitpredator'
author 'qalle-git; rework by: bitpredator'
lua54 'yes'
version '0.0.4'
version '1.0.0'
description "Jail Script With Working Job"

shared_script '@es_extended/imports.lua'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ Locales['en'] = {
['put_something'] = 'You need to put something here!',
['jail_empty'] = 'Your jail is empty!',
['not_officer'] = 'You are not an officer!',
['invalid_time'] = 'This time is invalid',
['id_not_online'] = 'This ID is not online',
['money_for_food'] = 'Here you have som cash for food!'
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ Locales['it'] = {
['put_something'] = 'Devi mettere qualcosa qui!',
['jail_empty'] = 'La tua prigione è vuota!',
['not_officer'] = 'Non sei un ufficiale!',
['invalid_time'] = 'Questo tempo non è valido',
['id_not_online'] = 'Questo ID non è online',
['money_for_food'] = 'Eccoti un po\' di soldi per il cibo!',
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ESX = nil
ESX = exports["es_extended"]:getSharedObject()
RegisterCommand("jail", function(src, args, raw)

RegisterCommand("jail", function(src, args, raw)
local xPlayer = ESX.GetPlayerFromId(src)

if xPlayer["job"]["name"] == "police" then
Expand All @@ -23,13 +22,13 @@ RegisterCommand("jail", function(src, args, raw)
end)
end
else
TriggerClientEvent("esx:showNotification", src, "This time is invalid!")
TriggerClientEvent("esx:showNotification", src, _U('invalid_time'))
end
else
TriggerClientEvent("esx:showNotification", src, "This ID is not online!")
TriggerClientEvent("esx:showNotification", src, _U("id_not_online"))
end
else
TriggerClientEvent("esx:showNotification", src, "You are not an officer!")
TriggerClientEvent("esx:showNotification", src, _U('not_officer'))
end
end)

Expand All @@ -44,10 +43,10 @@ RegisterCommand("unjail", function(src, args)
if GetPlayerName(jailPlayer) ~= nil then
UnJail(jailPlayer)
else
TriggerClientEvent("esx:showNotification", src, "This ID is not online!")
TriggerClientEvent("esx:showNotification", src, _U("id_not_online"))
end
else
TriggerClientEvent("esx:showNotification", src, "You are not an officer!")
TriggerClientEvent("esx:showNotification", src, _U('not_officer'))
end
end)

Expand All @@ -56,7 +55,7 @@ AddEventHandler("esx-qalle-jail:jailPlayer", function(targetSrc, jailTime, jailR
local src = source
local targetSrc = tonumber(targetSrc)
local xPlayer = ESX.GetPlayerFromId(src)

if xPlayer.job.name == 'police' then
JailPlayer(targetSrc, jailTime)

Expand All @@ -78,8 +77,7 @@ AddEventHandler("esx-qalle-jail:unJailPlayer", function(targetIdentifier)
if xPlayer ~= nil then
UnJail(xPlayer.source)
else
MySQL.Async.execute(
"UPDATE users SET jail = @newJailTime WHERE identifier = @identifier",
MySQL.Async.execute("UPDATE users SET jail = @newJailTime WHERE identifier = @identifier",
{
['@identifier'] = targetIdentifier,
['@newJailTime'] = 0
Expand All @@ -100,12 +98,9 @@ end)
RegisterServerEvent("esx-qalle-jail:prisonWorkReward")
AddEventHandler("esx-qalle-jail:prisonWorkReward", function()
local src = source

local xPlayer = ESX.GetPlayerFromId(src)

xPlayer.addMoney(math.random(13, 21))

TriggerClientEvent("esx:showNotification", src, "Thanks, here you have som cash for food!")
TriggerClientEvent("esx:showNotification", src, _U('money_for_food'))
end)

function JailPlayer(jailPlayer, jailTime)
Expand All @@ -123,12 +118,10 @@ end
function EditJailTime(source, jailTime)

local src = source

local xPlayer = ESX.GetPlayerFromId(src)
local Identifier = xPlayer.identifier

MySQL.Async.execute(
"UPDATE users SET jail = @newJailTime WHERE identifier = @identifier",
MySQL.Async.execute("UPDATE users SET jail = @newJailTime WHERE identifier = @identifier",
{
['@identifier'] = Identifier,
['@newJailTime'] = tonumber(jailTime)
Expand All @@ -147,27 +140,24 @@ function GetRPName(playerId, data)
end

ESX.RegisterServerCallback("esx-qalle-jail:retrieveJailedPlayers", function(source, cb)

local jailedPersons = {}

MySQL.Async.fetchAll("SELECT firstname, lastname, jail, identifier FROM users WHERE jail > @jail", { ["@jail"] = 0 }, function(result)

for i = 1, #result, 1 do
table.insert(jailedPersons, { name = result[i].firstname .. " " .. result[i].lastname, jailTime = result[i].jail, identifier = result[i].identifier })
end

cb(jailedPersons)
end)
end)

ESX.RegisterServerCallback("esx-qalle-jail:retrieveJailTime", function(source, cb)

local src = source

local xPlayer = ESX.GetPlayerFromId(src)
local Identifier = xPlayer.identifier


MySQL.Async.fetchAll("SELECT jail FROM users WHERE identifier = @identifier", { ["@identifier"] = Identifier }, function(result)

local JailTime = tonumber(result[1].jail)
Expand All @@ -180,4 +170,4 @@ ESX.RegisterServerCallback("esx-qalle-jail:retrieveJailTime", function(source, c
end

end)
end)
end)