forked from cuberite/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear.lua
More file actions
32 lines (26 loc) · 1.06 KB
/
clear.lua
File metadata and controls
32 lines (26 loc) · 1.06 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
function HandleClearCommand(Split, Player)
if (Split[2] == nil) then
Player:GetInventory():Clear()
LOGINFO(Player:GetName() .. " cleared their inventory.")
SendMessageSuccess(Player, cChatColor.LightGray .. "Cleared your own inventory.")
return true
end
if Player:HasPermission("core.admin.clear") then
local InventoryCleared = false
local ClearInventory = function(OtherPlayer)
if (OtherPlayer:GetName() == Split[2]) then
OtherPlayer:GetInventory():Clear()
InventoryCleared = true
end
end
cRoot:Get():FindAndDoWithPlayer(Split[2], ClearInventory)
if (InventoryCleared) then
LOGINFO(Player:GetName() .. " cleared the inventory of " .. Split[2] .. ".")
SendMessageSuccess(Player, cChatColor.LightGray .. "Cleared the inventory of " .. Split[2] .. ".")
else
SendMessageFailure(Player, cChatColor.LightGray .. "Couldn't find that player.")
end
return true
end
return false
end