diff --git a/client/job.lua b/client/job.lua index c3ee0617..c0c3c06c 100644 --- a/client/job.lua +++ b/client/job.lua @@ -1,6 +1,6 @@ local CurrentAction, CurrentActionMsg, CurrentActionData = nil, '', {} local HasAlreadyEnteredMarker, LastHospital, LastPart, LastPartNum -local isBusy = false +local isBusy, deadPlayers, deadPlayerBlips, isOnDuty = false, {}, {}, false local spawnedVehicles, isInShopMenu = {}, false function OpenAmbulanceActionsMenu() @@ -407,11 +407,16 @@ function OpenCloakroomMenu() elements = { {label = _U('ems_clothes_civil'), value = 'citizen_wear'}, {label = _U('ems_clothes_ems'), value = 'ambulance_wear'}, - } - }, function(data, menu) + }}, function(data, menu) if data.current.value == 'citizen_wear' then ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) TriggerEvent('skinchanger:loadSkin', skin) + isOnDuty = false + + for playerId,v in pairs(deadPlayerBlips) do + RemoveBlip(v) + deadPlayerBlips[playerId] = nil + end end) elseif data.current.value == 'ambulance_wear' then ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin) @@ -420,6 +425,8 @@ function OpenCloakroomMenu() else TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female) end + + isOnDuty = true end) end @@ -768,12 +775,13 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.Game.Teleport(playerPed, restoreCoords) end, function(data, menu) DeleteSpawnedVehicles() - WaitForVehicleToLoad(data.current.model) + ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle) table.insert(spawnedVehicles, vehicle) TaskWarpPedIntoVehicle(playerPed, vehicle, -1) FreezeEntityPosition(vehicle, true) + SetModelAsNoLongerNeeded(data.current.model) end) end) @@ -782,6 +790,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) table.insert(spawnedVehicles, vehicle) TaskWarpPedIntoVehicle(playerPed, vehicle, -1) FreezeEntityPosition(vehicle, true) + SetModelAsNoLongerNeeded(elements[1].model) end) end @@ -812,35 +821,19 @@ function WaitForVehicleToLoad(modelHash) if not HasModelLoaded(modelHash) then RequestModel(modelHash) + BeginTextCommandBusyspinnerOn('STRING') + AddTextComponentSubstringPlayerName(_U('vehicleshop_awaiting_model')) + EndTextCommandBusyspinnerOn(4) + while not HasModelLoaded(modelHash) do Citizen.Wait(0) - - DisableControlAction(0, 27, true) - DisableControlAction(0, 173, true) - DisableControlAction(0, 174, true) - DisableControlAction(0, 175, true) - DisableControlAction(0, 176, true) -- ENTER key - DisableControlAction(0, 177, true) - - drawLoadingText(_U('vehicleshop_awaiting_model'), 255, 255, 255, 255) + DisableAllControlActions(0) end + + BusyspinnerOff() end end -function drawLoadingText(text, red, green, blue, alpha) - SetTextFont(4) - SetTextScale(0.0, 0.5) - SetTextColour(red, green, blue, alpha) - SetTextDropshadow(0, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextCentre(true) - - BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(text) - EndTextCommandDisplayText(0.5, 0.5) -end - function OpenPharmacyMenu() ESX.UI.Menu.CloseAll() @@ -898,3 +891,34 @@ AddEventHandler('esx_ambulancejob:heal', function(healType, quiet) ESX.ShowNotification(_U('healed')) end end) + +RegisterNetEvent('esx_ambulancejob:setDeadPlayers') +AddEventHandler('esx_ambulancejob:setDeadPlayers', function(_deadPlayers) + deadPlayers = _deadPlayers + + if isOnDuty then + for playerId,v in pairs(deadPlayerBlips) do + RemoveBlip(v) + deadPlayerBlips[playerId] = nil + end + + for playerId,status in pairs(deadPlayers) do + if status == 'distress' then + local player = GetPlayerFromServerId(playerId) + local playerPed = GetPlayerPed(player) + local blip = AddBlipForEntity(playerPed) + + SetBlipSprite(blip, 303) + SetBlipColour(blip, 1) + SetBlipFlashes(blip, true) + SetBlipCategory(blip, 7) + + BeginTextCommandSetBlipName('STRING') + AddTextComponentSubstringPlayerName(_U('blip_dead')) + EndTextCommandSetBlipName(blip) + + deadPlayerBlips[playerId] = blip + end + end + end +end) diff --git a/client/main.lua b/client/main.lua index 517b6483..55f7689c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -109,7 +109,7 @@ AddEventHandler('esx_ambulancejob:useItem', function(itemName) Citizen.Wait(0) DisableAllControlActions(0) end - + TriggerEvent('esx_ambulancejob:heal', 'big', true) ESX.ShowNotification(_U('used_medikit')) end) @@ -151,16 +151,8 @@ function StartDistressSignal() AddTextComponentSubstringPlayerName(_U('distress_send')) EndTextCommandDisplayText(0.175, 0.805) - if IsControlPressed(0, 47) then + if IsControlJustReleased(0, 47) then SendDistressSignal() - - Citizen.CreateThread(function() - Citizen.Wait(1000 * 60 * 5) - if isDead then - StartDistressSignal() - end - end) - break end end @@ -172,11 +164,7 @@ function SendDistressSignal() local coords = GetEntityCoords(playerPed) ESX.ShowNotification(_U('distress_sent')) - TriggerServerEvent('esx_phone:send', 'ambulance', _U('distress_message'), false, { - x = coords.x, - y = coords.y, - z = coords.z - }) + TriggerServerEvent('esx_ambulancejob:onPlayerDistress') end function DrawGenericTextThisFrame() @@ -195,9 +183,9 @@ function secondsToClock(seconds) if seconds <= 0 then return 0, 0 else - local hours = string.format("%02.f", math.floor(seconds / 3600)) - local mins = string.format("%02.f", math.floor(seconds / 60 - (hours * 60))) - local secs = string.format("%02.f", math.floor(seconds - hours * 3600 - mins * 60)) + local hours = string.format('%02.f', math.floor(seconds / 3600)) + local mins = string.format('%02.f', math.floor(seconds / 60 - (hours * 60))) + local secs = string.format('%02.f', math.floor(seconds - hours * 3600 - mins * 60)) return mins, secs end @@ -245,7 +233,7 @@ function StartDeathTimer() DrawGenericTextThisFrame() - SetTextEntry("STRING") + SetTextEntry('STRING') AddTextComponentString(text) DrawText(0.5, 0.8) end @@ -280,11 +268,11 @@ function StartDeathTimer() DrawGenericTextThisFrame() - SetTextEntry("STRING") + SetTextEntry('STRING') AddTextComponentString(text) DrawText(0.5, 0.8) end - + if bleedoutTimer < 1 and isDead then RemoveItemsAfterRPDeath() end diff --git a/locales/br.lua b/locales/br.lua index 3a96cd65..da8db727 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -77,7 +77,6 @@ Locales['br'] = { ['respawn_bleedout_fine_msg'] = 'você precisa pagar ~r~$%s~s~ para reviver', ['distress_send'] = 'pressione [~b~G~s~] enviar sinal de socorro', ['distress_sent'] = 'sinal de socorro foi enviado para as unidades disponíveis!', - ['distress_message'] = 'atenção médica necessária: cidadão inconsciente!', ['combatlog_message'] = 'você foi revivido porque deixou o servidor anteriormente quando estava morto.', -- Revive ['revive_help'] = 'reviver um cidadão', diff --git a/locales/cs.lua b/locales/cs.lua index 807ad4e2..f3a01344 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -77,7 +77,6 @@ Locales['cs'] = { ['respawn_bleedout_fine_msg'] = 'zaplatili jste ~r~$%s~s~ za respawn.', ['distress_send'] = 'stiskněte [~b~G~s~] pro vyslání tísňového signálu', ['distress_sent'] = 'tísňový signál byl vyslán dostupným jednotkám!', - ['distress_message'] = 'nutná lékařská péče: občan v bezvědomí!', ['combatlog_message'] = 'byli jste násilně oživeni, protože jste předtím opustili server, když jste byli mrtví.', -- Revive ['revive_help'] = 'oživit hráče', diff --git a/locales/en.lua b/locales/en.lua index ab37f814..eee39e22 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -77,7 +77,6 @@ Locales['en'] = { ['respawn_bleedout_fine_msg'] = 'you paid ~r~$%s~s~ to respawn.', ['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', diff --git a/locales/es.lua b/locales/es.lua index caad1d52..a9cec2aa 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -77,7 +77,6 @@ Locales['es'] = { ['respawn_bleedout_fine_msg'] = 'you paid ~r~$%s~s~ to respawn.', ['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', diff --git a/locales/fi.lua b/locales/fi.lua index ecc1b36e..3ca1f5c6 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -77,7 +77,6 @@ Locales['fi'] = { ['respawn_bleedout_fine_msg'] = 'you paid ~r~$%s~s~ to respawn.', ['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', diff --git a/locales/fr.lua b/locales/fr.lua index 24fb1a4c..e86658c7 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -77,7 +77,6 @@ Locales['fr'] = { ['respawn_bleedout_fine_msg'] = 'vous avez payé ~r~$%s~s~ pour être réanimer.', ['distress_send'] = 'appuyez sur [~b~G~s~] pour envoyer un signal de détresse', ['distress_sent'] = 'un signal a été envoyé à toutes les unités disponibles!', - ['distress_message'] = 'interventtion requise: citoyen inconscient!', ['combatlog_message'] = 'vous avez été réanimé de force car vous avez quitté le serveur.', -- Revive ['revive_help'] = 'relancer un joueur', diff --git a/locales/pl.lua b/locales/pl.lua index 7308e156..9d70f91e 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -77,7 +77,6 @@ Locales['pl'] = { ['respawn_bleedout_fine_msg'] = 'you paid ~r~$%s~s~ to respawn.', ['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', diff --git a/locales/sv.lua b/locales/sv.lua index c52d1f33..773a0ebc 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -77,7 +77,6 @@ Locales['sv'] = { ['respawn_bleedout_fine_msg'] = 'du betalade ~r~%s SEK~s~ för att respawna.', ['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', diff --git a/server/main.lua b/server/main.lua index b9b7afc0..08eff022 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,8 +1,12 @@ ESX = nil -local playersHealing = {} +local playersHealing, deadPlayers = {}, {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) +TriggerEvent('esx_phone:registerNumber', 'ambulance', _U('alert_ambulance'), true, true) + +TriggerEvent('esx_society:registerSociety', 'ambulance', 'Ambulance', 'society_ambulance', 'society_ambulance', 'society_ambulance', {type = 'public'}) + RegisterNetEvent('esx_ambulancejob:revive') AddEventHandler('esx_ambulancejob:revive', function(playerId) local xPlayer = ESX.GetPlayerFromId(source) @@ -11,15 +15,49 @@ AddEventHandler('esx_ambulancejob:revive', function(playerId) 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') + if deadPlayers[playerId] then + xPlayer.showNotification(_U('revive_complete_award', xTarget.name, Config.ReviveReward)) + xPlayer.addMoney(Config.ReviveReward) + xTarget.triggerEvent('esx_ambulancejob:revive') + deadPlayers[playerId] = nil + else + xPlayer.showNotification(_U('player_not_unconscious')) + end else xPlayer.showNotification(_U('revive_fail_offline')) end end end) +RegisterNetEvent('esx:onPlayerDeath') +AddEventHandler('esx:onPlayerDeath', function(data) + deadPlayers[source] = 'dead' + TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) +end) + +RegisterNetEvent('esx_ambulancejob:onPlayerDistress') +AddEventHandler('esx_ambulancejob:onPlayerDistress', function() + if deadPlayers[source] then + deadPlayers[source] = 'distress' + TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) + end +end) + +RegisterNetEvent('esx_ambulancejob:onPlayerSpawn') +AddEventHandler('esx_ambulancejob:onPlayerSpawn', function() + if deadPlayers[source] then + deadPlayers[source] = nil + TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) + end +end) + +AddEventHandler('esx:playerDropped', function(playerId, reason) + if deadPlayers[playerId] then + deadPlayers[playerId] = nil + TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) + end +end) + RegisterNetEvent('esx_ambulancejob:heal') AddEventHandler('esx_ambulancejob:heal', function(target, type) local xPlayer = ESX.GetPlayerFromId(source) @@ -38,10 +76,6 @@ AddEventHandler('esx_ambulancejob:putInVehicle', function(target) end end) -TriggerEvent('esx_phone:registerNumber', 'ambulance', _U('alert_ambulance'), true, true) - -TriggerEvent('esx_society:registerSociety', 'ambulance', 'Ambulance', 'society_ambulance', 'society_ambulance', 'society_ambulance', {type = 'public'}) - ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(source, cb) local xPlayer = ESX.GetPlayerFromId(source)