forked from Stromic/sAdmin-Modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsh_pointshop2.lua
108 lines (94 loc) · 4.98 KB
/
sh_pointshop2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
sAdmin.registerPermission("pointshop2 manageitems", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 createitems", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 manageusers", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 managemodules", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 exportimport", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 manageservers", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 reset", "Pointshop 2", false, false)
sAdmin.registerPermission("pointshop2 usepac", "Pointshop 2", false, false)
sAdmin.addCommand({
name = "ps2_addpoints_steamid",
category = "Pointshop 2",
inputs = {{"text", "sid64/sid"}, {"numeric", "amount"}},
func = function(ply, args, silent)
local steamId = args[1]
local amount = tonumber(args[2]) or 0
local currencyType = "points"
Pointshop2Controller:getInstance( ):addPointsBySteamId( steamId, currencyType, amount )
:Fail( function( errid, err )
KLogf( 2, "[Pointshop 2] ERROR: Couldn't give %i %s to %s, %i - %s", amount, currencyType, steamId, errid, err )
end )
:Done( function( )
KLogf( 4, "[Pointshop 2] %s gave %i %s to %s", "CONSOLE", amount, currencyType, steamId )
end )
sAdmin.msg(silent and ply or nil, "ps2_addpoints_steamid_response", ply, amount, steamId)
end
})
sAdmin.addCommand({
name = "ps2_addpremiumpoints_steamid",
category = "Pointshop 2",
inputs = {{"text", "sid64/sid"}, {"numeric", "amount"}},
func = function(ply, args, silent)
local steamId = args[1]
local amount = tonumber(args[2]) or 0
local currencyType = "premiumPoints"
Pointshop2Controller:getInstance( ):addPointsBySteamId( steamId, currencyType, amount )
:Fail( function( errid, err )
KLogf( 2, "[Pointshop 2] ERROR: Couldn't give %i %s to %s, %i - %s", amount, currencyType, steamId, errid, err )
end )
:Done( function( )
KLogf( 4, "[Pointshop 2] %s gave %i %s to %s", "CONSOLE", amount, currencyType, steamId )
end )
sAdmin.msg(silent and ply or nil, "ps2_addpremiumpoints_steamid_response", ply, amount, steamId)
end
})
sAdmin.addCommand({
name = "ps2_addpoints",
category = "Pointshop 2",
inputs = {{"player", "player_name"}, {"numeric", "amount"}},
func = function(ply, args, silent)
local targets = sAdmin.getTargets("ps2_addpoints", ply, args[1], 1)
local amount = tonumber(args[2]) or 0
local currencyType = "points"
for k,v in ipairs(targets) do
local steamId = v:SteamID()
Pointshop2Controller:getInstance( ):addPointsBySteamId( steamId, currencyType, amount )
:Fail( function( errid, err )
KLogf( 2, "[Pointshop 2] ERROR: Couldn't give %i %s to %s, %i - %s", amount, currencyType, steamId, errid, err )
end )
:Done( function( )
KLogf( 4, "[Pointshop 2] %s gave %i %s to %s", "CONSOLE", amount, currencyType, steamId )
end )
end
sAdmin.msg(silent and ply or nil, "ps2_addpoints_response", ply, amount, targets)
end
})
sAdmin.addCommand({
name = "ps2_addpremiumpoints",
category = "Pointshop 2",
inputs = {{"player", "player_name"}, {"numeric", "amount"}},
func = function(ply, args, silent)
local targets = sAdmin.getTargets("ps2_addpremiumpoints", ply, args[1], 1)
local amount = tonumber(args[2]) or 0
local currencyType = "premiumPoints"
for k,v in ipairs(targets) do
local steamId = v:SteamID()
Pointshop2Controller:getInstance( ):addPointsBySteamId( steamId, currencyType, amount )
:Fail( function( errid, err )
KLogf( 2, "[Pointshop 2] ERROR: Couldn't give %i %s to %s, %i - %s", amount, currencyType, steamId, errid, err )
end )
:Done( function( )
KLogf( 4, "[Pointshop 2] %s gave %i %s to %s", "CONSOLE", amount, currencyType, steamId )
end )
end
sAdmin.msg(silent and ply or nil, "ps2_addpremiumpoints_response", ply, amount, targets)
end
})
slib.setLang("sadmin", "en", "ps2_addpoints_steamid_response", "%s added %s points to %s.")
slib.setLang("sadmin", "en", "ps2_addpremiumpoints_steamid_response", "%s added %s premium points to %s.")
slib.setLang("sadmin", "en", "ps2_addpoints_response", "%s added %s points to %s.")
slib.setLang("sadmin", "en", "ps2_addpremiumpoints_response", "%s added %s premium points to %s.")
slib.setLang("sadmin", "en", "ps2_addpoints_steamid_help", "Add points to specified SteamID.")
slib.setLang("sadmin", "en", "ps2_addpremiumpoints_steamid_help", "Add premium points to specified SteamID.")
slib.setLang("sadmin", "en", "ps2_addpoints_help", "Add points to specified player.")
slib.setLang("sadmin", "en", "ps2_addpremiumpoints_help", "Add premium points to specified player.")