diff --git a/server-data/resources/[esx_addons]/esx_policejob/client/main.lua b/server-data/resources/[esx_addons]/esx_policejob/client/main.lua index 16aa6c845..e43e8fafd 100644 --- a/server-data/resources/[esx_addons]/esx_policejob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_policejob/client/main.lua @@ -954,8 +954,7 @@ function OnPlayerData(k, v) end end -RegisterNetEvent('esx_phone:loaded') -AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) +RegisterNetEvent('esx_phone:loaded', function(phoneNumber, contacts) local specialContact = { name = TranslateCap('phone_police'), number = 'police', @@ -966,7 +965,7 @@ AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) end) -- don't show dispatches if the player isn't in service -AddEventHandler('esx_phone:cancelMessage', function(dispatchNumber) +RegisterNetEvent('esx_phone:cancelMessage', function(dispatchNumber) if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' and ESX.PlayerData.job.name == dispatchNumber then -- if esx_service is enabled if Config.EnableESXService and not playerInService then @@ -975,7 +974,7 @@ AddEventHandler('esx_phone:cancelMessage', function(dispatchNumber) end end) -AddEventHandler('esx_policejob:hasEnteredMarker', function(station, part, partNum) +RegisterNetEvent('esx_policejob:hasEnteredMarker', function(station, part, partNum) if part == 'Cloakroom' then CurrentAction = 'menu_cloakroom' CurrentActionMsg = TranslateCap('open_cloackroom') @@ -999,7 +998,7 @@ AddEventHandler('esx_policejob:hasEnteredMarker', function(station, part, partNu end end) -AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum) +RegisterNetEvent('esx_policejob:hasExitedMarker', function(station, part, partNum) if not isInShopMenu then ESX.CloseContext() end @@ -1007,7 +1006,7 @@ AddEventHandler('esx_policejob:hasExitedMarker', function(station, part, partNum CurrentAction = nil end) -AddEventHandler('esx_policejob:hasEnteredEntityZone', function(entity) +RegisterNetEvent('esx_policejob:hasEnteredEntityZone', function(entity) local playerPed = PlayerPedId() if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' and IsPedOnFoot(playerPed) then @@ -1030,14 +1029,13 @@ AddEventHandler('esx_policejob:hasEnteredEntityZone', function(entity) end end) -AddEventHandler('esx_policejob:hasExitedEntityZone', function(entity) +RegisterNetEvent('esx_policejob:hasExitedEntityZone', function(entity) if CurrentAction == 'remove_entity' then CurrentAction = nil end end) -RegisterNetEvent('esx_policejob:handcuff') -AddEventHandler('esx_policejob:handcuff', function() +RegisterNetEvent('esx_policejob:handcuff', function() isHandcuffed = not isHandcuffed local playerPed = PlayerPedId() @@ -1078,8 +1076,7 @@ AddEventHandler('esx_policejob:handcuff', function() end end) -RegisterNetEvent('esx_policejob:unrestrain') -AddEventHandler('esx_policejob:unrestrain', function() +RegisterNetEvent('esx_policejob:unrestrain', function() if isHandcuffed then local playerPed = PlayerPedId() isHandcuffed = false @@ -1098,8 +1095,7 @@ AddEventHandler('esx_policejob:unrestrain', function() end end) -RegisterNetEvent('esx_policejob:drag') -AddEventHandler('esx_policejob:drag', function(copId) +RegisterNetEvent('esx_policejob:drag', function(copId) if isHandcuffed then dragStatus.isDragged = not dragStatus.isDragged dragStatus.CopId = copId @@ -1136,8 +1132,7 @@ CreateThread(function() end end) -RegisterNetEvent('esx_policejob:putInVehicle') -AddEventHandler('esx_policejob:putInVehicle', function() +RegisterNetEvent('esx_policejob:putInVehicle', function() if isHandcuffed then local playerPed = PlayerPedId() local vehicle, distance = ESX.Game.GetClosestVehicle() @@ -1160,8 +1155,7 @@ AddEventHandler('esx_policejob:putInVehicle', function() end end) -RegisterNetEvent('esx_policejob:OutVehicle') -AddEventHandler('esx_policejob:OutVehicle', function() +RegisterNetEvent('esx_policejob:OutVehicle', function() local GetVehiclePedIsIn = GetVehiclePedIsIn local IsPedSittingInAnyVehicle = IsPedSittingInAnyVehicle local TaskLeaveVehicle = TaskLeaveVehicle @@ -1504,8 +1498,7 @@ function createBlip(id) end end -RegisterNetEvent('esx_policejob:updateBlip') -AddEventHandler('esx_policejob:updateBlip', function() +RegisterNetEvent('esx_policejob:updateBlip', function() -- Refresh all blips for k, existingBlip in pairs(blipsCops) do @@ -1540,7 +1533,7 @@ AddEventHandler('esx_policejob:updateBlip', function() end) -AddEventHandler('esx:onPlayerSpawn', function(spawn) +RegisterNetEvent('esx:onPlayerSpawn', function(spawn) isDead = false TriggerEvent('esx_policejob:unrestrain') @@ -1550,11 +1543,11 @@ AddEventHandler('esx:onPlayerSpawn', function(spawn) hasAlreadyJoined = true end) -AddEventHandler('esx:onPlayerDeath', function(data) +RegisterNetEvent('esx:onPlayerDeath', function(data) isDead = true end) -AddEventHandler('onResourceStop', function(resource) +RegisterNetEvent('onResourceStop', function(resource) if resource == GetCurrentResourceName() then TriggerEvent('esx_policejob:unrestrain') TriggerEvent('esx_phone:removeSpecialContact', 'police') diff --git a/server-data/resources/[esx_addons]/esx_policejob/server/main.lua b/server-data/resources/[esx_addons]/esx_policejob/server/main.lua index 7545fc353..d43bedbaf 100644 --- a/server-data/resources/[esx_addons]/esx_policejob/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_policejob/server/main.lua @@ -7,8 +7,7 @@ end TriggerEvent('esx_phone:registerNumber', 'police', TranslateCap('alert_police'), true, true) TriggerEvent('esx_society:registerSociety', 'police', TranslateCap('society_police'), 'society_police', 'society_police', 'society_police', {type = 'public'}) -RegisterNetEvent('esx_policejob:confiscatePlayerItem') -AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount) +RegisterNetEvent('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount) local source = source local sourceXPlayer = ESX.GetPlayerFromId(source) local targetXPlayer = ESX.GetPlayerFromId(target) @@ -68,8 +67,7 @@ AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, end end) -RegisterNetEvent('esx_policejob:handcuff') -AddEventHandler('esx_policejob:handcuff', function(target) +RegisterNetEvent('esx_policejob:handcuff', function(target) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == 'police' then @@ -79,8 +77,7 @@ AddEventHandler('esx_policejob:handcuff', function(target) end end) -RegisterNetEvent('esx_policejob:drag') -AddEventHandler('esx_policejob:drag', function(target) +RegisterNetEvent('esx_policejob:drag', function(target) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == 'police' then @@ -90,8 +87,7 @@ AddEventHandler('esx_policejob:drag', function(target) end end) -RegisterNetEvent('esx_policejob:putInVehicle') -AddEventHandler('esx_policejob:putInVehicle', function(target) +RegisterNetEvent('esx_policejob:putInVehicle', function(target) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == 'police' then @@ -101,8 +97,7 @@ AddEventHandler('esx_policejob:putInVehicle', function(target) end end) -RegisterNetEvent('esx_policejob:OutVehicle') -AddEventHandler('esx_policejob:OutVehicle', function(target) +RegisterNetEvent('esx_policejob:OutVehicle', function(target) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == 'police' then @@ -112,8 +107,7 @@ AddEventHandler('esx_policejob:OutVehicle', function(target) end end) -RegisterNetEvent('esx_policejob:getStockItem') -AddEventHandler('esx_policejob:getStockItem', function(itemName, count) +RegisterNetEvent('esx_policejob:getStockItem', function(itemName, count) local source = source local xPlayer = ESX.GetPlayerFromId(source) @@ -137,8 +131,7 @@ AddEventHandler('esx_policejob:getStockItem', function(itemName, count) end) end) -RegisterNetEvent('esx_policejob:putStockItems') -AddEventHandler('esx_policejob:putStockItems', function(itemName, count) +RegisterNetEvent('esx_policejob:putStockItems', function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) local sourceItem = xPlayer.getInventoryItem(itemName) @@ -426,7 +419,7 @@ ESX.RegisterServerCallback('esx_policejob:getPlayerInventory', function(source, cb({items = items}) end) -AddEventHandler('playerDropped', function() +RegisterNetEvent('playerDropped', function() local playerId = source if playerId then local xPlayer = ESX.GetPlayerFromId(playerId) @@ -438,8 +431,7 @@ AddEventHandler('playerDropped', function() end end) -RegisterNetEvent('esx_policejob:spawned') -AddEventHandler('esx_policejob:spawned', function() +RegisterNetEvent('esx_policejob:spawned', function() local playerId = source local xPlayer = ESX.GetPlayerFromId(playerId) @@ -449,14 +441,13 @@ AddEventHandler('esx_policejob:spawned', function() end end) -RegisterNetEvent('esx_policejob:forceBlip') -AddEventHandler('esx_policejob:forceBlip', function() +RegisterNetEvent('esx_policejob:forceBlip', function() for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'police')) do TriggerClientEvent('esx_policejob:updateBlip', xPlayer.source) end end) -AddEventHandler('onResourceStart', function(resource) +RegisterNetEvent('onResourceStart', function(resource) if resource == GetCurrentResourceName() then Wait(5000) for _, xPlayer in pairs(ESX.GetExtendedPlayers('job', 'police')) do @@ -465,7 +456,7 @@ AddEventHandler('onResourceStart', function(resource) end end) -AddEventHandler('onResourceStop', function(resource) +RegisterNetEvent('onResourceStop', function(resource) if resource == GetCurrentResourceName() then TriggerEvent('esx_phone:removeNumber', 'police') end