List
#1
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)
Reply
Thanks given by:
#2
I'm not completely sure what you want. You want to loop over all players and extract their UUID?
Reply
Thanks given by:
#3
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
Reply
Thanks given by:
#4
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
  cRoot:Get():DoWithPlayerByUUID(uuid,
    function (a_CBPlayer)
      a_CBPlayer:SendMessage("You are spying")
    end
  )
end  -- for uuid - g_SpyingPlayers[]
Reply
Thanks given by:
#5
thats exactly what i did ->github
Reply
Thanks given by:




Users browsing this thread: 5 Guest(s)