-
Notifications
You must be signed in to change notification settings - Fork 0
/
concommand.lua
61 lines (48 loc) · 1.4 KB
/
concommand.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
// Do not touch
local REWARD = BATTLEPASS:CreateReward()
// Displayed icon in tier
REWARD.Mat = "battlepass/command.png"
// Verification function
function REWARD:CanUnlock(ply, reward)
// Unlock the item
// You may actually put a CustomCheck here if you want
return true
end
// Tooltip function
function REWARD:GetTooltip(reward)
local wep = concommand.Get(reward)
// Return commands description
return concommand.Description or "Runs a command !"
end
// Icon function
function REWARD:GetModel(reward)
// Return above defined icon
return self.Mat
end
// Name function
function REWARD:GetName(reward)
// Display the amount of points fetched from REWARD:GetTooltip()
return self:GetTooltip(reward)
end
// On unlock, do ...
function REWARD:Unlock(ply, reward, amount)
// SERVER only
if (CLIENT) then return end
// Variables
local wep = concommand.Get(reward)
// Verification
if (!wep) then return end
// Placeholders
local sid = ply:SteamID()
local sid64 = ply:SteamID64()
// Replace all occurences
// We start with sid64 cuz sid would both works with sid64 & sid occurences
string.Replace(wep, "sid64", sid64)
string.Replace(wep, "sid", sid)
// Store the function RCC in a var
local eCommand = RunConsoleCommand(wep)
// Execute the command in servers console on claim
return eCommand
end
// Reward registration
REWARD:Register("concommand")