diff --git a/lib/placers/client/object_Placer.lua b/lib/placers/client/object_Placer.lua index 70891be..1bf3984 100644 --- a/lib/placers/client/object_Placer.lua +++ b/lib/placers/client/object_Placer.lua @@ -36,6 +36,7 @@ Placeable.PlaceObject = function(object, distance, snapToGround, allowedMats, of local propObject = type(object) == 'string' and joaat(object) or object local heading = 0.0 local checkDist = distance or 10.0 + local ped = PlayerPedId() Utility.LoadModel(propObject) @@ -60,7 +61,7 @@ Placeable.PlaceObject = function(object, distance, snapToGround, allowedMats, of end SetEntityCoords(activePlacementProp, coords.x, coords.y, coords.z, false, false, false, false) - local distCheck = #(GetEntityCoords(cache.ped) - coords) + local distCheck = #(GetEntityCoords(ped) - coords) SetEntityHeading(activePlacementProp, heading) if snapToGround then diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index 5b41346..9808f49 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -312,10 +312,11 @@ end ---Reload the player's skin and remove attached objects ---@return boolean function Utility.ReloadSkin() - local skinData = Utility.GetEntitySkinData(cache.ped) - Utility.SetEntitySkinData(cache.ped, skinData) + local ped = PlayerPedId() + local skinData = Utility.GetEntitySkinData(ped) + Utility.SetEntitySkinData(ped, skinData) for _, props in pairs(GetGamePool("CObject")) do - if IsEntityAttachedToEntity(cache.ped, props) then + if IsEntityAttachedToEntity(ped, props) then SetEntityAsMissionEntity(props, true, true) DeleteObject(props) DeleteEntity(props) @@ -366,6 +367,7 @@ end ---@param conditionFunction function|nil ---@param afterTeleportFunction function|nil function Utility.TeleportPlayer(coords, conditionFunction, afterTeleportFunction) + local ped = PlayerPedId() if conditionFunction ~= nil then if not conditionFunction() then return @@ -373,18 +375,18 @@ function Utility.TeleportPlayer(coords, conditionFunction, afterTeleportFunction end DoScreenFadeOut(2500) Wait(2500) - SetEntityCoords(cache.ped, coords.x, coords.y, coords.z, false, false, false, false) + SetEntityCoords(ped, coords.x, coords.y, coords.z, false, false, false, false) if coords.w then - SetEntityHeading(cache.ped, coords.w) + SetEntityHeading(ped, coords.w) end - FreezeEntityPosition(cache.ped, true) + FreezeEntityPosition(ped, true) local count = 0 - while not HasCollisionLoadedAroundEntity(cache.ped) and count <= 30000 do + while not HasCollisionLoadedAroundEntity(ped) and count <= 30000 do RequestCollisionAtCoord(coords.x, coords.y, coords.z) Wait(0) count = count + 1 end - FreezeEntityPosition(cache.ped, false) + FreezeEntityPosition(ped, false) DoScreenFadeIn(1000) if afterTeleportFunction ~= nil then afterTeleportFunction() @@ -406,8 +408,8 @@ end function Utility.GetClosestPlayer(coords, distanceScope, includeMe) local players = GetActivePlayers() local closestPlayer = 0 - local selfPed = cache.ped - local selfCoords = coords or GetEntityCoords(cache.ped) + local selfPed = PlayerPedId() + local selfCoords = coords or GetEntityCoords(selfPed) local closestDistance = distanceScope or 5 for _, player in ipairs(players) do @@ -434,12 +436,13 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh) local vehicleEntity = nil local vehicleNetID = nil local vehicleCoords = nil - local selfCoords = coords or GetEntityCoords(cache.ped) + local ped = PlayerPedId() + local selfCoords = coords or GetEntityCoords(ped) local closestDistance = distanceScope or 5 local includeMyVeh = includePlayerVeh or false local gamePoolVehicles = GetGamePool("CVehicle") - local playerVehicle = IsPedInAnyVehicle(cache.ped, false) and GetVehiclePedIsIn(cache.ped, false) or 0 + local playerVehicle = IsPedInAnyVehicle(ped, false) and GetVehiclePedIsIn(ped, false) or 0 for i = 1, #gamePoolVehicles do local thisVehicle = gamePoolVehicles[i] diff --git a/modules/dispatch/_default/client/client.lua b/modules/dispatch/_default/client/client.lua index ab2434e..15bccc0 100644 --- a/modules/dispatch/_default/client/client.lua +++ b/modules/dispatch/_default/client/client.lua @@ -5,15 +5,16 @@ Dispatch = Dispatch or {} ---@param data table The data to send to the dispatch system. ---@return nil Dispatch.SendAlert = function(data) + local ped = PlayerPedId() TriggerServerEvent('community_bridge:Server:DispatchAlert', { sprite = data.blipData.sprite or 161, color = data.blipData.color or 1, scale = data.blipData.scale or 0.8, vehicle = data.vehicle or nil, plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil, - ped = data.ped or cache.ped, - pedCoords = data.pedCoords or GetEntityCoords(cache.ped), - coords = data.coords or GetEntityCoords(cache.ped), + ped = data.ped or ped, + pedCoords = data.pedCoords or GetEntityCoords(ped), + coords = data.coords or GetEntityCoords(ped), message = data.message or "An Alert Has Been Made", code = data.code or '10-80', icon = data.icon or 'fas fa-question', diff --git a/modules/dispatch/bub-mdt/client/client.lua b/modules/dispatch/bub-mdt/client/client.lua index a17f3f5..8bdedda 100644 --- a/modules/dispatch/bub-mdt/client/client.lua +++ b/modules/dispatch/bub-mdt/client/client.lua @@ -3,14 +3,15 @@ if GetResourceState('bub-mdt') == 'missing' then return end Dispatch = Dispatch or {} Dispatch.SendAlert = function(data) + local ped = PlayerPedId() local alertData = { code = data.code or '10-80', offense = data.message, - coords = data.coords or GetEntityCoords(cache.ped), + coords = data.coords or GetEntityCoords(ped), info = { label = data.code or '10-80', icon = data.icon or 'fas fa-question' }, blip = data.blipData.sprite or 1, isEmergency = data.priority == 1 and true or false, - blipCoords = data.coords or cache.ped and GetEntityCoords(cache.ped) or { x = 0, y = 0}, + blipCoords = data.coords or ped and GetEntityCoords(ped) or { x = 0, y = 0}, } exports["bub-mdt"]:CustomAlert(alertData) end diff --git a/modules/dispatch/linden_outlawalert/client/client.lua b/modules/dispatch/linden_outlawalert/client/client.lua index 4b63501..c783e98 100644 --- a/modules/dispatch/linden_outlawalert/client/client.lua +++ b/modules/dispatch/linden_outlawalert/client/client.lua @@ -3,6 +3,7 @@ if GetResourceState('linden_outlawalert') == 'missing' then return end Dispatch = Dispatch or {} Dispatch.SendAlert = function(data) + local ped = PlayerPedId() TriggerServerEvent('wf-alerts:svNotify', { dispatchData = { displayCode = data.code or '211', @@ -14,7 +15,7 @@ Dispatch.SendAlert = function(data) info = data.message or "Alert" }, caller = 'Anonymous', - coords = data.coords or GetEntityCoords(cache.ped) + coords = data.coords or GetEntityCoords(ped) }) end diff --git a/modules/doorlock/qb-doorlock/client.lua b/modules/doorlock/qb-doorlock/client.lua index c21442b..a7356db 100644 --- a/modules/doorlock/qb-doorlock/client.lua +++ b/modules/doorlock/qb-doorlock/client.lua @@ -6,10 +6,11 @@ Doorlock = Doorlock or {} ---This will get the closest door to the ped ---@return string | nil Doorlock.GetClosestDoor = function() + local ped = PlayerPedId() local closestDoor = exports["qb-doorlock"]:GetClosestDoor() if Table.CheckPopulated(closestDoor) then return closestDoor end local allDoors = exports["qb-doorlock"]:GetDoorList() - local pedCoords = GetEntityCoords(cache.ped) + local pedCoords = GetEntityCoords(ped) local door = 0 local doorDist = 1000.0 for doorID, data in pairs(allDoors) do diff --git a/modules/doorlock/rcore_doorlock/client.lua b/modules/doorlock/rcore_doorlock/client.lua index 06e5a7d..5c9cd6c 100644 --- a/modules/doorlock/rcore_doorlock/client.lua +++ b/modules/doorlock/rcore_doorlock/client.lua @@ -6,8 +6,9 @@ Doorlock = Doorlock or {} ---This will get the closest door to the ped ---@return string | nil Doorlock.GetClosestDoor = function() + local ped = PlayerPedId() local allDoors = exports.rcore_doorlock:getLoadedDoors() - local pedCoords = GetEntityCoords(cache.ped) + local pedCoords = GetEntityCoords(ped) local door = 0 local doorDist = 1000.0 for _, data in pairs(allDoors) do