diff --git a/client/job.lua b/client/job.lua index 1021b88c..2434ca4f 100644 --- a/client/job.lua +++ b/client/job.lua @@ -62,48 +62,7 @@ function OpenMobileAmbulanceActionsMenu() else if data.current.value == 'revive' then - - isBusy = true - - ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity) - if quantity > 0 then - local closestPlayerPed = GetPlayerPed(closestPlayer) - - if IsPedDeadOrDying(closestPlayerPed, 1) then - local playerPed = PlayerPedId() - - ESX.ShowNotification(_U('revive_inprogress')) - - local lib, anim = 'mini@cpr@char_a@cpr_str', 'cpr_pumpchest' - - for i=1, 15, 1 do - Citizen.Wait(900) - - ESX.Streaming.RequestAnimDict(lib, function() - TaskPlayAnim(PlayerPedId(), lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) - end) - end - - TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') - TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer)) - - -- Show revive award? - if Config.ReviveReward > 0 then - ESX.ShowNotification(_U('revive_complete_award', GetPlayerName(closestPlayer), Config.ReviveReward)) - else - ESX.ShowNotification(_U('revive_complete', GetPlayerName(closestPlayer))) - end - else - ESX.ShowNotification(_U('player_not_unconscious')) - end - else - ESX.ShowNotification(_U('not_enough_medikit')) - end - - isBusy = false - - end, 'medikit') - + revivePlayer(closestPlayer) elseif data.current.value == 'small' then ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity) @@ -174,6 +133,38 @@ function OpenMobileAmbulanceActionsMenu() end) end +function revivePlayer(closestPlayer) + isBusy = true + + ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity) + if quantity > 0 then + local closestPlayerPed = GetPlayerPed(closestPlayer) + + if IsPedDeadOrDying(closestPlayerPed, 1) then + local playerPed = PlayerPedId() + local lib, anim = 'mini@cpr@char_a@cpr_str', 'cpr_pumpchest' + ESX.ShowNotification(_U('revive_inprogress')) + + for i=1, 15 do + Citizen.Wait(900) + + ESX.Streaming.RequestAnimDict(lib, function() + TaskPlayAnim(playerPed, lib, anim, 8.0, -8.0, -1, 0, 0, false, false, false) + end) + end + + TriggerServerEvent('esx_ambulancejob:removeItem', 'medikit') + TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer)) + else + ESX.ShowNotification(_U('player_not_unconscious')) + end + else + ESX.ShowNotification(_U('not_enough_medikit')) + end + isBusy = false + end, 'medikit') +end + function FastTravel(coords, heading) local playerPed = PlayerPedId() diff --git a/locales/br.lua b/locales/br.lua index 1cd0b382..6d9551c2 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -39,6 +39,7 @@ Locales['br'] = { ['revive_inprogress'] = 'Reanimação em andamento', ['revive_complete'] = 'você ressuscitou ~y~%s~s~', ['revive_complete_award'] = 'você ressuscitou ~y~%s~s~, ~g~$%s~s~', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'you are healing!', ['heal_complete'] = 'you have healed ~y~%s~s~', ['no_players'] = 'Nenhum jogador nas proximidades', diff --git a/locales/cs.lua b/locales/cs.lua index aa2f664f..807ad4e2 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -39,6 +39,7 @@ Locales['cs'] = { ['revive_inprogress'] = 'probíhá oživení!', ['revive_complete'] = 'oživili jste ~y~%s~s~', ['revive_complete_award'] = 'oživili jste ~y~%s~s~ a dostali jste ~g~$%s~s~!', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'uzdravujete!', ['heal_complete'] = 'uzdravili jste ~y~%s~s~', ['no_players'] = 'v okolí není žádný hráč!', diff --git a/locales/en.lua b/locales/en.lua index 36848986..ab37f814 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -39,6 +39,7 @@ Locales['en'] = { ['revive_inprogress'] = 'a revive is in progress!', ['revive_complete'] = 'you have revived ~y~%s~s~', ['revive_complete_award'] = 'you have revived ~y~%s~s~ and earned ~g~$%s~s~!', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'you are healing!', ['heal_complete'] = 'you have healed ~y~%s~s~', ['no_players'] = 'no players nearby', diff --git a/locales/es.lua b/locales/es.lua index a197d2ac..caad1d52 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -39,6 +39,7 @@ Locales['es'] = { ['revive_inprogress'] = 'reanimación en curso', ['revive_complete'] = 'has sido reanimado ~y~%s~s~', ['revive_complete_award'] = 'has sido reanimado ~y~%s~s~, ~g~$%s~s~', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'you are healing!', ['heal_complete'] = 'you have healed ~y~%s~s~', ['no_players'] = 'ningún jugador cerca', diff --git a/locales/fi.lua b/locales/fi.lua index 2068b318..ecc1b36e 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,8 +1,8 @@ Locales['fi'] = { -- Cloakroom - ['cloakroom'] = 'Vaatelokero', - ['ems_clothes_civil'] = 'Siviilikamppeet', - ['ems_clothes_ems'] = 'Työkamppeet', + ['cloakroom'] = 'vaatelokero', + ['ems_clothes_civil'] = 'siviilikamppeet', + ['ems_clothes_ems'] = 'työkamppeet', -- Vehicles ['ambulance'] = 'ambulance', ['helicopter_prompt'] = 'press ~INPUT_CONTEXT~ to access the ~y~Helicopter Actions~s~.', @@ -39,6 +39,7 @@ Locales['fi'] = { ['revive_inprogress'] = 'elvytys on menossa!', ['revive_complete'] = 'sinä elvytit henkilön ~y~%s~s~', ['revive_complete_award'] = 'sinä elvytit henkilön ~y~%s~s~ ja tienasit ~g~$%s~s~!', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'sinä olet parantamassa!', ['heal_complete'] = 'sinä paransit henkilön ~y~%s~s~', ['no_players'] = 'ei pelaajia lähettyvillä', diff --git a/locales/fr.lua b/locales/fr.lua index 94f62665..24fb1a4c 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,8 +1,8 @@ Locales['fr'] = { -- Cloakroom - ['cloakroom'] = 'Vestiaire', - ['ems_clothes_civil'] = 'Tenue Civil', - ['ems_clothes_ems'] = 'Tenue Ambulancier', + ['cloakroom'] = 'vestiaire', + ['ems_clothes_civil'] = 'tenue Civil', + ['ems_clothes_ems'] = 'tenue Ambulancier', -- Vehicles ['ambulance'] = 'ambulance', ['helicopter_prompt'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder aux ~y~Actions de l\'hélicoptère~s~.', @@ -39,6 +39,7 @@ Locales['fr'] = { ['revive_inprogress'] = 'réanimation en cours', ['revive_complete'] = 'vous avez réanimé ~y~%s~s~', ['revive_complete_award'] = 'vous avez réanimé ~y~%s~s~, ~g~$%s~s~', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'vous soignez...', ['heal_complete'] = 'vous avez soigné ~y~%s~s~', ['no_players'] = 'aucun joueur à proximité', diff --git a/locales/pl.lua b/locales/pl.lua index ebf75ce1..7308e156 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -39,6 +39,7 @@ Locales['pl'] = { ['revive_inprogress'] = 'trwa wskrzeszenie', ['revive_complete'] = 'zostałeś wskrzeszony ~y~%s~s~', ['revive_complete_award'] = 'zostałeś wskrzeszony ~y~%s~s~ i zarobiono ~g~$%s~s~!', + ['revive_fail_offline'] = 'that player is no longer online', ['heal_inprogress'] = 'leczysz!', ['heal_complete'] = 'zostałeś uleczony ~y~%s~s~', ['no_players'] = 'brak graczy w pobliżu', diff --git a/locales/sv.lua b/locales/sv.lua index 64abd2cf..c52d1f33 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -39,6 +39,7 @@ Locales['sv'] = { ['revive_inprogress'] = 'en återupplivning har börjats', ['revive_complete'] = 'du har återupplivat ~y~%s~s~, bra jobbat!', ['revive_complete_award'] = 'du har återupplivat ~y~%s~s~ och tjärnat ~g~%s SEK~s~ för dina tjänster, bra jobbat!', + ['revive_fail_offline'] = 'den spelaren har lämnat servern', ['heal_inprogress'] = 'du behandlar patienten!', ['heal_complete'] = 'du har behandlat ~y~%s~s~', ['no_players'] = 'det finns inga spelare i närheten!', diff --git a/server/main.lua b/server/main.lua index 1f037c9e..6da561e6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,17 +3,24 @@ local playersHealing = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -RegisterServerEvent('esx_ambulancejob:revive') -AddEventHandler('esx_ambulancejob:revive', function(target) +RegisterNetEvent('esx_ambulancejob:revive') +AddEventHandler('esx_ambulancejob:revive', function(playerId) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.job.name == 'ambulance' then - xPlayer.addMoney(Config.ReviveReward) - TriggerClientEvent('esx_ambulancejob:revive', target) + if xPlayer and xPlayer.job.name == 'ambulance' then + local xTarget = ESX.GetPlayerFromId(playerId) + + if xTarget then + xPlayer.showNotification(_U('revive_complete_award', xTarget.name, Config.ReviveReward)) + xPlayer.addMoney(Config.ReviveReward) + xTarget.triggerEvent('esx_ambulancejob:revive') + else + xPlayer.showNotification(_U('revive_fail_offline')) + end end end) -RegisterServerEvent('esx_ambulancejob:heal') +RegisterNetEvent('esx_ambulancejob:heal') AddEventHandler('esx_ambulancejob:heal', function(target, type) local xPlayer = ESX.GetPlayerFromId(source) @@ -22,7 +29,7 @@ AddEventHandler('esx_ambulancejob:heal', function(target, type) end end) -RegisterServerEvent('esx_ambulancejob:putInVehicle') +RegisterNetEvent('esx_ambulancejob:putInVehicle') AddEventHandler('esx_ambulancejob:putInVehicle', function(target) local xPlayer = ESX.GetPlayerFromId(source) @@ -88,7 +95,7 @@ if Config.EarlyRespawnFine then cb(bankBalance >= Config.EarlyRespawnFineAmount) end) - RegisterServerEvent('esx_ambulancejob:payFine') + RegisterNetEvent('esx_ambulancejob:payFine') AddEventHandler('esx_ambulancejob:payFine', function() local xPlayer = ESX.GetPlayerFromId(source) local fineAmount = Config.EarlyRespawnFineAmount @@ -188,7 +195,7 @@ function getPriceFromHash(hashKey, jobGrade, type) return 0 end -RegisterServerEvent('esx_ambulancejob:removeItem') +RegisterNetEvent('esx_ambulancejob:removeItem') AddEventHandler('esx_ambulancejob:removeItem', function(item) local xPlayer = ESX.GetPlayerFromId(source) xPlayer.removeInventoryItem(item, 1) @@ -200,7 +207,7 @@ AddEventHandler('esx_ambulancejob:removeItem', function(item) end end) -RegisterServerEvent('esx_ambulancejob:giveItem') +RegisterNetEvent('esx_ambulancejob:giveItem') AddEventHandler('esx_ambulancejob:giveItem', function(itemName, amount) local xPlayer = ESX.GetPlayerFromId(source) @@ -274,7 +281,7 @@ ESX.RegisterServerCallback('esx_ambulancejob:getDeathStatus', function(source, c end) end) -RegisterServerEvent('esx_ambulancejob:setDeathStatus') +RegisterNetEvent('esx_ambulancejob:setDeathStatus') AddEventHandler('esx_ambulancejob:setDeathStatus', function(isDead) local identifier = GetPlayerIdentifiers(source)[1]