Skip to content

Commit

Permalink
refactor: (esx-qalle-jail) translated new strings through locales folder
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Oct 13, 2023
1 parent 2517e33 commit 18c805e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ function DeliverPackage(packageId)
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
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!',
}
34 changes: 12 additions & 22 deletions server-data/resources/[esx_addons]/esx-qalle-jail/server/server.lua
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)

0 comments on commit 18c805e

Please sign in to comment.