From 29fdf896f94b9cd3ff632fcf24239393c501a894 Mon Sep 17 00:00:00 2001 From: Ilias Rbayti <63159154+Kenshiin13@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:58:52 +0200 Subject: [PATCH] Only returns a table if val param is also of type table. More intuitive. If I want the job count of a single job "police", I don't expect a table as a return value, but the count directly. --- [core]/es_extended/server/functions.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index e2e9cf1a..d1bc1419 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -264,7 +264,8 @@ function ESX.GetNumPlayers(key, val) return ESX.Table.SizeOf(ESX.Players) end - local valTable = (type(val) == "table" and val or {val}) + local isValATable = (type(val) == "table") + local valTable = (isValATable and val or {val}) local numPlayers = {} for i, val in ipairs(valTable) do numPlayers[val] = 0 @@ -277,7 +278,7 @@ function ESX.GetNumPlayers(key, val) end end - return numPlayers + return (isValATable and numPlayers or numPlayers[val]) end function ESX.GetPlayerFromId(source)