mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-16 21:46:03 +01:00
feat: get players by data values
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user