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
+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()