GetPlayers added

while theres a native to do this, the purpose of this is using the framework methods, this will only return logged in players ie wont include people who are in multichar and still not logged in
This commit is contained in:
MrNewb committed 2025-04-14 01:16:06 -04:00
1 parent 663e3bc9c1
commit 870f440a1b
3 files changed
+33

No files matched your search

+11
View File
@@ -35,6 +35,17 @@ Framework.GetPlayerName = function(src)
return xPlayer.variables.firstName, xPlayer.variables.lastName return xPlayer.variables.firstName, xPlayer.variables.lastName
end end
---This will return a table of all logged in players
---@return table
Framework.GetPlayers = function()
local players = ESX.GetExtendedPlayers()
local playerList = {}
for _, xPlayer in pairs(players) do
table.insert(playerList, xPlayer.source)
end
return playerList
end
-- Framework.GetItem(src, item, metadata) -- Framework.GetItem(src, item, metadata)
-- Returns a table of items matching the specified name and if passed metadata from the player's inventory. -- Returns a table of items matching the specified name and if passed metadata from the player's inventory.
-- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot} -- returns {name = v.name, count = v.amount, metadata = v.info, slot = v.slot}
+11
View File
@@ -133,6 +133,17 @@ Framework.GetPlayerInventory = function(src)
return repackedTable return repackedTable
end end
---This will return a table of all logged in players
---@return table
Framework.GetPlayers = function()
local players = QBCore.Functions.GetPlayers()
local playerList = {}
for _, src in pairs(players) do
table.insert(playerList, src)
end
return playerList
end
Framework.GetItemBySlot = function(src, slot) Framework.GetItemBySlot = function(src, slot)
local player = QBCore.Functions.GetPlayer(src) local player = QBCore.Functions.GetPlayer(src)
if not player then return end if not player then return end
+11
View File
@@ -29,6 +29,17 @@ Framework.GetPlayerIdentifier = function(src)
return playerData.citizenid return playerData.citizenid
end end
---This will return a table of all logged in players
---@return table
Framework.GetPlayers = function()
local players = QBox:GetQBPlayers()
local playerList = {}
for src, _ in pairs(players) do
table.insert(playerList, src)
end
return playerList
end
-- Framework.GetPlayerName(src) -- Framework.GetPlayerName(src)
-- Returns the first and last name of the player. -- Returns the first and last name of the player.
Framework.GetPlayerName = function(src) Framework.GetPlayerName = function(src)