feat: get players by data values

This commit is contained in:
Andyyy7666
2022-11-30 04:04:48 +01:00
parent 1cfe60db42
commit 211c2531cc

View File

@@ -6,8 +6,32 @@ function NDCore.Functions.GetPlayer(player)
end
-- Get all active players character data.
function NDCore.Functions.GetPlayers(players, cb)
return NDCore.Players
function NDCore.Functions.GetPlayers(getBy, value)
if not getBy or not value then
return NDCore.Players
end
local players = {}
if getBy == "groups" then
for player, playerInfo in pairs(NDCore.Players) do
if playerInfo.data.groups then
local valueGroup = value:lower()
for group, _ in pairs(playerInfo.data.groups) do
if group.lower() == valueGroup then
players[player] = playerInfo
end
end
end
end
else
for player, playerInfo in pairs(NDCore.Players) do
if playerInfo[getBy] == value then
players[player] = playerInfo
end
end
end
return players
end
local discordErrors = {