Death screen update, see description

The system has been changed, so that you will first enter a 'respawn available in x' timer, then after that a bleedout timer will appear.
This commit is contained in:
ElPumpo
2018-10-30 23:22:58 +01:00
parent 9189039cbc
commit 8f18c991b8
10 changed files with 166 additions and 131 deletions
+94 -73
View File
@@ -52,11 +52,7 @@ function OnPlayerDeath()
IsDead = true
TriggerServerEvent('esx_ambulancejob:setDeathStatus', 1)
if Config.ShowDeathTimer == true then
ShowDeathTimer()
end
StartRespawnTimer()
StartDeathTimer()
StartDistressSignal()
ClearPedTasksImmediately(PlayerPedId())
@@ -65,7 +61,7 @@ end
function StartDistressSignal()
Citizen.CreateThread(function()
local timer = Config.RespawnDelayAfterRPDeath
local timer = Config.BleedoutTimer
while timer > 0 and IsDead do
Citizen.Wait(2)
@@ -103,74 +99,113 @@ function SendDistressSignal()
})
end
function ShowDeathTimer()
local respawnTimer = Config.RespawnDelayAfterRPDeath
local allowRespawn = Config.RespawnDelayAfterRPDeath/2
local fineAmount = Config.EarlyRespawnFineAmount
local payFine = false
function DrawGenericTextThisFrame()
SetTextFont(4)
SetTextProportional(0)
SetTextScale(0.0, 0.5)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextCentre(true)
end
if Config.EarlyRespawn and Config.EarlyRespawnFine then
ESX.TriggerServerCallback('esx_ambulancejob:checkBalance', function(finePayable)
if finePayable then
payFine = true
else
payFine = false
end
function secondsToClock(seconds)
local seconds, hours, mins, secs = tonumber(seconds), 0, 0, 0
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))
return mins, secs
end
end
function StartDeathTimer()
local canPayFine = false
if Config.EarlyRespawnFine then
ESX.TriggerServerCallback('esx_ambulancejob:checkBalance', function(canPay)
canPayFine = canPay
end)
end
local earlySpawnTimer = ESX.Round(Config.EarlyRespawnTimer / 1000)
local bleedoutTimer = ESX.Round(Config.BleedoutTimer / 1000)
Citizen.CreateThread(function()
while respawnTimer > 0 and IsDead do
Citizen.Wait(0)
-- early respawn timer
while earlySpawnTimer > 0 and IsDead do
Citizen.Wait(1000)
raw_seconds = respawnTimer/1000
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)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
local text = _U('please_wait', minutes, seconds)
if Config.EarlyRespawn then
if not Config.EarlyRespawnFine and respawnTimer <= allowRespawn then
text = text .. _U('press_respawn')
elseif Config.EarlyRespawnFine and respawnTimer <= allowRespawn and payFine then
text = text .. _U('respawn_now_fine', fineAmount)
else
text = text
end
if earlySpawnTimer > 0 then
earlySpawnTimer = earlySpawnTimer - 1
end
end
-- bleedout timer
while bleedoutTimer > 0 and IsDead do
Citizen.Wait(1000)
if bleedoutTimer > 0 then
bleedoutTimer = bleedoutTimer - 1
end
end
end)
Citizen.CreateThread(function()
local text, timeHeld
-- early respawn timer
while earlySpawnTimer > 0 and IsDead do
Citizen.Wait(0)
text = _U('respawn_available_in', secondsToClock(earlySpawnTimer))
DrawGenericTextThisFrame()
SetTextCentre(true)
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(0.5, 0.8)
end
if Config.EarlyRespawn then
if not Config.EarlyRespawnFine then
if IsControlPressed(0, Keys['E']) then
RemoveItemsAfterRPDeath()
break
end
elseif Config.EarlyRespawnFine then
if respawnTimer <= allowRespawn and payFine then
if IsControlPressed(0, Keys['E']) then
PayFine()
break
end
end
-- bleedout timer
while bleedoutTimer > 0 and IsDead do
Citizen.Wait(0)
text = _U('respawn_bleedout_in', secondsToClock(bleedoutTimer))
if not Config.EarlyRespawnFine then
text = text .. _U('respawn_bleedout_prompt')
if IsControlPressed(0, Keys['E']) and timeHeld > 60 then
break
end
elseif Config.EarlyRespawnFine and canPayFine then
text = text .. _U('respawn_bleedout_fine', ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount))
if IsControlPressed(0, Keys['E']) and timeHeld > 60 then
TriggerServerEvent('esx_ambulancejob:payFine')
break
end
end
respawnTimer = respawnTimer - 15
if IsControlPressed(0, Keys['E']) then
timeHeld = timeHeld + 1
else
timeHeld = 0
end
DrawGenericTextThisFrame()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(0.5, 0.8)
end
RemoveItemsAfterRPDeath()
end)
end
@@ -196,12 +231,6 @@ function RemoveItemsAfterRPDeath()
end)
end
function PayFine()
ESX.TriggerServerCallback('esx_ambulancejob:payFine', function()
RemoveItemsAfterRPDeath()
end)
end
function RespawnPed(ped, coords)
SetEntityCoordsNoOffset(ped, coords.x, coords.y, coords.z, false, false, false, true)
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, coords.heading, true, false)
@@ -212,14 +241,6 @@ function RespawnPed(ped, coords)
ESX.UI.Menu.CloseAll()
end
function StartRespawnTimer()
Citizen.SetTimeout(Config.RespawnDelayAfterRPDeath, function()
if IsDead then
RemoveItemsAfterRPDeath()
end
end)
end
function TeleportFadeEffect(entity, coords)
Citizen.CreateThread(function()
DoScreenFadeOut(800)
+12 -17
View File
@@ -11,31 +11,26 @@ Config.Locale = 'fr'
local second = 1000
local minute = 60 * second
-- How much time before auto respawn at hospital
Config.RespawnDelayAfterRPDeath = 10 * minute
Config.EarlyRespawnTimer = 2 * minute -- Time til respawn is available
Config.BleedoutTimer = 10 * minute -- Time til the player bleeds out
Config.EnablePlayerManagement = false
Config.EnableSocietyOwnedVehicles = false
Config.EnablePlayerManagement = false
Config.EnableSocietyOwnedVehicles = false
Config.RemoveWeaponsAfterRPDeath = true
Config.RemoveCashAfterRPDeath = true
Config.RemoveItemsAfterRPDeath = true
Config.RemoveWeaponsAfterRPDeath = true
Config.RemoveCashAfterRPDeath = true
Config.RemoveItemsAfterRPDeath = true
-- Will display a timer that shows RespawnDelayAfterRPDeath as a countdown
Config.ShowDeathTimer = true
-- Will allow respawn after half of RespawnDelayAfterRPDeath has elapsed.
Config.EarlyRespawn = false
-- The player will be fined for respawning early (on bank account)
Config.EarlyRespawnFine = false
Config.EarlyRespawnFineAmount = 500
-- Let the player pay for respawning early, if he can afford it.
Config.EarlyRespawnFine = false
Config.EarlyRespawnFineAmount = 5000
Config.Blip = {
Pos = { x = 307.76, y = -1433.47, z = 28.97 },
Sprite = 61,
Display = 4,
Scale = 1.2,
Colour = 2,
Colour = 2
}
Config.HelicopterSpawner = {
@@ -43,7 +38,7 @@ Config.HelicopterSpawner = {
Heading = 0.0
}
-- https://wiki.fivem.net/wiki/Vehicles
-- https://wiki.rage.mp/index.php?title=Vehicles
Config.AuthorizedVehicles = {
{
+5 -4
View File
@@ -44,10 +44,11 @@ Locales['br'] = {
-- Phone
['alert_ambulance'] = 'Alerta Socorro',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
+9 -8
View File
@@ -2,7 +2,7 @@ Locales['en'] = {
-- Cloakroom
['cloakroom'] = 'locker Room',
['ems_clothes_civil'] = 'civilian Clothes',
['ems_clothes_ems'] = 'eMS Clothes',
['ems_clothes_ems'] = 'EMS Clothes',
-- Vehicles
['veh_menu'] = 'vehicle',
['veh_spawn'] = 'press ~INPUT_CONTEXT~ to get a Vehicle or Helicopter',
@@ -35,7 +35,7 @@ Locales['en'] = {
['bandage'] = 'bandage',
['max_item'] = 'You are already carrying enough on yourself.',
-- F6 Menu
['ems_menu'] = 'eMS Menu',
['ems_menu'] = 'EMS Menu',
['ems_menu_title'] = 'ambulance - EMS Menu',
['ems_menu_revive'] = 'revive Player',
['ems_menu_putincar'] = 'put in Vehicle',
@@ -44,10 +44,11 @@ Locales['en'] = {
-- Phone
['alert_ambulance'] = 'alert Ambulance',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
@@ -56,7 +57,7 @@ Locales['en'] = {
-- Item
['used_medikit'] = 'You have used ~y~1x~s~ medikit',
['used_bandage'] = 'You have used ~y~1x~s~ bandage',
['not_enough_medikit'] = 'You do not have ~b~medikit~w~.',
['not_enough_bandage'] = 'You do not have ~b~bandage~w~.',
['not_enough_medikit'] = 'You do not have ~b~medikit~s~.',
['not_enough_bandage'] = 'You do not have ~b~bandage~s~.',
['healed'] = 'you have been treated.',
}
+20 -4
View File
@@ -27,21 +27,37 @@ Locales['es'] = {
['open_menu'] = 'Presione ~INPUT_CONTEXT~ para abrir el menú',
['deposit_amount'] = 'cantidad de fianza depositada',
['money_withdraw'] = 'cantidad de fianza retirada',
['fast_travel'] = 'Press on ~INPUT_CONTEXT~ to fast travel.',
['open_pharmacy'] = 'Press on ~INPUT_CONTEXT~ to open the pharmacy.',
['pharmacy_menu_title'] = 'Pharmacy',
['pharmacy_take'] = 'Take',
['medikit'] = 'medikit',
['bandage'] = 'bandage',
['max_item'] = 'You are already carrying enough on yourself.',
-- F6 Menu
['ems_menu'] = 'ayuda ciudadana',
['ems_menu_title'] = 'ambulancia - Ayuda Ciudadana',
['ems_menu_revive'] = 'reanimar',
['ems_menu_putincar'] = 'meter en el vehículo',
['ems_menu_small'] = 'heal small wounds',
['ems_menu_big'] = 'treat serious injuries',
-- Phone
['alert_ambulance'] = 'Alerta de ambulancia',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
-- Revive
['revive_help'] = 'reviver un jugador',
-- Item
['used_medikit'] = 'You have used ~y~1x~s~ medikit',
['used_bandage'] = 'You have used ~y~1x~s~ bandage',
['not_enough_medikit'] = 'You do not have ~b~medikit~s~.',
['not_enough_bandage'] = 'You do not have ~b~bandage~s~.',
['healed'] = 'you have been treated.',
}
+5 -5
View File
@@ -44,10 +44,11 @@ Locales['fi'] = {
-- Phone
['alert_ambulance'] = 'hälyytys Ensihoidolle',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
@@ -59,5 +60,4 @@ Locales['fi'] = {
['not_enough_medikit'] = 'ei tarpeeksi ~b~ensiapupakkauksia~w~.',
['not_enough_bandage'] = 'ei tarpeeksi ~b~sideharsoja~w~.',
['healed'] = 'sinua parannettiin',
-- Misc
}
+5 -5
View File
@@ -44,10 +44,11 @@ Locales['fr'] = {
-- Phone
['alert_ambulance'] = 'alerte Ambulance',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
@@ -59,5 +60,4 @@ Locales['fr'] = {
['not_enough_medikit'] = 'vous n\'avez pas de ~b~kit de soin~w~.',
['not_enough_bandage'] = 'vous n\'avez pas de ~b~bandage~w~.',
['healed'] = 'vous avez été soigné.',
-- Misc
}
+5 -5
View File
@@ -44,10 +44,11 @@ Locales['pl'] = {
-- Phone
['alert_ambulance'] = 'wezwij ambulans',
-- Death
['please_wait'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['press_respawn'] = 'press [~b~E~w~] to respawn.',
['respawn_now_fine'] = 'respawn now for ~g~$%s ~w~[Press ~b~E~w~]',
['respawn_fine'] = 'you paid ~r~$%s~s~ to respawn.',
['respawn_available_in'] = 'respawn available in ~b~%s minutes %s seconds~s~',
['respawn_bleedout_in'] = 'you will bleed out in ~b~%s minutes %s seconds~s~\n',
['respawn_bleedout_prompt'] = 'hold [~b~E~s~] to respawn',
['respawn_bleedout_fine'] = 'hold [~b~E~s~] to respawn for ~g~$%s~s~',
['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!',
@@ -59,5 +60,4 @@ Locales['pl'] = {
['not_enough_medikit'] = 'nie posiadasz ~b~apteczki~w~.',
['not_enough_bandage'] = 'nie posiadasz ~b~bandaża~w~.',
['healed'] = 'zostałeś potraktowany',
-- Misc
}
+5 -5
View File
@@ -44,10 +44,11 @@ Locales['sv'] = {
-- Phone
['alert_ambulance'] = 'ambulanssamtal',
-- Death
['please_wait'] = 'du är medvetslös och kommer att dö om ~b~%s minuter och %s sekunder~s~\n',
['press_respawn'] = 'tryck [~b~E~s~] för att respawna.',
['respawn_now_fine'] = 'respawna nu för ~g~%s SEK~s~ [Tryck ~b~E~s~]',
['respawn_fine'] = 'du betalade ~r~%s SEK~s~ för att respawna.',
['respawn_available_in'] = 'respawn tillgänglig om ~b~%s:%s~s~',
['respawn_bleedout_in'] = 'du kommer att blöda ut om ~b~%s:%s~s~\n',
['respawn_bleedout_prompt'] = 'håll [~b~E~s~] för att respawna',
['respawn_bleedout_fine'] = 'håll [~b~E~s~] för att respawna, kostar ~g~$%s~s~',
['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!',
@@ -59,5 +60,4 @@ Locales['sv'] = {
['not_enough_medikit'] = 'du har inget ~b~Medecinkit~s~.',
['not_enough_bandage'] = 'du har inget ~b~Bandage~s~.',
['healed'] = 'dina skador har blivit behandlade.',
-- Misc
}
+6 -5
View File
@@ -71,7 +71,7 @@ ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(
cb()
end)
if Config.EarlyRespawn and Config.EarlyRespawnFine then
if Config.EarlyRespawnFine then
ESX.RegisterServerCallback('esx_ambulancejob:checkBalance', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local bankBalance = xPlayer.getAccount('bank').money
@@ -79,12 +79,13 @@ if Config.EarlyRespawn and Config.EarlyRespawnFine then
cb(bankBalance >= Config.EarlyRespawnFineAmount)
end)
ESX.RegisterServerCallback('esx_ambulancejob:payFine', function(source, cb)
RegisterServerEvent('esx_ambulancejob:payFine')
AddEventHandler('esx_ambulancejob:payFine', function()
local xPlayer = ESX.GetPlayerFromId(source)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('respawn_fine', Config.EarlyRespawnFineAmount))
xPlayer.removeAccountMoney('bank', Config.EarlyRespawnFineAmount)
local fineAmount = Config.EarlyRespawnFineAmount
cb()
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('respawn_bleedout_fine_msg', ESX.Math.GroupDigits(fineAmount)))
xPlayer.removeAccountMoney('bank', fineAmount)
end)
end