I don’t know if I’m just missing something here or what.
AddEventHandler("chatMessage", function(player, playerName, message)
if message == "test" then
local players = GetPlayers()
print(#players)
CancelEvent()
end
end)
returns an empty table every time even though I’m clearly on the server typing test in the chat.
It’s suppose to return a table of all the players id’s right?
The code I gave you is all I got, the resource is called test, and it has only one server side lua file called test with that code in it. It seems when I join and type test, it will show one player in the table with an id of 1. If I disconnect and rejoin then type test again, now it will still show one player in the server but I will still have the id 1 instead of 2 as it shows on the scoreboard. This is literally the only resource I have loaded, everything else is the same as when I downloaded the server.
I don’t know how all the internals work. sorry. As far as I know, the IDs in the GetPlayers() array should work for server-side interactions with clients (e.g. TriggerClientEvent) and other server-side functions that require the players ID (e.g. GetPlayerName).