@@ -20,7 +20,7 @@ local M = {
2020
2121local registerCallback = lib .callback .register
2222
23- RegisterNetEvent (' esx:requestModel' , function (model )
23+ @ onNet (' esx:requestModel' , function (model )
2424 ESX .Streaming .RequestModel (model )
2525end )
2626
3434
3535local hybridType = public .hybrid_data
3636
37- RegisterNetEvent (' esx:playerLoaded' , function (xPlayer , isNew )
37+ @ onNet (' esx:playerLoaded' , function (xPlayer , isNew )
3838 local tries = 0
3939 repeat
4040 Core .Items = lib .loadJson (' db.items' )
@@ -157,7 +157,7 @@ RegisterNetEvent('esx:playerLoaded', function(xPlayer, isNew)
157157 lib .print .info (' Player has initialized' )
158158end )
159159
160- RegisterNetEvent (' esx:setInventory' , function (_newInventory )
160+ @ onNet (' esx:setInventory' , function (_newInventory )
161161 local newInventory = {}
162162
163163 for index , item in ipairs (_newInventory ) do
@@ -178,21 +178,21 @@ local function onPlayerSpawn()
178178 ESX .SetPlayerData (' dead' , false )
179179end
180180
181- AddEventHandler (' playerSpawned' , onPlayerSpawn )
182- AddEventHandler (' esx:onPlayerSpawn' , onPlayerSpawn )
181+ @ on (' playerSpawned' , onPlayerSpawn )
182+ @ on (' esx:onPlayerSpawn' , onPlayerSpawn )
183183
184- AddEventHandler (' esx:onPlayerDeath' , function ()
184+ @ on (' esx:onPlayerDeath' , function ()
185185 ESX .SetPlayerData (' dead' , true )
186186end )
187187
188- AddEventHandler (' skinchanger:modelLoaded' , function ()
188+ @ on (' skinchanger:modelLoaded' , function ()
189189 while not ESX .PlayerLoaded do
190190 Wait (100 )
191191 end
192192 TriggerEvent (' esx:restoreLoadout' )
193193end )
194194
195- AddEventHandler (' esx:restoreLoadout' , function ()
195+ @ on (' esx:restoreLoadout' , function ()
196196 local ammoTypes = {}
197197 RemoveAllPedWeapons (cache .ped , true )
198198
@@ -249,7 +249,7 @@ AddStateBagChangeHandler('VehicleProperties', nil, function(bagName, _, value)
249249 ESX .Game .SetVehicleProperties (vehicle , value )
250250end )
251251
252- RegisterNetEvent (' esx:setAccountMoney' , function (account )
252+ @ onNet (' esx:setAccountMoney' , function (account )
253253 local retval = true
254254 if hybridType == true or hybridType == ' hash' then
255255 retval = pcall (function ()
@@ -274,23 +274,23 @@ RegisterNetEvent('esx:setAccountMoney', function(account)
274274 ESX .SetPlayerData (' accounts' , ESX .PlayerData .accounts )
275275end )
276276
277- RegisterNetEvent (' esx:setJob' , function (job )
277+ @ onNet (' esx:setJob' , function (job )
278278 ESX .SetPlayerData (' job' , job )
279279end )
280280
281- RegisterNetEvent (' esx:setGroup' , function (group )
281+ @ onNet (' esx:setGroup' , function (group )
282282 ESX .SetPlayerData (' group' , group )
283283end )
284284
285- RegisterNetEvent (' esx:registerSuggestions' , function (registeredCommands )
285+ @ onNet (' esx:registerSuggestions' , function (registeredCommands )
286286 for name , command in pairs (registeredCommands ) do
287287 if command .suggestion then
288288 TriggerEvent (' chat:addSuggestion' , (' /%s' ):format (name ), command .suggestion .help , command .suggestion .arguments )
289289 end
290290 end
291291end )
292292
293- RegisterNetEvent (' esx:addInventoryItem' , function (item , count )
293+ @ onNet (' esx:addInventoryItem' , function (item , count )
294294 local retval = true
295295
296296 if hybridType == true or hybridType == ' hash' then
@@ -313,7 +313,7 @@ RegisterNetEvent('esx:addInventoryItem', function(item, count)
313313 end
314314end )
315315
316- RegisterNetEvent (' esx:removeInventoryItem' , function (item , count )
316+ @ onNet (' esx:removeInventoryItem' , function (item , count )
317317 local retval = true
318318
319319 if hybridType == true or hybridType == ' hash' then
@@ -336,7 +336,7 @@ RegisterNetEvent('esx:removeInventoryItem', function(item, count)
336336 end
337337end )
338338
339- RegisterNetEvent (' esx:addLoadoutItem' , function (weaponName , weaponLabel , ammo )
339+ @ onNet (' esx:addLoadoutItem' , function (weaponName , weaponLabel , ammo )
340340 local data = {
341341 name = weaponName ,
342342 ammo = ammo ,
@@ -369,7 +369,7 @@ RegisterNetEvent('esx:addLoadoutItem', function(weaponName, weaponLabel, ammo)
369369 ESX .SetPlayerData (' loadout' , ESX .PlayerData .loadout )
370370end )
371371
372- RegisterNetEvent (' esx:removeLoadoutItem' , function (weaponName , weaponLabel )
372+ @ onNet (' esx:removeLoadoutItem' , function (weaponName , weaponLabel )
373373 local retval = true
374374
375375 if hybridType == true or hybridType == ' hash' then
@@ -399,16 +399,16 @@ registerCallback('esx:getVehicleType', function(model)
399399 return ESX .GetVehicleTypeClient (model )
400400end )
401401
402- RegisterNetEvent (' esx:updatePlayerData' , function (key , val )
402+ @ onNet (' esx:updatePlayerData' , function (key , val )
403403 ESX .SetPlayerData (key , val )
404404end )
405405
406406--- @param command string
407- RegisterNetEvent (' esx:executeCommand' , function (command )
407+ @ onNet (' esx:executeCommand' , function (command )
408408 ExecuteCommand (command )
409409end )
410410
411- AddEventHandler (' onResourceStop' , function (resource )
411+ @ on (' onResourceStop' , function (resource )
412412 if Core .Events [resource ] then
413413 for i = 1 , # Core .Events [resource ] do
414414 RemoveEventHandler (Core .Events [resource ][i ])
0 commit comments