diff --git a/client/job.lua b/client/job.lua index 529ec5fb..48da14d5 100644 --- a/client/job.lua +++ b/client/job.lua @@ -1,4 +1,5 @@ local HasAlreadyEnteredMarker, LastZone, CurrentAction, CurrentActionMsg, CurrentActionData = nil, nil, nil, '', {} +local IsBusy = false function OpenAmbulanceActionsMenu() local elements = { diff --git a/client/main.lua b/client/main.lua index 0e739c98..0141e83b 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,7 +10,7 @@ Keys = { ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 } -local FirstSpawn, IsBusy = true, false +local FirstSpawn, PlayerLoaded = true, false IsDead = false ESX = nil @@ -25,12 +25,14 @@ Citizen.CreateThread(function() Citizen.Wait(100) end + PlayerLoaded = true ESX.PlayerData = ESX.GetPlayerData() end) RegisterNetEvent('esx:playerLoaded') AddEventHandler('esx:playerLoaded', function(xPlayer) ESX.PlayerData = xPlayer + PlayerLoaded = true end) RegisterNetEvent('esx:setJob') @@ -42,9 +44,19 @@ AddEventHandler('playerSpawned', function() IsDead = false if FirstSpawn then - TriggerServerEvent('esx_ambulancejob:firstSpawn') exports.spawnmanager:setAutoSpawn(false) -- disable respawn FirstSpawn = false + + ESX.TriggerServerCallback('esx_ambulancejob:getDeathStatus', function(isDead) + if isDead and Config.AntiCombatLog then + while not PlayerLoaded do + Citizen.Wait(1000) + end + + ESX.ShowNotification(_U('combatlog_message')) + RemoveItemsAfterRPDeath() + end + end) end end) @@ -66,7 +78,7 @@ end) function OnPlayerDeath() IsDead = true - TriggerServerEvent('esx_ambulancejob:setDeathStatus', 1) + TriggerServerEvent('esx_ambulancejob:setDeathStatus', true) StartDeathTimer() StartDistressSignal() @@ -226,7 +238,7 @@ function StartDeathTimer() end function RemoveItemsAfterRPDeath() - TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) + TriggerServerEvent('esx_ambulancejob:setDeathStatus', false) Citizen.CreateThread(function() DoScreenFadeOut(800) @@ -290,7 +302,7 @@ RegisterNetEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) - TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0) + TriggerServerEvent('esx_ambulancejob:setDeathStatus', true) Citizen.CreateThread(function() DoScreenFadeOut(800) @@ -322,15 +334,6 @@ AddEventHandler('esx_ambulancejob:revive', function() end) end) - -RegisterNetEvent('esx_ambulancejob:requestDeath') -AddEventHandler('esx_ambulancejob:requestDeath', function() - if Config.AntiCombatLog then - Citizen.Wait(5000) - SetEntityHealth(PlayerPedId(), 0) - end -end) - -- Load unloaded IPLs if Config.LoadIpl then Citizen.CreateThread(function() diff --git a/locales/br.lua b/locales/br.lua index 1e934fcb..2d7db462 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -52,6 +52,7 @@ Locales['br'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'reviver um jogador', -- Item diff --git a/locales/en.lua b/locales/en.lua index 17c85a22..053012f2 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -52,6 +52,7 @@ Locales['en'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'revive a player', -- Item diff --git a/locales/es.lua b/locales/es.lua index 2445a06e..df241022 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -52,6 +52,7 @@ Locales['es'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'reviver un jugador', -- Item diff --git a/locales/fi.lua b/locales/fi.lua index 59574c21..d474c1f5 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -52,6 +52,7 @@ Locales['fi'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'elvytä pelaaja', -- Item diff --git a/locales/fr.lua b/locales/fr.lua index 1fa2cca3..3dc156b1 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -52,6 +52,7 @@ Locales['fr'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'relancer un joueur', -- Item diff --git a/locales/pl.lua b/locales/pl.lua index 31b5486a..e301f8b4 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -52,6 +52,7 @@ Locales['pl'] = { ['distress_send'] = 'press [~b~G~s~] to send distress signal', ['distress_sent'] = 'distress signal has been sent to available units!', ['distress_message'] = 'medical attention required: unconscious citizen!', + ['combatlog_message'] = 'you have been force-respawned because you\'ve previously left the server when dead.', -- Revive ['revive_help'] = 'ożyw gracza', -- Item diff --git a/locales/sv.lua b/locales/sv.lua index ae3f4a04..7097678f 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -52,6 +52,7 @@ Locales['sv'] = { ['distress_send'] = 'tryck ~b~[G]~s~ för att skicka nödsignal', ['distress_sent'] = 'nödsignal har skickats till samtliga enheter!', ['distress_message'] = 'läkarvård krävs: medvetslös medborgare!', + ['combatlog_message'] = 'du har force-respawnats på grund av att du lämnat servern medans du var död', -- Revive ['revive_help'] = 'återuppliva en spelare', -- Item diff --git a/server/main.lua b/server/main.lua index b233f93d..2a66b62c 100644 --- a/server/main.lua +++ b/server/main.lua @@ -179,17 +179,17 @@ ESX.RegisterUsableItem('bandage', function(source) TriggerClientEvent('esx:showNotification', _source, _U('used_bandage')) end) -RegisterServerEvent('esx_ambulancejob:firstSpawn') -AddEventHandler('esx_ambulancejob:firstSpawn', function() - local _source = source - local identifier = GetPlayerIdentifiers(_source)[1] +ESX.RegisterServerCallback('esx_ambulancejob:getDeathStatus', function(source, cb) + local identifier = GetPlayerIdentifiers(source)[1] + MySQL.Async.fetchScalar('SELECT is_dead FROM users WHERE identifier = @identifier', { ['@identifier'] = identifier }, function(isDead) if isDead then print(('esx_ambulancejob: %s attempted combat logging!'):format(identifier)) - TriggerClientEvent('esx_ambulancejob:requestDeath', _source) end + + cb(isDead) end) end)