From 09a1995ebfa5346cba46f6c255692f2326eef093 Mon Sep 17 00:00:00 2001 From: JERICOFX Date: Thu, 28 Apr 2022 00:40:40 -0300 Subject: [PATCH] Added lang server side, added sound to report --- client/client.lua | 2 -- client/nuiCallbacks.lua | 10 +++------- langs/en.lua | 10 ++++++++++ langs/es.lua | 26 ++++++++++++++++++-------- server/server.lua | 35 +++++++++++++++-------------------- 5 files changed, 46 insertions(+), 37 deletions(-) diff --git a/client/client.lua b/client/client.lua index 6ee84b7..a73fc71 100644 --- a/client/client.lua +++ b/client/client.lua @@ -1,6 +1,5 @@ local Reports={} local Polices={} - CreateThread(function() Wait(200) for k,v in each(Config.AvaliablePC) do @@ -236,4 +235,3 @@ AddEventHandler('onResourceStart', function(resourceName) end TriggerServerEvent("fx-mdt:server:UpdateAllReports") end) - diff --git a/client/nuiCallbacks.lua b/client/nuiCallbacks.lua index d186f2a..78b9b98 100644 --- a/client/nuiCallbacks.lua +++ b/client/nuiCallbacks.lua @@ -29,13 +29,13 @@ RegisterNUICallback("getEvidence", function(data, cb) end) RegisterNUICallback("sendNewReport", function(data, cb) local Info = data - QBCore.Functions.TriggerCallback("fx-mdt:server:setNewReport", function(isok) cb(isok) - --TriggerServerEvent("fx-mdt:server:UpdateReports") end, Info) end) - +RegisterNetEvent("fx-mdt:client:PlaySound",function() + PlaySound(-1, "Event_Start_Text", "GTAO_FM_Events_Soundset", 0, 0, 1) +end) RegisterNUICallback("getAllPolices", function(data, cb) QBCore.Functions.TriggerCallback("fx-mdt:server:GetAllPolices", function(allPolices) cb(allPolices) @@ -135,10 +135,6 @@ RegisterNUICallback("setDestination", function(data, cb) cb({}) end) --- RegisterCommand("rfs", function(source, args) --- TriggerServerEvent("QBCore:Server:SetMetaData", "callsign", "NO CALLSIGN") --- end) - RegisterNUICallback("getDataByPlate", function(data, cb) local Plate = data.plate diff --git a/langs/en.lua b/langs/en.lua index 5695277..1d1fa1b 100644 --- a/langs/en.lua +++ b/langs/en.lua @@ -21,6 +21,16 @@ local Translations = { report = { send = "Report Sended", }, + server = { + new_report = "New Report Incoming", + message = "A fine has been created the amount to pay is $%{amount} if you need more information, please go to the police station and give this code %{id} to the officers.", + fine_situation = "Fine situation", + no_money = "Not enought money, you need ${amount}", + pay = "You paid the fine with the id {id} ", + taked_report = "Unit {call} has taked the report with the ID: {id}", + un_report = "The report ID: {id} was un-assigned by {call}", + delete_report = "The report ID: {id} was deleted", + }, } Lang = Locale:new({ diff --git a/langs/es.lua b/langs/es.lua index 35ddbb9..93b9d4a 100644 --- a/langs/es.lua +++ b/langs/es.lua @@ -1,25 +1,35 @@ local Translations = { computer = { - open_computer = "Abrir Pc", + open_computer = "Open Pc", }, money = { pay_fines = "Pagar Multas", - pay_fine = "Pagaste la Multa", + pay_fine = "Pagaste la multa", }, menu = { amount = "Cantidad", title = "Titulo", - no_fines = "No tienes multas activas", - report_add_message = "Agregar Mensaje", - report_title = "Agregar Reporte", - report_inser_message = "Mensaje a enviar, + no_fines = "No tienes ninguna multa pendiente", + report_add_message = "Añadir Mensaje", + report_title = "Añadir Mensaje al Reporte", + report_inser_message = "Escribe tu mensaje aca", }, error = { - no_in_vehicle = "No estas en un auto habilitado", + no_in_vehicle = "No estas en un vehiculo habilitado", no_message = "Necesitas colocar un mensaje", }, report = { - send = "Reporte enviado", + send = "Reporte Enviado", + }, + server = { + new_report = "Nuevo reporte recibido", + message = "Una multa fue puesta en su nombre, el monto es $%{amount} si necesitas mas informacion por favor ve a la estacion de policia mas cercana y brindales este codigo %{id} a los oficiales de policia.", + fine_situation = "Fine situation", + no_money = "No tienes suficiente dinero, necesitas: ${amount}", + pay = "Pagaste la multa con la ID: {id} ", + taked_report = "Unidad {call} tomo el reporte con la ID: {id}", + un_report = "El reporte ID: {id} fue desasignado por {call}", + delete_report = "El reporte ID: {id} fue borrado", }, } diff --git a/server/server.lua b/server/server.lua index 8bd380e..9020e60 100644 --- a/server/server.lua +++ b/server/server.lua @@ -261,17 +261,17 @@ CC("fx-mdt:server:payFine", function(source, cb, amount, id) local PlayerBank = Player.PlayerData.money.bank > tonumber(amount) if Player.PlayerData.citizenid then if PlayerCash then - Player.Functions.RemoveMoney("cash", amount, "Pago la fianza con la id "..id) + Player.Functions.RemoveMoney("cash", amount, Lang:t("server.pay",{id=id})) exports["qb-management"]:AddMoney("police", amount) local result = MySQL.query.await("DELETE FROM fx_reports WHERE id = ?", {id}) cb(true) elseif PlayerBank then - Player.Functions.RemoveMoney("bank", amount, "Pago la fianza con la id "..id) + Player.Functions.RemoveMoney("bank", amount, Lang:t("server.pay",{id=id})) exports["qb-management"]:AddMoney("police", amount) local result = MySQL.query.await("DELETE FROM fx_reports WHERE id = ?", {id}) cb(true) else - TriggerClientEvent("QBCore:Notify",source,"Not enought money") + TriggerClientEvent("QBCore:Notify",source,Lang:t("server.no_money",{amount=amount})) cb(false) end end @@ -290,10 +290,13 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) local coords = GetEntityCoords(GetPlayerPed(source)) local data1 = GetAllPolices() + + + CT(function() if data.report then if data.report.type == "basic" then - TriggerEvent("qb-phone:server:sendNewMailToOffline", data.report.citizenid, {sender = "Police Depto", subject = " Fine situation", message = "A fine has been created the amount to pay is $"..data.report.amount.." if you need more information, please go to the police station and give this code "..data.report.id.." to the officer."}) + TriggerEvent("qb-phone:server:sendNewMailToOffline", data.report.citizenid, {sender = "Police Depto", subject = Lang:t("server.fine_situation"), message = Lang:t("server.message",{amount= data.report.amount,id = data.report.id})}) end Wait(100) local Res = MySQL.query.await( @@ -321,6 +324,7 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) CurrentReports[#CurrentReports+1] = {data.report} cb(true) sendToPolicesOnly(data.report,"report") + elseif Res.affectedRows > 0 and data.report.type == "basic" then cb(true) else @@ -394,6 +398,7 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) for i = 1, #data1 do local el = data1[i] TriggerClientEvent("fx-mdt:client:deleteReport",el.src,id.id) + TriggerClientEvent("QBCore:Notify",el.src,Lang:t("server.delete_report",{id = id})) end end end) @@ -429,6 +434,8 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) TriggerClientEvent("fx-mdt:client:UpdateAllReports", el.src, t) else TriggerClientEvent("fx-mdt:client:UpdateReports", el.src, t) + TriggerClientEvent("fx-mdt:client:PlaySound",el.src) + TriggerClientEvent("QBCore:Notify", el.src, Lang:t("server.new_report"),"primary","5000") end end @@ -452,7 +459,7 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) {id.id, id.location, id.coords, id.citizenid, id.name, data.callsign, id.id}) for i = 1, #data1 do local el = data1[i] - TriggerClientEvent("QBCore:Notify", el.src, "Unit: "..data.callsign.." has taken the report ID: "..id.id) + TriggerClientEvent("QBCore:Notify", el.src, Lang:t("server.taked_report",{call = data.callsign,id = id.id})) TriggerClientEvent("fx-mdt:client:updateCallReport",el.src,id.id,data.callsign) end @@ -500,7 +507,8 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) local Update = MySQL.query("UPDATE fx_reports SET taked = 0, callsign = 'none' WHERE id = ?", {id}) for i = 1, #data1 do local el = data1[i] - TriggerClientEvent("QBCore:Notify", el.src, "The report ID: "..id.." Was deleted by "..callsign) + TriggerClientEvent("QBCore:Notify", el.src,Lang:t("server.un_report",{id = id,call = callsign}) ) + -- TriggerClientEvent("fx-mdt:client:deleteCall",el.src,id) end cb(true) @@ -534,19 +542,6 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) Wait(200) sendToPolicesOnly({title = Title,id = id,name = name,lastname = lastname,citizenid = citizenid,observations = message, data = {evidences = {}, polices = {}, fines = {}},type = "report",location = streetName,coords = coords,taked = 0,isvehicle = 0 },"report") end - -- tostring(data.report.id), - -- tostring(data.report.title), - -- tostring(data.report.name), - -- tostring(data.report.lastname), - -- tostring(data.report.citizenid), - -- data.report.plate, - -- data.report.location, - -- encode(coords), - -- tostring(data.report.observations), - -- encode(data.report.data), - -- data.report.amount, - -- data.report.type or "basic", - -- data.report.isvehicle and 1 or 0 end) QBCore.Commands.Add("fxr", "Update a report", {name = "id", help = "ID of the report"}, false, function(source, args) @@ -575,7 +570,7 @@ CC("fx-mdt:server:setNewReport", function(source, cb, data) if EX.EX == nil then local Ins = MySQL.insert.await("INSERT INTO fx_helprequest (uid,code,street,coords,text,taked,callsign,takedby) VALUES (?,?,?,?,?,?,?,?)", {tostring(data.uid), data.code, data.street, encode(data.coords), data.text, 0, data.callsign, "none"}) else - TriggerClientEvent("QBCore:Notify", src, "No puedes crear mas") + TriggerClientEvent("QBCore:Notify", src, "You can´t create more ") end Wait(100)