Implemented dead player blips, closes #46 (read desc)

- Fixed vehicles in vehicle shop not unloading
- Use busy spinner instead of drawing when loading vehicles
This commit is contained in:
ElPumpo
2020-01-19 17:14:33 +01:00
parent ecb553f23c
commit 6f8587b391
11 changed files with 102 additions and 64 deletions
+51 -27
View File
@@ -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)
+9 -21
View File
@@ -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