-
Notifications
You must be signed in to change notification settings - Fork 41
/
cmd_tell.lua
66 lines (54 loc) · 1.93 KB
/
cmd_tell.lua
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local LastSender = {}
function HandleTellCommand(Split, Player)
local Response
local SenderName = "Server"
local SenderUUID = "CuberiteServerConsoleSender"
if Player then
SenderName = Player:GetName()
SenderUUID = Player:GetUUID()
end
local SendPrivateMessage = function(OtherPlayer)
local Message = table.concat(Split, " ", 2)
local ReceiverName = "Server"
local ReceiverUUID = "CuberiteServerConsoleSender"
if OtherPlayer then
ReceiverName = OtherPlayer:GetName()
ReceiverUUID = OtherPlayer:GetUUID()
OtherPlayer:SendMessagePrivateMsg(Message, SenderName)
else
LOG("[MSG:" .. SenderName .. "] " .. Message)
end
LastSender[ReceiverUUID] = SenderUUID
Response = SendMessageSuccess(Player, "Message to \"" .. ReceiverName .. "\" sent!")
end
if Split[1] == "r" or Split[1] == "/r" then
if not Split[2] then
Response = SendMessage(Player, "Usage: " .. Split[1] .. " <message ...>")
elseif not LastSender[SenderUUID] then
Response = SendMessageFailure(Player, "No last sender found")
elseif "CuberiteServerConsoleSender" == LastSender[SenderUUID] then
SendPrivateMessage()
else
local ReceiverName = cMojangAPI:GetPlayerNameFromUUID(LastSender[SenderUUID], true)
if not cRoot:Get():FindAndDoWithPlayer(ReceiverName, SendPrivateMessage) then
Response = SendMessageFailure(Player, "Player \"" .. ReceiverName .. "\" not found")
end
end
else
if not Split[3] then
Response = SendMessage(Player, "Usage: " .. Split[1] .. " <player> <message ...>")
elseif Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], SendPrivateMessage) then
Response = SendMessageFailure(Player, "Player \"" .. Split[2] .. "\" not found")
end
end
return true, Response
end
function HandleConsoleTell(Split)
return HandleTellCommand(Split)
end
function HandleRCommand(Split, Player)
return HandleTellCommand(Split, Player)
end
function HandleConsoleR(Split)
return HandleRCommand(Split)
end