-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspy.lua
More file actions
38 lines (35 loc) · 1.49 KB
/
spy.lua
File metadata and controls
38 lines (35 loc) · 1.49 KB
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
33
34
35
36
37
38
-- spy.lua
-- Implements the /spy command and creates a list of staffmembers with the feature enabled.
CommandSpyList = {}
function HandleSpyCommand(Split, Player)
if Split[2] == "commands" then
-- Add that player's identifier to the list.
CommandSpyList[Player:GetUUID()] = true
Player:SendMessageSuccess("Enabled spying on players' commands.")
elseif Split[2] == "stop" then
-- If they disable the feature, remove their identifier from the list.
CommandSpyList[Player:GetUUID()] = nil
Player:SendMessageFailure("Disabled spying on players' commands.")
else
Player:SendMessage(cChatColor.LightGray .. "Usage: " .. Split[1] .. " <commands | stop>")
end
return true
end
function OnExecuteCommand(Player, CommandSplit, EntireCommand)
local DisplayCommand = function(OtherPlayer)
if CommandSpyList[OtherPlayer:GetUUID()] ~= nil then
if Player then
if CommandSpyList[Player:GetUUID()] ~= nil then
-- OtherPlayer:SendMessage(cChatColor.Yellow .. Player:GetName() .. cChatColor.Yellow .. ": " .. EntireCommand)
return true
else
OtherPlayer:SendMessage(cChatColor.LightGray .. Player:GetName() .. ": " .. EntireCommand)
end
-- If the command was executed by the console or by a command block, then send a different message.
else
OtherPlayer:SendMessage(cChatColor.LightGray .. cChatColor.Italic .. "Console/cmdblock: " .. cChatColor.Plain .. cChatColor.LightGray .. EntireCommand)
end
end
end
cRoot:Get():ForEachPlayer(DisplayCommand)
end