This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathdemo.lua
184 lines (164 loc) · 4.53 KB
/
demo.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
------------------------------------------------------------
-- COMMANDS --
------------------------------------------------------------
TriggerEvent('chat:addSuggestion', '/ESXP_AddFakePlayer', 'Adds a fake player to the leaderboard')
TriggerEvent('chat:addSuggestion', '/ESXP_SetInitial', 'Sets player initial XP', {
{ name="XP", help="The XP to set" },
})
TriggerEvent('chat:addSuggestion', '/ESXP_Add', 'Add XP', {
{ name="XP", help="The XP to add" },
})
TriggerEvent('chat:addSuggestion', '/ESXP_Remove', 'Remove XP', {
{ name="XP", help="The XP to remove" },
})
-- !!!!!! THESE ARE FOR TESTING PURPOSES AND WILL NOT SAVE THE CHANGES IN THE DB !!!!!! --
RegisterCommand('ESXP_SetInitial', function(source, args)
if IsInt(args[1]) then
CurrentXP = LimitXP(tonumber(args[1]))
SendNUIMessage({
xpm_set = true,
xp = CurrentXP
})
else
print("esx_xp: Invalid XP")
end
end)
RegisterCommand('ESXP_Add', function(source, args)
if IsInt(args[1]) then
CurrentXP = LimitXP(CurrentXP + tonumber(args[1]))
SendNUIMessage({
xpm_set = true,
xp = CurrentXP
})
else
print("esx_xp: Invalid XP")
end
end)
RegisterCommand('ESXP_Remove', function(source, args)
if IsInt(args[1]) then
CurrentXP = LimitXP(CurrentXP - tonumber(args[1]))
SendNUIMessage({
xpm_set = true,
xp = CurrentXP
})
else
print("esx_xp: Invalid XP")
end
end)
RegisterCommand('ESXP_AddFakePlayer', function(source, args)
local count = 1
if args[1] ~= nil and tonumber(args[1]) then
count = tonumber(args[1])
end
math.randomseed(GetGameTimer())
for i = 1, count do
AddFakePlayer()
end
TriggerServerEvent("esx_xp:getPlayerData")
SendNUIMessage({
xpm_show = true,
xbm_lb = Config.Leaderboard
})
ESX.ShowNotification("~b~ESX_XP: ~g~" .. count .. " ~w~players added")
end)
RegisterCommand('ESXP_RemoveFakePlayers', function(source, args)
for i=#Players,1,-1 do
if Players[i].fake ~= nil then
table.remove(Players, i)
end
end
ESX.ShowNotification("~b~ESX_XP: ~w~Fake players removed")
TriggerServerEvent("esx_xp:getPlayerData")
SendNUIMessage({
xpm_show = true,
xbm_lb = Config.Leaderboard
})
end)
RegisterCommand('ESXP_SortLeaderboard', function(source, args)
local order = args[1] or "rank"
ESXP_SortLeaderboard(order)
TriggerServerEvent("esx_xp:getPlayerData")
SendNUIMessage({
xpm_show = true,
xbm_lb = Config.Leaderboard
})
ESX.ShowNotification("~b~ESX_XP: ~w~Leaderboard ordered by ~g~" .. order)
end)
function AddFakePlayer()
function maxVal(t, fn)
local max = 0
for k, v in pairs(Players) do
local id = tonumber(v.id)
if id > max then
max = id
end
end
return max
end
local names = {
"xxvctdreemaxxto",
"estropevc",
"bruscavi5a",
"fretaretzgl",
"tenshii58",
"afamatt9",
"motriuo1",
"kittykatrox13cj",
"meastalfs",
"tisleiferxl",
"persephone33ql",
"herbianinvu",
"lapic4r",
"rubia1044rp",
"dzieciaryd9",
"Lactabikito12",
"trappunumu7",
"Dallioes",
"apanyava43",
"hcoloverrrrx33x",
"kastplankif",
"Foramitibp",
"Rail45",
"dargludajm",
"Condoloqo",
"hestvagn3g",
"Aidelmimaip",
"Stehanjkgr",
"daycapaniwebs05",
"polars87",
"nickbitemekt",
"hovedlegeb0",
"peoplesuck076l",
"Laisvisli",
"drargewabwz",
"Cocconiz0",
"BypeSkebykj",
"neerdaalcc",
"kennirh7",
"kuhwelela50",
"Honshubv",
"Mungarilz",
"aphangejy",
"Fiananese93",
"Mushungtq",
"lorci1",
"rongalitnm",
"engusardet9",
"bauginojj",
"sonsonatzk0"
}
local name = names[ math.random( #names ) ]
local rank = math.random(1, 100)
local id = maxVal() + 1
local ping = false
if Config.Leaderboard.ShowPing then
ping = math.random(0, 100)
end
table.insert(Players, {
name = name,
id = id,
ping = ping,
rank = rank,
fake = true
})
end