-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.lua
246 lines (205 loc) · 7.73 KB
/
server.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
local admins = {
'steam:'
}
RegisterServerEvent("sp_admin:giveCash")
AddEventHandler("sp_admin:giveCash", function(money)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local total = money
xPlayer.addMoney((total))
end)
ESX.RegisterServerCallback('sp_admin:getUsergroup', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local group = xPlayer.getGroup()
print(GetPlayerName(source).." - "..group)
cb(group)
end)
RegisterServerEvent("sp_admin:giveBank")
AddEventHandler("sp_admin:giveBank", function(money)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local total = money
xPlayer.addAccountMoney('bank', total)
end)
RegisterServerEvent("sp_admin:giveDirtyMoney")
AddEventHandler("sp_admin:giveDirtyMoney", function(money)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local total = money
xPlayer.addAccountMoney('black_money', total)
end)
RegisterCommand(Config.Command, function(source,args)
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer then
local isAllowed = false
for _,group in pairs(Config.AllowedGroups) do
if group == xPlayer.getGroup() then
isAllowed = true
break
end
end
if isAllowed then
TriggerClientEvent('relisoft_players:drawText',source)
else
TriggerEvent('chat:addMessage', source, { args = { '', '' }, color = { 255, 50, 50 } })
end
end
end)
function isAdmin(player)
local allowed = false
for i,id in ipairs(admins) do
for x,pid in ipairs(GetPlayerIdentifiers(player)) do
if string.lower(pid) == string.lower(id) then
allowed = true
end
end
end
return allowed
end
local function checkAdmin(source)
local xPlayer = ESX.GetPlayerFromId(source)
local result = {}
if xPlayer ~= nil then
result = MySQL.Sync.fetchAll('SELECT * FROM users WHERE identifier = @identifier', {['identifier'] = xPlayer.identifier})
end
if result[1].group ~= nil and result[1].group == "superadmin" then
return true
end
return false
end
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
RegisterServerEvent('checkadmin')
AddEventHandler('checkadmin', function()
local id = source
if isAdmin(id) then
TriggerClientEvent("setgroup", source)
end
end)
RegisterNetEvent('sp_admin:giveweapon')
AddEventHandler('sp_admin:giveweapon', function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon('WEAPON_KNIFE', 999)
xPlayer.addWeapon('WEAPON_KNUCKLE', 999)
xPlayer.addWeapon('WEAPON_CROWBAR', 999)
xPlayer.addWeapon('WEAPON_GOLFCLUB', 999)
xPlayer.addWeapon('WEAPON_BOTTLE', 999)
xPlayer.addWeapon('WEAPON_DAGGER', 999)
xPlayer.addWeapon('WEAPON_HATCHET', 999)
xPlayer.addWeapon('WEAPON_KNUCKLEDUSTER', 999)
xPlayer.addWeapon('WEAPON_FLASHLIGHT', 999)
xPlayer.addWeapon('WEAPON_SWITCHBLADE', 999)
xPlayer.addWeapon('WEAPON_POOLCUE', 999)
xPlayer.addWeapon('WEAPON_WRENCH', 999)
xPlayer.addWeapon('GADGET_PARACHUTE', 999)
xPlayer.addWeapon('WEAPON_BATTLEAXE', 999)
xPlayer.addWeapon('WEAPON_NIGHTSTICK', 999)
xPlayer.addWeapon('WEAPON_HAMMER', 999)
xPlayer.addWeapon('WEAPON_BAT', 999)
xPlayer.addWeapon('WEAPON_MACHETE', 999)
xPlayer.addWeapon('WEAPON_GRENADE', 999)
xPlayer.addWeapon('WEAPON_STICKYBOMB', 999)
xPlayer.addWeapon('WEAPON_PISTOL', 999)
xPlayer.addWeapon('WEAPON_PISTOLMK2', 999)
xPlayer.addWeapon('WEAPON_PISTOL50', 999)
xPlayer.addWeapon('WEAPON_COMBATPISTOL', 999)
xPlayer.addWeapon('WEAPON_SNSPISTOL', 999)
xPlayer.addWeapon('WEAPON_HEAVYPISTOL', 999)
xPlayer.addWeapon('WEAPON_VINTAGEPISTOL', 999)
xPlayer.addWeapon('WEAPON_MARKSMANPISTOL', 999)
xPlayer.addWeapon('WEAPON_REVOLVER', 999)
xPlayer.addWeapon('WEAPON_APPISTOL', 999)
xPlayer.addWeapon('WEAPON_STUNGUN', 999)
xPlayer.addWeapon('WEAPON_FLAREGUN', 999)
xPlayer.addWeapon('WEAPON_MICROSMG', 999)
xPlayer.addWeapon('WEAPON_MACHINEPISTOL', 999)
xPlayer.addWeapon('WEAPON_SMGMK2', 999)
xPlayer.addWeapon('WEAPON_ASSAULTSMG', 999)
xPlayer.addWeapon('WEAPON_COMBATPDW', 999)
xPlayer.addWeapon('WEAPON_MG', 999)
xPlayer.addWeapon('WEAPON_COMBATMG', 999)
xPlayer.addWeapon('WEAPON_COMBATMGMK2', 999)
xPlayer.addWeapon('WEAPON_KUSEMBERG', 999)
xPlayer.addWeapon('WEAPON_MINISMG', 999)
xPlayer.addWeapon('WEAPON_SMG', 999)
xPlayer.addWeapon('WEAPON_ASSAULTRIFLE', 999)
xPlayer.addWeapon('WEAPON_ASSAULTRIFLEMK2', 999)
xPlayer.addWeapon('WEAPON_CARBINERIFLE', 999)
xPlayer.addWeapon('WEAPON_CARBINERIFLEMK2', 999)
xPlayer.addWeapon('WEAPON_ADVANCEDRIFLE', 999)
xPlayer.addWeapon('WEAPON_GUSENBERG', 999)
xPlayer.addWeapon('WEAPON_RAYCARBINE', 999)
xPlayer.addWeapon('WEAPON_SPECIALCARBINE', 999)
xPlayer.addWeapon('WEAPON_BULLPUPRIFLE', 999)
xPlayer.addWeapon('WEAPON_COMPACTRIFLE', 999)
xPlayer.addWeapon('WEAPON_SNIPERRIFLE', 999)
xPlayer.addWeapon('WEAPON_HEAVYSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_HEAVYSNIPER', 999)
xPlayer.addWeapon('WEAPON_HEAVYSNIPERMK2', 999)
xPlayer.addWeapon('WEAPON_MARKSMANRIFLE', 999)
xPlayer.addWeapon('WEAPON_DBSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_SNIPERRIFLE', 999)
xPlayer.addWeapon('WEAPON_PUMPSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_SAWNOFFSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_BULLPUPSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_ASSAULTSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_MUSKET', 999)
xPlayer.addWeapon('WEAPON_DOUBLEBARRELSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_AUTOSHOTGUN', 999)
xPlayer.addWeapon('WEAPON_GRENADELAUNCHER', 999)
xPlayer.addWeapon('WEAPON_RPG', 999)
xPlayer.addWeapon('WEAPON_MINIGUN', 999)
xPlayer.addWeapon('WEAPON_FIREWORK', 999)
xPlayer.addWeapon('WEAPON_RAILGUN', 999)
xPlayer.addWeapon('WEAPON_HOMINGLAUNCHER', 999)
xPlayer.addWeapon('WEAPON_GRENADELAUNCHERSMOKE', 999)
xPlayer.addWeapon('WEAPON_COMPACTLAUNCHER', 999)
xPlayer.addWeapon('WEAPON_PROXIMITYMINE', 999)
xPlayer.addWeapon('WEAPON_BZGAS', 999)
xPlayer.addWeapon('WEAPON_MOLOTOV', 999)
xPlayer.addWeapon('WEAPON_FIREEXTINGUISHER', 999)
xPlayer.addWeapon('WEAPON_PETROLCAN', 999)
xPlayer.addWeapon('WEAPON_FLARE', 999)
xPlayer.addWeapon('WEAPON_BALL', 999)
xPlayer.addWeapon('WEAPON_SNOWBALL', 999)
xPlayer.addWeapon('WEAPON_SMOKEGRENADE', 999)
xPlayer.addWeapon('WEAPON_PIPEBOMB', 999)
xPlayer.addWeapon('WEAPON_PARACHUTE', 999)
end)
RegisterServerEvent('haciadmin:kickjoueur')
AddEventHandler('haciadmin:kickjoueur', function(player)
DropPlayer(player, "You were kicked! More information on our discord.")
end)
RegisterNetEvent('sp_admin:removeweapon')
AddEventHandler('sp_admin:removeweapon', function()
local _source = source
local xPlayer = ESX.GetPlayerFromId(source)
for i=1, #xPlayer.loadout, 1 do
xPlayer.removeWeapon(xPlayer.loadout[i].name)
end
end)
RegisterServerEvent('spadmin:supprimeappels')
AddEventHandler('spadmin:supprimeappels', function(supprimer)
MySQL.Async.execute('DELETE FROM appels_ems WHERE id = @id', {
['@id'] = supprimer
})
end)
RegisterServerEvent("spadmin:message")
AddEventHandler("spadmin:message", function(onlyjoueurs, message)
TriggerClientEvent("spadmin:envoyer", onlyjoueurs, message)
end)
--##################################--
--#### SP Leaks License © ####--
--##################################--