Police ability to revive without /revive [esx_policejob]


#1

I have been trying to get police ability to revive people without /revive command, just like medics revive people on esx_ambulancejob. I have tried to copy parts of the esx_ambulancejob into my esx_policejob but it just doesnt work at all and breaks esx_policejob.

So i would appreciate any help with getting police ability to revive to work.


#2

I found this on github in a “snippets” resource, most of which doesn’t seem to work. I converted it to police job. you can try it and see if it works.

--[[
----------------------------------------------------------------------------
____________________________________________________________________________
						
						AUTHOR : Jager Bom

			Autoriser /revive pour les médics si aucun admin en ville 
			Allow /revive if no admin online

						
____________________________________________________________________________
						
---------------------------------------------------------------------------
]]--


TriggerEvent('es:addGroupCommand', 'revivea', 'user', function(source, args, user)
    local source = source
    local admin = 0
    local xPlayers = ESX.GetPlayers()
    for i=1, #xPlayers, 1 do
        local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
        if xPlayer.group == 'admin'  then
            admin = admin + 1
        end
    end

if(admin >= 1)then
  if args[2] ~= nil then
    TriggerClientEvent('esx_policejob:revive', tonumber(args[2]))
  else
    TriggerClientEvent('esx_policejob:revive', source)
  end
  end

end, function(source, args, user)
  TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "There are already admins on the server.")
end, {help = _U('revive_help'), params = {{name = 'id'}}})

#3

Thanks but i dont want revive via /revive command, i’d like to get it in police jobmenu just like in ambulancejob


#4

Then you should be asking in the thread of the policejob.


#6

I added the ability to revive people from the police menu.

Requires esx_ambulance job obviously

Add this to your police menu in the client main.lua

			  {label = _U('revive player'),       value = 'revive'},

Remember if it is at the end of this list you need to remove the comma.

Then add this

if data2.current.value == 'revive' then	
              local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
	          local closestPlayerPed = GetPlayerPed(closestPlayer)
              local health = GetEntityHealth(closestPlayerPed)
				if health == 0 then
				local playerPed = GetPlayerPed(-1)
				Citizen.CreateThread(function()
						  ESX.ShowNotification(_U('revive_inprogress'))
						  TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true)
						  Wait(10000)
						  ClearPedTasks(playerPed)
						  if GetEntityHealth(closestPlayerPed) == 0 then
							TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer))
							ESX.ShowNotification(_U('revive_complete'))
						  else
							ESX.ShowNotification(_U('isdead'))
						  end
						end)
				end
			  end

ABOVE your police menus if thens…

if data2.current.value == 'identity_card' then
    OpenIdentityCardMenu(player)
end

NEXT

Add this to your server main.lua

RegisterServerEvent('esx_ambulancejob:revive')
AddEventHandler('esx_ambulancejob:revive', function(target)
  TriggerClientEvent('esx_ambulancejob:revive', target)
end)

LASTLY

Add these to your locales.lua

['revive player'] = 'revive player',
['revive_inprogress'] = 'revive in progress',
['revive_complete'] = 'revive complete',
['isdead'] = 'Player Dead',

Police revive
[Release][ESX] [EMS/Ambulance Job]
[Release] [ESX] [Police Job]
#7

Can you do ready script


#8

Extremely helpful and well laid out tutorial. Thanks!


#9

This is the updated version for the most current esx_police job as of 7/26/18

Requires esx_ambulance job obviously

Add this to your police menu in the client main.lua

			  {label = _U('revive player'),       value = 'revive'},

Remember if it is at the end of this list you need to remove the comma.

Then add this

if action == 'revive' then
	local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
	local closestPlayerPed = GetPlayerPed(closestPlayer)
	local health = GetEntityHealth(closestPlayerPed)
	if health == 0 then
	    local playerPed = GetPlayerPed(-1)
	    Citizen.CreateThread(function()
		   ESX.ShowNotification(_U('revive_inprogress'))
		   TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true)
		   Wait(10000)
		   ClearPedTasks(playerPed)
		   if GetEntityHealth(closestPlayerPed) == 0 then
			   TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer))
			   ESX.ShowNotification(_U('revive_complete'))
		   else
			ESX.ShowNotification(_U('isdead'))
		   end
		end)
     end
elseif action == 'identity_card' then
    OpenIdentityCardMenu(closestPlayer)
elseif action == 'body_search' then
    TriggerServerEvent('esx_policejob:message', GetPlayerServerId(closestPlayer), _U('being_searched'))
elseif.... 

It should look like this after.

local action = data2.current.value
					
if action == 'revive' then
	local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
	local closestPlayerPed = GetPlayerPed(closestPlayer)
	local health = GetEntityHealth(closestPlayerPed)
	if health == 0 then
		local playerPed = GetPlayerPed(-1)
		Citizen.CreateThread(function()
			ESX.ShowNotification(_U('revive_inprogress'))
			TaskStartScenarioInPlace(playerPed, 'CODE_HUMAN_MEDIC_TEND_TO_DEAD', 0, true)
			Wait(10000)
			ClearPedTasks(playerPed)
			if GetEntityHealth(closestPlayerPed) == 0 then
				TriggerServerEvent('esx_ambulancejob:revive', GetPlayerServerId(closestPlayer))
				ESX.ShowNotification(_U('revive_complete'))
				     else
					  ESX.ShowNotification(_U('isdead'))
				     end
			end)
	 end
elseif action == 'identity_card' then
	OpenIdentityCardMenu(closestPlayer)
elseif action == 'body_search' then
	TriggerServerEvent('esx_policejob:message', GetPlayerServerId(closestPlayer), _U('being_searched'))
	OpenBodySearchMenu(closestPlayer)
elseif action == 'handcuff' then
	TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))
elseif action == 'drag' then
	TriggerServerEvent('esx_policejob:drag', GetPlayerServerId(closestPlayer))
elseif action == 'put_in_vehicle' then
	TriggerServerEvent('esx_policejob:putInVehicle', GetPlayerServerId(closestPlayer))
elseif action == 'out_the_vehicle' then
	TriggerServerEvent('esx_policejob:OutVehicle', GetPlayerServerId(closestPlayer))
elseif action == 'fine' then
	OpenFineMenu(closestPlayer)
elseif action == 'license' then
	ShowPlayerLicense(closestPlayer)
elseif action == 'unpaid_bills' then
	OpenUnpaidBillsMenu(closestPlayer)
end

NEXT

Add this to your server main.lua

RegisterServerEvent('esx_ambulancejob:revive')
AddEventHandler('esx_ambulancejob:revive', function(target)
  TriggerClientEvent('esx_ambulancejob:revive', target)
end)

LASTLY

Add these to your locales.lua

--Revive
['revive player'] = 'revive player',
['revive_inprogress'] = 'revive in progress',
['revive_complete'] = 'revive complete',
['isdead'] = 'Player Dead',

Police revive
#10

Not working, when I added it it’s not worked and I tried put it in the end of the script and nothing worked it didn’t displayed any Error message or anything. I can’t even open F6. Can you please send me the full script?