Skip to content

Commit

Permalink
Added lang server side, added sound to report
Browse files Browse the repository at this point in the history
  • Loading branch information
JericoFX committed Apr 28, 2022
1 parent 824cbd1 commit 09a1995
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 37 deletions.
2 changes: 0 additions & 2 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local Reports={}
local Polices={}

CreateThread(function()
Wait(200)
for k,v in each(Config.AvaliablePC) do
Expand Down Expand Up @@ -236,4 +235,3 @@ AddEventHandler('onResourceStart', function(resourceName)
end
TriggerServerEvent("fx-mdt:server:UpdateAllReports")
end)

10 changes: 3 additions & 7 deletions client/nuiCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions langs/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
26 changes: 18 additions & 8 deletions langs/es.lua
Original file line number Diff line number Diff line change
@@ -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",
},
}

Expand Down
35 changes: 15 additions & 20 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 09a1995

Please sign in to comment.