Stupid question...

how can I have a list, which is empty by default.
SocialSpyList = {}
I wanna add Player:GetUUID(), loop over the list while running DoWithPlayerByUUID()
I also want to remove items (just remove a specific UUID, eg on a disable command or on leave)

so where do I have to define the list, so I can use it in OnCommandExecute (loop over the list if not empty) and HandleSocialSpyCommand (and how to add/remove entries)
Thanks given by:
I'm not completely sure what you want. You want to loop over all players and extract their UUID?
Thanks given by:
see my updated pr on github. i want to add the UUID to a list, if they run the /socialspy on command. I want to remove the UUID from the list, if they run /socialspy off. i want to loop over the UUIDs if anyone runs a command and send the command to each player in the list (DoWithPlayerByUUID)
It doesnt have to be the UUID, but thats the only possibility i found to loop over a set of players
Thanks given by:
Use a global Lua table, and use it as a dictionary:
-- Initialize the array, this should be in a file outside of any functions
-- Maps UUID -> true for all players who are currently spying
g_SpyingPlayers = {}

-- Add a player:
g_SpyingPlayers[a_Player:GetUUID()] = true

-- Remove a player:
g_SpyingPlayers[a_Player:GetUUID()] = nil

-- Do something with all players:
for _, uuid in pairs(g_SpyingPlayers) do
    function (a_CBPlayer)
      a_CBPlayer:SendMessage("You are spying")
end  -- for uuid - g_SpyingPlayers[]
Thanks given by:
thats exactly what i did ->github
Thanks given by:

Users browsing this thread: 1 Guest(s)