-
Notifications
You must be signed in to change notification settings - Fork 41
/
cmd_rank.lua
59 lines (50 loc) · 1.83 KB
/
cmd_rank.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
function HandleRankCommand(Split, Player)
local Response
local PlayerName = Split[2]
local NewRank = Split[3]
local InformLoadRank = function(OtherPlayer)
if PlayerName == OtherPlayer:GetName() then
local Actor = "the server console"
if Player then
Actor = "player \"" .. Player:GetName() .. "\""
end
OtherPlayer:SendMessageInfo("You were assigned the rank " .. NewRank .. " by " .. Actor)
OtherPlayer:LoadRank()
end
end
if not PlayerName then
Response = SendMessage(Player, "Usage: " .. Split[1] .. " <player> [rank]")
else
-- Translate the PlayerName to a UUID:
local PlayerUUID = GetPlayerUUID(PlayerName)
if not PlayerUUID or string.len(PlayerUUID) ~= 32 then
Response = SendMessage(Player, "There is no player with the name \"" .. PlayerName .. "\"")
else
-- View the player's rank, if requested:
if not NewRank then
-- "/rank <PlayerName>" usage, display the rank:
local CurrentRank = cRankManager:GetPlayerRankName(PlayerUUID)
if CurrentRank == "" then
Response = SendMessage(Player, "Player \"" .. PlayerName .. "\" has no rank assigned to them.")
else
Response = SendMessage(Player, "The rank of player \"" .. PlayerName .. "\" is " .. CurrentRank)
end
else
-- Change the player's rank:
if not cRankManager:RankExists(NewRank) then
Response = SendMessage(Player, "The specified rank does not exist!")
else
cRankManager:SetPlayerRank(PlayerUUID, PlayerName, NewRank)
-- Let the player know:
SafeDoWithPlayer(PlayerName, InformLoadRank)
local CurrentRank = cRankManager:GetPlayerRankName(PlayerUUID)
Response = SendMessageSuccess(Player, "Player \"" .. PlayerName .. "\" is now in rank " .. CurrentRank)
end
end
end
end
return true, Response
end
function HandleConsoleRank(Split)
return HandleRankCommand(Split)
end