forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtell.lua
55 lines (44 loc) · 1.71 KB
/
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
function HandleTellCommand(Split, Player)
if (Split[2] == nil) or (Split[3] == nil) then
SendMessage( Player, "Usage: "..Split[1].." <player> <message ...>")
return true
end
local FoundPlayer = false
local SendMessage = function(OtherPlayer)
if (OtherPlayer:GetName() == Split[2]) then
local newSplit = table.concat( Split, " ", 3 )
SendMessageSuccess( Player, "Message to player " .. Split[2] .. " sent!" )
OtherPlayer:SendMessagePrivateMsg(newSplit, Player:GetName())
lastsender[OtherPlayer:GetName()] = Player:GetName()
FoundPlayer = true
end
end
cRoot:Get():ForEachPlayer(SendMessage)
if not FoundPlayer then
SendMessageFailure( Player, 'Player "' ..Split[2].. '" not found')
end
return true;
end
function HandleRCommand(Split,Player)
if Split[2] == nil then
Player:SendMessageInfo("Usage: "..Split[1].." <message ...>")
else
local SendMessage = function(OtherPlayer)
if (OtherPlayer:GetName() == lastsender[Player:GetName()]) then
local newSplit = table.concat( Split, " ", 2 )
Player:SendMessageSuccess( "Message to player " .. lastsender[Player:GetName()] .. " sent!" )
OtherPlayer:SendMessagePrivateMsg(newSplit, Player:GetName())
lastsender[OtherPlayer:GetName()] = Player:GetName()
return true
end
end
if lastsender[Player:GetName()] == nil then
Player:SendMessageFailure("No last sender found")
else
if (not(cRoot:Get():FindAndDoWithPlayer(lastsender[Player:GetName()], SendMessage))) then
Player:SendMessageFailure("Player not found")
end
end
end
return true
end