for _, i in ipairs(GetActivePlayers()) do
print('Active Players '..GetActivePlayers()) -- ERROR PRINT ON THIS LINE - concatenation issue
local playerName = GetPlayerName(i)
local label = playerName..' [ID '..i..']'
print('i = ' ..i)
end
Could someone explain why the above code always returns 128 when printed?
I’m trying to loop through all players but the print always returns 128.
With this logic, anything I do will only create for ID 128?
I’m creating an admin menu from scratch, using nativeui, most of which is client sided.
for _, i in ipairs(GetActivePlayers()) do
print('Active Players'..GetActivePlayers())
if NetworkIsPlayerActive(i) then
local playerName = GetPlayerName(i)
local id = GetPlayerServerId(i)
local label = playerName..' [ID '..id..']'
PlayerMenu[i] = MenuPool:AddSubMenu(playerManagementSubMenu, label, "Select Player Options")
print('i = ', i)
local playerActions = {"Kick", "Ban", "Warn", "Mute", "Unmute"}
for _, action in ipairs(playerActions) do
local actionItem = NativeUI.CreateItem(action, "Perform " .. action .. " action on " .. label)
PlayerMenu[i]:AddItem(actionItem)
actionItem.Activated = function(sender, item, index)
ExecutePlayerAction(action, i)
end
end
MenuPool:RefreshIndex() -- Refresh the menu pool index after adding items
end
end
The logic works, but the looping through all players is an issue, I can’t send it to the server side because NativeUI does not work on the server side; I can never get it to display.