From 8b502d461d175acda1e8a76108174b2b25d5d8eb Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:04:16 +1100 Subject: [PATCH] fix(server): check stash distance in getClosestStashCoordss --- server.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/server.lua b/server.lua index 687ea845d..555cf3a78 100644 --- a/server.lua +++ b/server.lua @@ -68,13 +68,14 @@ exports('setPlayerInventory', server.setPlayerInventory) AddEventHandler('ox_inventory:setPlayerInventory', server.setPlayerInventory) ---@param playerPed number ----@param coordinates vector3|vector3[] ----@param distance? number ----@return vector3|false -local function getClosestStashCoords(playerPed, coordinates, distance) +---@param stash OxInventory +---@return vector3? +local function getClosestStashCoords(playerPed, stash) local playerCoords = GetEntityCoords(playerPed) + local distance = stash.distance or 10 + local coordinates = stash.coords - if not distance then distance = 10 end + if not coordinates then return end if type(coordinates) == 'table' then for i = 1, #coordinates do @@ -85,10 +86,10 @@ local function getClosestStashCoords(playerPed, coordinates, distance) end end - return false + return end - return #(coordinates - playerCoords) < distance and coordinates + return #(coordinates - playerCoords) < distance and coordinates or nil end ---@param source number @@ -217,7 +218,7 @@ local function openInventory(source, invType, data, ignoreSecurityChecks) end if not ignoreSecurityChecks and right.coords then - closestCoords = getClosestStashCoords(playerPed, right.coords) + closestCoords = getClosestStashCoords(playerPed, right) if not closestCoords then return end end