forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_clear.lua
30 lines (26 loc) · 883 Bytes
/
cmd_clear.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
function HandleClearCommand(Split, Player)
local Response
local ClearInventory = function(OtherPlayer)
OtherPlayer:GetInventory():Clear()
if Split[2] then
Response = SendMessageSuccess(Player, "You cleared the inventory of player \"" .. OtherPlayer:GetName() .. "\"")
else
Response = SendMessageSuccess(OtherPlayer, "You cleared your own inventory")
end
end
if not Split[2] then
if not Player then
Response = SendMessage(nil, "Usage: " .. Split[1] .. " <player>")
else
ClearInventory(Player)
end
elseif not Player or Player:HasPermission("core.admin.clear") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], ClearInventory) then
Response = SendMessageFailure(Player, "Player \"" .. Split[2] .. "\" not found")
end
end
return true, Response
end
function HandleConsoleClear(Split)
return HandleClearCommand(Split)
end