Added sending distress signals to available medics

This commit is contained in:
ElPumpo
2018-06-06 22:43:47 +02:00
parent 01aea0a71d
commit b0011647a6
7 changed files with 113 additions and 67 deletions
+87 -65
View File
@@ -19,7 +19,6 @@ local LastZone = nil
local CurrentAction = nil
local CurrentActionMsg = ''
local CurrentActionData = {}
local RespawnToHospitalMenu = nil
ESX = nil
GUI.Time = 0
@@ -29,7 +28,7 @@ Citizen.CreateThread(function()
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
Citizen.Wait(5000)
PlayerData = ESX.GetPlayerData()
end)
@@ -40,11 +39,7 @@ function RespawnPed(ped, coords)
SetPlayerInvincible(ped, false)
TriggerEvent('playerSpawned', coords.x, coords.y, coords.z, coords.heading)
ClearPedBloodDamage(ped)
if RespawnToHospitalMenu ~= nil then
RespawnToHospitalMenu.close()
RespawnToHospitalMenu = nil
end
ESX.UI.Menu.CloseAll()
end
@@ -63,43 +58,69 @@ AddEventHandler('esx_ambulancejob:heal', function(_type)
end)
function StartRespawnToHospitalMenuTimer()
ESX.SetTimeout(Config.MenuRespawnToHospitalDelay, function()
if IsDead then
local elements = {}
table.insert(elements, {label = _U('yes'), value = 'yes'})
RespawnToHospitalMenu = ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'menuName',
{
title = _U('respawn_at_hospital'),
align = 'top-left',
elements = elements
},
function(data, menu) --Submit Cb
menu.close()
Citizen.CreateThread(function()
RemoveItemsAfterRPDeath()
end)
end,
function(data, menu) --Cancel Cb
--menu.close()
end,
function(data, menu) --Change Cb
--print(data.current.value)
end,
function(data, menu) --Close Cb
RespawnToHospitalMenu = nil
end
)
end
end)
ESX.SetTimeout(Config.MenuRespawnToHospitalDelay, function()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'respawn_hospital',
{
title = _U('respawn_at_hospital'),
align = 'top-left',
elements = {
{label = _U('no'), value = 'no'},
{label = _U('yes'), value = 'yes'}
}
}, function(data, menu)
if data.current.value == 'yes' then
RemoveItemsAfterRPDeath()
end
menu.close()
end)
end)
end
function StartRespawnTimer()
ESX.SetTimeout(Config.RespawnDelayAfterRPDeath, function()
if IsDead then
RemoveItemsAfterRPDeath()
end
end)
ESX.SetTimeout(Config.RespawnDelayAfterRPDeath, function()
RemoveItemsAfterRPDeath()
end)
end
function StartDistressSignal()
Citizen.CreateThread(function()
local timer = Config.RespawnDelayAfterRPDeath
while timer > 0 and IsDead do
Citizen.Wait(2)
timer = timer - 30
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.45, 0.45)
SetTextColour(185, 185, 185, 255)
SetTextDropShadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
BeginTextCommandDisplayText('STRING')
AddTextComponentSubstringPlayerName(_U('distress_send'))
EndTextCommandDisplayText(0.175, 0.805)
if IsControlPressed(0, Keys['G']) then
SendDistressSignal()
break
end
end
end)
end
function SendDistressSignal()
local playerPed = GetPlayerPed(-1)
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
})
end
function ShowTimer()
@@ -113,7 +134,7 @@ function ShowTimer()
raw_minutes = raw_seconds/60
minutes = stringsplit(raw_minutes, ".")[1]
seconds = stringsplit(raw_seconds-(minutes*60), ".")[1]
SetTextFont(4)
SetTextProportional(0)
SetTextScale(0.0, 0.5)
@@ -122,7 +143,6 @@ function ShowTimer()
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
local text = _U('please_wait', minutes, seconds)
@@ -130,9 +150,10 @@ function ShowTimer()
text = text .. '\n[~b~E~s~]'
end
AddTextComponentString(text)
SetTextCentre(true)
DrawText(0.5, 0.8)
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandDisplayText(0.5, 0.8)
if Config.EarlyRespawn then
if IsControlPressed(0, Keys['E']) then
@@ -155,11 +176,11 @@ function ShowTimer()
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(_U('press_respawn'))
SetTextCentre(true)
DrawText(0.5, 0.8)
BeginTextCommandDisplayText("STRING")
AddTextComponentSubstringPlayerName(_U('press_respawn'))
EndTextCommandDisplayText(0.5, 0.8)
if IsControlPressed(0, Keys['E']) then
RemoveItemsAfterRPDeath()
@@ -172,24 +193,24 @@ end
function RemoveItemsAfterRPDeath()
TriggerServerEvent('esx_ambulancejob:setDeathStatus', 0)
Citizen.CreateThread(function()
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(1)
end
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function()
ESX.SetPlayerData('lastPosition', Config.Zones.HospitalInteriorInside1.Pos)
ESX.SetPlayerData('loadout', {})
Citizen.CreateThread(function()
DoScreenFadeOut(800)
while not IsScreenFadedOut() do
Citizen.Wait(10)
end
TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos)
ESX.TriggerServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function()
ESX.SetPlayerData('lastPosition', Config.Zones.HospitalInteriorInside1.Pos)
ESX.SetPlayerData('loadout', {})
RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos)
TriggerServerEvent('esx:updateLastPosition', Config.Zones.HospitalInteriorInside1.Pos)
RespawnPed(GetPlayerPed(-1), Config.Zones.HospitalInteriorInside1.Pos)
StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end)
StopScreenEffect('DeathFailOut')
DoScreenFadeIn(800)
end)
end)
end
function OnPlayerDeath()
@@ -201,13 +222,14 @@ function OnPlayerDeath()
end
StartRespawnTimer()
StartDistressSignal()
if Config.RespawnToHospitalMenuTimer == true then
if Config.RespawnToHospitalMenuTimer then
StartRespawnToHospitalMenuTimer()
end
ClearPedTasksImmediately(GetPlayerPed(-1))
StartScreenEffect('DeathFailOut', 0, false)
StartScreenEffect('DeathFailOut', 0, false)
end
function TeleportFadeEffect(entity, coords)
+4
View File
@@ -48,9 +48,13 @@ Locales['br'] = {
-- Death
['respawn_at_hospital'] = 'Você quer ser transportado para o hospital ?',
['yes'] = 'Sim',
['no'] = 'no',
['please_wait'] = 'Você será automaticamente transportado para o hospital em ~b~%s minutos %s segundos~s~',
['press_respawn'] = 'Aperte [~b~E~w~] para renascer.',
['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.',
['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!',
-- Revive
['revive_help'] = 'reviver um jogador',
-- Item
+4
View File
@@ -39,9 +39,13 @@ Locales['de'] = {
-- Death
['respawn_at_hospital'] = 'Willst du ins Krankenhaus gebracht werden?',
['yes'] = 'ja',
['no'] = 'no',
['please_wait'] = 'bitte warte ~b~%s minuten %s sekunden~s~ bis zum respawn',
['press_respawn'] = 'Drücke [~b~E~w~] zum respawnen.',
['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.',
['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!',
-- Revive
['revive_help'] = 'Spieler wiederbeleben',
}
+4
View File
@@ -48,9 +48,13 @@ Locales['en'] = {
-- Death
['respawn_at_hospital'] = 'do you want to force respawn and spawn in the hospital?',
['yes'] = 'yes',
['no'] = 'no',
['please_wait'] = 'you are unconscious and will bleed out in ~b~%s minutes and %s seconds~s~',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.',
['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!',
-- Revive
['revive_help'] = 'revive a player',
-- Item
+4
View File
@@ -38,9 +38,13 @@ Locales['es'] = {
-- Death
['respawn_at_hospital'] = '¿Quieres ser transportado al hospital?',
['yes'] = 'oui',
['no'] = 'no',
['please_wait'] = 's\'por favor, espere ~b~%s minutos %s segundos para reparecer~s~',
['press_respawn'] = 'presione [~b~E~w~] para reparecer.',
['respawn_fine'] = 'you paid ~r~$%s~s~ for respawning.',
['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!',
-- Revive
['revive_help'] = 'reviver un jugador',
}
+4
View File
@@ -48,9 +48,13 @@ Locales['fr'] = {
-- Death
['respawn_at_hospital'] = 'voulez-vous être transporté à l\'hôpital ?',
['yes'] = 'oui',
['no'] = 'no',
['please_wait'] = 'Vous serez automatiquement transporté à l\'hôpital dans ~b~%s minutes %s secondes~s~',
['press_respawn'] = 'appuyez sur [~b~E~w~] pour réapparaître.',
['respawn_fine'] = 'vous avez payer ~r~$%s~s~ pour réapparaître.',
['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!',
-- Revive
['revive_help'] = 'relancer un joueur',
-- Item
+6 -2
View File
@@ -47,10 +47,14 @@ Locales['sv'] = {
['alert_ambulance'] = 'Ring ambulansen',
-- Death
['respawn_at_hospital'] = 'Vill du snabbresa till sjukhuset?',
['yes'] = 'Ja!',
['yes'] = 'ja',
['no'] = 'nej',
['please_wait'] = 'du är medvetslös och kommer att dö om ~b~%s minuter och %s sekunder~s~',
['press_respawn'] = 'Tryck [~b~E~w~] för att respawna.',
['press_respawn'] = 'tryck [~b~E~w~] för att respawna.',
['respawn_fine'] = 'du betalade ~r~$%s~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!',
-- Revive
['revive_help'] = 'Återuppliva en spelare',
-- Item