Added ability to find an invisible dead player

https://github.com/ESX-Org/esx_ambulancejob/issues/20
This commit is contained in:
Alex Garcio
2020-02-13 16:44:14 -05:00
parent 783a5eeae2
commit e8e3eaa4d1
11 changed files with 54 additions and 3 deletions
+5 -2
View File
@@ -46,13 +46,16 @@ function OpenMobileAmbulanceActionsMenu()
{label = _U('ems_menu_revive'), value = 'revive'},
{label = _U('ems_menu_small'), value = 'small'},
{label = _U('ems_menu_big'), value = 'big'},
{label = _U('ems_menu_putincar'), value = 'put_in_vehicle'}
{label = _U('ems_menu_putincar'), value = 'put_in_vehicle'},
{label = _U('ems_menu_search'), value = 'search'}
}}, function(data, menu)
if isBusy then return end
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer == -1 or closestDistance > 1.0 then
if data.current.value == 'search' then
TriggerServerEvent('esx_ambulancejob:svsearch')
elseif closestPlayer == -1 or closestDistance > 1.0 then
ESX.ShowNotification(_U('no_players'))
else
if data.current.value == 'revive' then
+36 -1
View File
@@ -1,6 +1,6 @@
local firstSpawn, PlayerLoaded = true, false
isDead = false
isDead, isSearched, medic = false, false, 0
ESX = nil
Citizen.CreateThread(function()
@@ -81,6 +81,41 @@ Citizen.CreateThread(function()
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if isDead and isSearched then
local playerPed = PlayerPedId()
local ped = GetPlayerPed(GetPlayerFromServerId(medic))
isSearched = false
AttachEntityToEntity(playerPed, ped, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
Citizen.Wait(1000)
DetachEntity(playerPed, true, false)
ClearPedTasksImmediately(playerPed)
end
end
end)
RegisterNetEvent('esx_ambulancejob:clsearch')
AddEventHandler('esx_ambulancejob:clsearch', function(medicId)
local playerPed = PlayerPedId()
if isDead then
local coords = GetEntityCoords(playerPed)
local playersInArea = ESX.Game.GetPlayersInArea(coords, 50.0)
for i=1, #playersInArea, 1 do
local player = playersInArea[i]
if player == GetPlayerFromServerId(medicId) then
medic = tonumber(medicId)
isSearched = true
break
end
end
end
end)
function OnPlayerDeath()
isDead = true
ESX.UI.Menu.CloseAll()