mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-18 22:36:03 +01:00
feat: get players by data values
This commit is contained in:
@@ -6,8 +6,32 @@ function NDCore.Functions.GetPlayer(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get all active players character data.
|
-- Get all active players character data.
|
||||||
function NDCore.Functions.GetPlayers(players, cb)
|
function NDCore.Functions.GetPlayers(getBy, value)
|
||||||
return NDCore.Players
|
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
|
end
|
||||||
|
|
||||||
local discordErrors = {
|
local discordErrors = {
|
||||||
|
|||||||
Reference in New Issue
Block a user