From 5fe78d33a3749a16d9a60cb00aefc08581bf2ce4 Mon Sep 17 00:00:00 2001 From: Linden Date: Mon, 12 Jul 2021 17:53:04 +1000 Subject: [PATCH] fix(esx/client): Fix ESX.Game.GetPeds; allow string or hash for ESX.Game.SpawnObject --- [esx]/es_extended/client/functions.lua | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/[esx]/es_extended/client/functions.lua b/[esx]/es_extended/client/functions.lua index 2b0bd7b3..acf7a802 100644 --- a/[esx]/es_extended/client/functions.lua +++ b/[esx]/es_extended/client/functions.lua @@ -339,16 +339,13 @@ ESX.Game.Teleport = function(entity, coords, cb) end ESX.Game.SpawnObject = function(object, coords, cb, networked) - local model = (type(object) == 'number' and model or GetHashKey(object)) + local model = type(object) == 'number' and object or GetHashKey(object) local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) networked = networked == nil and true or networked Citizen.CreateThread(function() ESX.Streaming.RequestModel(model) - -- The below has to be done just for CreateObject since for some reason CreateObjects model argument is set - -- as an Object instead of a hash so it doesn't automatically hash the item - model = type(model) == 'number' and model or GetHashKey(model) local obj = CreateObject(model, vector.xyz, networked, false, true) if cb then cb(obj) @@ -357,7 +354,6 @@ ESX.Game.SpawnObject = function(object, coords, cb, networked) end ESX.Game.SpawnLocalObject = function(object, coords, cb) - -- Why have 2 separate functions for this? Just call the other one with an extra param ESX.Game.SpawnObject(object, coords, cb, false) end @@ -417,13 +413,13 @@ ESX.Game.GetObjects = function() -- Leave the function for compatibility end ESX.Game.GetPeds = function(onlyOtherPeds) - local peds, myPed = {}, ESX.PlayerData.ped + local peds, myPed, pool = {}, ESX.PlayerData.ped, GetGamePool('CPed') - for ped in GetGamePool('CPed') do - if ((onlyOtherPeds and ped ~= myPed) or not onlyOtherPeds) then - table.insert(peds, ped) - end - end + for i=1, #pool do + if ((onlyOtherPeds and pool[i] ~= myPed) or not onlyOtherPeds) then + table.insert(peds, pool[i]) + end + end return peds end