Skip to content

Commit

Permalink
Huge refractor, now the event are more safer and light, so no more 81…
Browse files Browse the repository at this point in the history
…15bt sended over the network, this will not cause any Connection Timeout on some players
  • Loading branch information
JericoFX committed Apr 24, 2022
1 parent 3cba9a9 commit 70e8782
Show file tree
Hide file tree
Showing 24 changed files with 691 additions and 815 deletions.
37 changes: 30 additions & 7 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ RegisterNetEvent("QBCore:Client:OnPlayerLoaded",function()
return
end
TriggerServerEvent("fx-mdt:server:SendHelpOnLogin")
TriggerServerEvent("fx-mdt:server:UpdateReports")
TriggerServerEvent("fx-mdt:server:UpdateAllReports")
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate',function(job)
if job.name=="police" then
TriggerServerEvent("fx-mdt:server:SendHelpOnLogin")
TriggerServerEvent("fx-mdt:server:UpdateReports")
TriggerServerEvent("fx-mdt:server:UpdateAllReports")
end

end)

RegisterNetEvent("fx-mdt:client:UpdateReports",function(Reportes)
RegisterNetEvent("fx-mdt:client:UpdateAllReports",function(Reportes)
Reports={}
Reports=Reportes
SendData("updateReports",{reports=Reports})
Reports = Reportes
SendData("updateAllReports",{reports= Reports})
end)
function SendData(action,data)
if action and type(data)=="table" then
Expand All @@ -135,7 +135,7 @@ function SendData(action,data)
end

RegisterNetEvent("fx-mdt:client:openTablet",function()
TriggerServerEvent("fx-mdt:server:UpdateReports")
-- TriggerServerEvent("fx-mdt:server:UpdateReports")
TriggerServerEvent("fx-mdt:server:SendHelpOnLogin")
local metadata,citizenid,charinfo,job in QBCore.Functions.GetPlayerData()
SendData("openTablet",{
Expand All @@ -155,7 +155,7 @@ RegisterNetEvent("fx-mdt:client:openTablet",function()
end)

RegisterCommand("mdt",function(source,args)
TriggerServerEvent("fx-mdt:server:UpdateReports")
-- TriggerServerEvent("fx-mdt:server:UpdateReports")
local ped=PlayerPedId()
local veh=GetEntityModel(GetVehiclePedIsIn(ped))
local metadata,citizenid,charinfo,job in QBCore.Functions.GetPlayerData()
Expand Down Expand Up @@ -216,3 +216,26 @@ end)
RegisterNetEvent("fx-mdt:client:sendUpdateCalls",function(calls)
SendData("getMycalls",{calls=calls})
end)
RegisterNetEvent("fx-mdt:client:UpdateReports",function(data)
print(json.encode(data))
SendData("updateReports",{reports = data})
end)
RegisterNetEvent('fx-mdt:client:updateCallReport', function(id,call)

SendData("updateCallReport",{id = id,call=call})
end)
RegisterNetEvent('fx-mdt:client:deleteCall', function(id)
SendData("deleteCall",{id = id})
end)

RegisterNetEvent("fx-mdt:client:deleteReport",function(id)
print(id)
SendData("delReport",{id = id})
end)
AddEventHandler('onResourceStart', function(resourceName)
if (GetCurrentResourceName() ~= resourceName) then
return
end
TriggerServerEvent("fx-mdt:server:UpdateAllReports")
end)

28 changes: 15 additions & 13 deletions client/nuiCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ RegisterNUICallback("sendNewReport", function(data, cb)
local Info = data

QBCore.Functions.TriggerCallback("fx-mdt:server:setNewReport", function(isok)
cb({type = isok.type, reports = Reports})
TriggerServerEvent("fx-mdt:server:UpdateReports")
cb(isok)
--TriggerServerEvent("fx-mdt:server:UpdateReports")
end, Info)
end)

Expand All @@ -52,7 +52,6 @@ RegisterNUICallback("deleteReport", function(data, cb)

QBCore.Functions.TriggerCallback("fx-mdt:server:deleteReport", function(bol)
cb(bol)
--TriggerServerEvent("fx-mdt:server:UpdateReports")
end, ID)
end)
RegisterNUICallback("getReports", function(data, cb)
Expand All @@ -69,9 +68,9 @@ RegisterNUICallback("getVehicleByPlate", function(data, cb)
end, Plate)
end)

function addBlip(coords, text, cb)
function addBlip(coords, text)
local blips = {}
if coords ~= nil and text ~= nil and not cb then
if coords ~= nil and text ~= nil then
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
SetBlipSprite(blip, 535)
SetBlipColour(blip, 1)
Expand All @@ -84,8 +83,7 @@ function addBlip(coords, text, cb)
AddTextComponentString("CASE ID: "..blip)
EndTextCommandSetBlipName(blip)
blips[#blips + 1] = {id = text, bid = blip}
else
cb(blips)


end

Expand All @@ -108,7 +106,7 @@ end)

RegisterNUICallback("deleteAssignment", function(data, cb)
local ID = data.id
local Callsign = data?.callsign
local Callsign = data.callsign
QBCore.Functions.TriggerCallback("fx-mdt:server:deleteCall", function(cb1)
cb(cb1)
end, ID, Callsign)
Expand Down Expand Up @@ -139,10 +137,9 @@ RegisterNUICallback("setDestination", function(data, cb)
cb({})
end)

RegisterCommand("rfs", function(source, args)
TriggerServerEvent("QBCore:Server:SetMetaData", "callsign", "NO CALLSIGN")

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 Expand Up @@ -181,4 +178,9 @@ RegisterNetEvent("fx-mdt:client:HelpRequested", function(data)

end)


RegisterNUICallback("sendMessage",function (data,cb)
local msg = data.message
QBCore.Functions.Notify(tostring(msg))
cb({})
end)

3 changes: 2 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Config=Config or {}
Config = Config or {}
--Make this way, nameOfTheCar = true
Config.AllowedCars={
[`police`]=true,
Expand Down Expand Up @@ -35,6 +35,7 @@ Config.LangAvaliable={
index="en",
lang="English"
}}

Config.DefaultLang="en"


1 change: 1 addition & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ shared_scripts({
files({
"nui/dist/index.html",
"nui/dist/locales/*.json",
"nui/dist/utils/*.json",
"nui/dist/assets/*.js",
"nui/dist/assets/*.css",
"nui/dist/iconos/*.png",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nui/dist/assets/MyTool.517a58da.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 70e8782

Please sign in to comment.