diff --git a/unit_tests/cache_test.lua b/examples/cache.lua similarity index 100% rename from unit_tests/cache_test.lua rename to examples/cache.lua diff --git a/unit_tests/callbacks_test.lua b/examples/callbacks.lua similarity index 100% rename from unit_tests/callbacks_test.lua rename to examples/callbacks.lua diff --git a/unit_tests/input_test.lua b/examples/input.lua similarity index 100% rename from unit_tests/input_test.lua rename to examples/input.lua diff --git a/unit_tests/locale_test.lua b/examples/locale.lua similarity index 100% rename from unit_tests/locale_test.lua rename to examples/locale.lua diff --git a/unit_tests/particle_test.lua b/examples/particle.lua similarity index 100% rename from unit_tests/particle_test.lua rename to examples/particle.lua diff --git a/unit_tests/placeable_object.lua b/examples/placeableObject.lua similarity index 100% rename from unit_tests/placeable_object.lua rename to examples/placeableObject.lua diff --git a/lib/cache/client/cache.lua b/lib/cache/client/cache.lua index 4b4b430..44a0235 100644 --- a/lib/cache/client/cache.lua +++ b/lib/cache/client/cache.lua @@ -3,33 +3,22 @@ local PlayerPedId = PlayerPedId local GetVehiclePedIsIn = GetVehiclePedIsIn local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers local GetPedInVehicleSeat = GetPedInVehicleSeat -local GetPlayerServerId = GetPlayerServerId local GetSelectedPedWeapon = GetSelectedPedWeapon -local PlayerId = PlayerId - - --- Comparison functions for client-side state - ---- Get the player's ped ID ----@return integer -function GetPed() - return PlayerPedId() -end --- Get the vehicle the player is in, if any ---@return integer | nil function GetVehicle() - local ped = Cache.Get("Ped") -- Use cached ped for efficiency - if not ped then return end -- Or handle error/default case + local ped = PlayerPedId() + if not ped then return end return GetVehiclePedIsIn(ped, false) end --- Get the seat of the player in the vehicle if the vehicle is occupied ---@return integer | nil function GetVehicleSeat() - local vehicle = Cache.Get("Vehicle") + local vehicle = GetVehicle() if not vehicle then return end - local ped = Cache.Get("Ped") + local ped = PlayerPedId() if not ped then return end for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do if ped == GetPedInVehicleSeat(vehicle, i) then @@ -38,26 +27,17 @@ function GetVehicleSeat() end end ----Get The Server ID of the player ----@return integer | nil -function GetServerId() - local ped = PlayerId() - if not ped then return end -- Return unarmed hash if no ped - return GetPlayerServerId(ped) -end - --- Get the current weapon of the player --- @return integer | nil function GetWeapon() - local ped = Cache.Get("Ped") + local ped = PlayerPedId() if not ped then return end -- Return unarmed hash if no ped return GetSelectedPedWeapon(ped) end -Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed) +Cache.Create("Ped", PlayerPedId, 1000) -- Check ped every second (adjust as needed) Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms Cache.Create("Weapon", GetWeapon , 250) -- Check weapon every 250ms -Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second return Cache diff --git a/lib/utility/client/utility.lua b/lib/utility/client/utility.lua index 8379c8f..050a058 100644 --- a/lib/utility/client/utility.lua +++ b/lib/utility/client/utility.lua @@ -3,6 +3,7 @@ local blipIDs = {} local spawnedPeds = {} Locales = Locales or Require('modules/locales/shared.lua') +Point = Point or Require('lib/points/client/pointsv2.lua') ---Get the hash of a model (string or number) ---@param model string|number @@ -410,8 +411,8 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh) end -- Deprecated point functions (no changes) -function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit, _nearby) - return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit, _nearby) +function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit) + return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit) end function Utility.GetPointById(pointID)