diff --git a/client/exports.lua b/client/exports.lua index c5ab082..059d9ff 100644 --- a/client/exports.lua +++ b/client/exports.lua @@ -140,7 +140,6 @@ end exports('InjuriedPerson', InjuriedPerson) function EmergencyCall(message, phonenumber, anonymous) - local PlayerData = QBCore.Functions.GetPlayerData() local data = { tencodeid = phonenumber.."call", tencode = Config.TenCodes[phonenumber.."call"].tencode, @@ -148,8 +147,8 @@ function EmergencyCall(message, phonenumber, anonymous) gender = GetGender(), type = 0, coords = GetEntityCoords(cache.ped), - name = not anonymous and PlayerData.charinfo.lastname .. " " .. PlayerData.charinfo.firstname, - number = not anonymous and PlayerData.charinfo.phone, + name = not anonymous and QBX.PlayerData.charinfo.lastname .. " " .. QBX.PlayerData.charinfo.firstname, + number = not anonymous and QBX.PlayerData.charinfo.phone, information = message, title = Config.TenCodes[phonenumber.."call"].title, jobs = Config.TenCodes[phonenumber.."call"].jobs @@ -166,13 +165,12 @@ local function Code99(servicetype) service = 'ems99' end if not service then return end - local PlayerData = QBCore.Functions.GetPlayerData() local data = { tencodeid = service, tencode = Config.TenCodes[service].tencode, location = GetLocation(GetEntityCoords(cache.ped)), - name = PlayerData.charinfo.lastname .. " " .. PlayerData.charinfo.firstname, - callsign = PlayerData.metadata.callsign, + name = QBX.PlayerData.charinfo.lastname .. " " .. QBX.PlayerData.charinfo.firstname, + callsign = QBX.PlayerData.metadata.callsign, type = 1, coords = GetEntityCoords(cache.ped), title = Config.TenCodes[service].title, diff --git a/client/main.lua b/client/main.lua index 94053c1..0f04417 100644 --- a/client/main.lua +++ b/client/main.lua @@ -28,7 +28,7 @@ function GetVehicleData(vehicle) Data.id = NetworkGetNetworkIdFromEntity(vehicle) Data.speed = GetEntitySpeed(vehicle) Data.name = GetLabelText(GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))) - Data.name = Data.name == 'NULL' and QBCore.Shared.Vehicles[model].name or Data.name + Data.name = Data.name == 'NULL' and exports.qbx_core:GetVehiclesByName().Vehicles[model].name or Data.name local primary, secondary = GetVehicleColours(vehicle) local color1, color2 = Lang:t('colors.' .. primary), Lang:t('colors.' .. secondary) @@ -46,8 +46,7 @@ end --- returns the player's gender ---@return string function GetGender() - local PlayerData = QBCore.Functions.GetPlayerData() - return PlayerData.charinfo.gender + return tostring(QBX.PlayerData.charinfo.gender) end --- returns the heading of the player @@ -68,7 +67,7 @@ end local WeaponClasses = { [2685387236] = Lang:t('WeaponClasses.melee'), [416676503] = Lang:t('WeaponClasses.gun'), - [-95776620] = Lang:t('WeaponClasses.submachinegun'), + [-95776620] = Lang:t('WeaponClasses.submachinegun'), [860033945] = Lang:t('WeaponClasses.shotgun'), [970310034] = Lang:t('WeaponClasses.assaultrifle'), [1159398588] = Lang:t('WeaponClasses.lightmachinegun'), @@ -111,8 +110,7 @@ local fightAntiSpam = false local function fight(ped) if ped ~= cache.ped then return end - local PlayerData = QBCore.Functions.GetPlayerData() - if CheckJob(Config.Events.fight.jobwhitelist, PlayerData.job) and PlayerData.job.onduty then return end + if CheckJob(Config.Events.fight.jobwhitelist, QBX.PlayerData.job) and QBX.PlayerData.job.onduty then return end fightAntiSpam = true exports['qbx-dispatch']:Fight() @@ -127,8 +125,7 @@ local function shotfired(ped) if IsPedCurrentWeaponSilenced(ped) and math.random() <= 0.98 then return end -- 2% chance to trigger the event if the weapon is silenced, ( real life weapons are not 100% silent ;c ) - local PlayerData = QBCore.Functions.GetPlayerData() - if CheckJob(Config.Events.shotsfired.jobwhitelist, PlayerData.job) and PlayerData.job.onduty then return end + if CheckJob(Config.Events.shotsfired.jobwhitelist, QBX.PlayerData.job) and QBX.PlayerData.job.onduty then return end shotsfiredAntiSpam = true if cache.vehicle then @@ -193,9 +190,8 @@ end RegisterNetEvent('qbx-dispatch:client:AddCall', function(Data, CallId) if DispatchDisabled then return end if not Data or not LocalPlayer.state.isLoggedIn then return end - local PlayerData = QBCore.Functions.GetPlayerData() - if Data.jobs and not CheckJob(Data.jobs, PlayerData.job) then return end - if Config.OnlyOnDuty and not PlayerData.job.onduty then return end + if Data.jobs and not CheckJob(Data.jobs, QBX.PlayerData.job) then return end + if Config.OnlyOnDuty and not QBX.PlayerData.job.onduty then return end if not Data.coords then return end if Data.speed then Data.speed = (Config.UseMPH and math.ceil(Data.speed * 2.236936) .. " Mph") or (math.ceil(Data.speed * 3.6) .. " Km/h") end @@ -206,7 +202,7 @@ RegisterNetEvent('qbx-dispatch:client:AddCall', function(Data, CallId) }) local sound = Config.TenCodes[Data.tencodeid].sound - if PlayerData.metadata.mutedispatch or not sound then return end + if QBX.PlayerData.metadata.mutedispatch or not sound then return end if not sound.custom then PlaySound(-1, sound.name, sound.ref, false, false, true) return end TriggerServerEvent("InteractSound_SV:PlayOnSource", sound.name, sound.volume or 0.25) -- For Custom Sounds end) @@ -217,9 +213,8 @@ end) ---@param CallId number RegisterNetEvent("qbx-dispatch:client:AddBlip", function(coords, data, CallId) if DispatchDisabled then return end - local PlayerData = QBCore.Functions.GetPlayerData() - if not data.jobs or not CheckJob(data.jobs, PlayerData.job) then return end - if not (not Config.OnlyOnDuty or PlayerData.job.onduty) then return end + if not data?.jobs or not CheckJob(data?.jobs, QBX.PlayerData.job) then return end + if not (not Config.OnlyOnDuty or QBX.PlayerData.job.onduty) then return end local alpha = 255 local radiusAlpha = 128 local blip, radius @@ -294,21 +289,21 @@ RegisterNetEvent("qbx-dispatch:client:ClearBlips", function() end radiuses = {} blips = {} - QBCore.Functions.Notify(Lang:t('success.clearedblips'), "success") + exports.qbx_core:Notify(Lang:t('success.clearedblips'), "success") end) --- Disables the dispatch RegisterNetEvent("qbx-dispatch:client:DisableDispatch", function() DispatchDisabled = not DispatchDisabled - QBCore.Functions.Notify(DispatchDisabled and Lang:t('success.disableddispatch') or Lang:t('success.enableddispatch'), "success") + exports.qbx_core:Notify(DispatchDisabled and Lang:t('success.disableddispatch') or Lang:t('success.enableddispatch'), "success") end) --- Sends a message to the dispatch when someone send a message to 911 (NPWD) RegisterNetEvent('qbx-dispatch:NPWD:Text911', function(message) local msg = message - if string.len(msg) <= 0 then QBCore.Functions.Notify(Lang:t('error.nomessage'), 'error') return end - if exports['qbx-policejob']:IsHandcuffed() then QBCore.Functions.Notify(Lang:t('error.handcuffed'), 'error') return end - if exports.npwd:isPhoneDisabled() then QBCore.Functions.Notify(Lang:t('error.disabledphone'), 'error') return end + if string.len(msg) <= 0 then exports.qbx_core:Notify(Lang:t('error.nomessage'), 'error') return end + if exports['qbx-policejob']:IsHandcuffed() then exports.qbx_core:Notify(Lang:t('error.handcuffed'), 'error') return end + if exports.npwd:isPhoneDisabled() then exports.qbx_core:Notify(Lang:t('error.disabledphone'), 'error') return end local anonymous = (((Config.AllowAnonText and string.split(message, " ")[1] == "anon") and true) or false) if anonymous then message = string.gsub(message, "anon ", "") end @@ -318,9 +313,9 @@ end) --- Sends a message to the dispatch when someone send a message to 912 (NPWD) RegisterNetEvent('qbx-dispatch:NPWD:Text912', function(message) local msg = message - if string.len(msg) <= 0 then QBCore.Functions.Notify(Lang:t('error.nomessage'), 'error') return end - if exports['qbx-policejob']:IsHandcuffed() then QBCore.Functions.Notify(Lang:t('error.handcuffed'), 'error') return end - if exports.npwd:isPhoneDisabled() then QBCore.Functions.Notify(Lang:t('error.disabledphone'), 'error') return end + if string.len(msg) <= 0 then exports.qbx_core:Notify(Lang:t('error.nomessage'), 'error') return end + if exports['qbx-policejob']:IsHandcuffed() then exports.qbx_core:Notify(Lang:t('error.handcuffed'), 'error') return end + if exports.npwd:isPhoneDisabled() then exports.qbx_core:Notify(Lang:t('error.disabledphone'), 'error') return end local anonymous = (((Config.AllowAnonText and string.split(message, " ")[1] == "anon") and true) or false) if anonymous then message = string.gsub(message, "anon ", "") end @@ -330,7 +325,6 @@ end) --#region Keybinds --- Accepting and denying calls - lib.addKeybind({ name = 'acceptdispatch', description = Lang:t('general.acceptdispatchcall'), @@ -347,4 +341,4 @@ lib.addKeybind({ end }) --- ---#endregion Keybinds +--#endregion Keybinds \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 8a36d58..b3010b4 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,19 +1,21 @@ fx_version 'cerulean' game 'gta5' -version '1.0.4' +author 'Tonybyn_Mp4' +description 'Dispatch resource for the Qbox framework' +version '1.1.0' shared_scripts { - '@qbx-core/import.lua', + "@qbx_core/import.lua", '@ox_lib/init.lua', - '@qbx-core/shared/locale.lua', + '@qbx_core/shared/locale.lua', 'locales/en.lua', 'locales/*.lua', 'config.lua', } modules { - 'qbx-core:core' + "qbx_core:client:playerdata" } client_scripts { @@ -38,4 +40,4 @@ dependencies { } lua54 'yes' -use_experimental_fxv2_oal 'yes' +use_experimental_fxv2_oal 'yes' \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index 7574daa..582b9fd 100644 --- a/server/main.lua +++ b/server/main.lua @@ -23,13 +23,13 @@ RegisterServerEvent("qbx-dispatch:server:AddCall", function(info) end) lib.addCommand('mutedispatch', {help = Lang:t('commands.mutedispatch')}, function(source, _) - local Player = QBCore.Functions.GetPlayer(source) - Player.Functions.SetMetaData('mutedispatch', not Player.PlayerData.metadata['mutedispatch']) - QBCore.Player.Save(source) + local player = exports.qbx_core:GetPlayer(source) + player.Functions.SetMetaData('mutedispatch', not player.PlayerData.metadata['mutedispatch']) + exports.qbx_core:Save(source) end) lib.addCommand('disabledispatch', {help = Lang:t('commands.disabledispatch')}, function(source, _) - local job = QBCore.Functions.GetPlayer(source).PlayerData.job + local job = exports.qbx_core:GetPlayer(source).PlayerData.job if not Config.DispatchJobs.Types[job.type] or not Config.DispatchJobs.Jobs[job.name] then return end TriggerClientEvent('qbx-dispatch:client:DisableDispatch', source) @@ -80,4 +80,4 @@ lib.callback.register('qbx-dispatch:server:GetLastCall', function(source) return {blipid = calls[i].id} end end -end) +end) \ No newline at end of file