-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayers.lua
More file actions
32 lines (26 loc) · 889 Bytes
/
players.lua
File metadata and controls
32 lines (26 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- players.lua
-- Implements the /players command.
function HandleConsolePlayers(Split, Player)
local PlayerTable = {}
-- Collect and tabulate online players.
local ForEachPlayer = function(a_Player)
table.insert(PlayerTable, a_Player:GetName())
end
cRoot:Get():ForEachPlayer(ForEachPlayer)
table.sort(PlayerTable)
-- Format this table.
LOG("Players (" .. #PlayerTable .. "): " .. table.concat(PlayerTable, ", "))
return true
end
function HandlePlayersCommand(Split, Player)
local PlayerTable = {}
-- Collect and tabulate online players.
local ForEachPlayer = function(a_Player)
table.insert(PlayerTable, a_Player:GetName())
end
cRoot:Get():ForEachPlayer(ForEachPlayer)
table.sort(PlayerTable)
-- Format this table in a message.
Player:SendMessage(cChatColor.LightGray .. "Players (" .. #PlayerTable .. "): " .. table.concat(PlayerTable, ", "))
return true
end