Jump to content

[HELP] Getting Targets on Perspective


#MacTavish

Recommended Posts

hi all, i created a script that works for shooting other vehicles with heatseeking rockets by Hunter Helicopter. But i can shoot other vehicles if they are on my screen, so i can shoot other vehicles even they are behind of hunter helicopter and this is unrealistic. I want to make it realistic, so, i want to shoot other vehicles if they are only on Helicopters' perspective even when i don't look at them, here is the script, please help ; 

function shootProjectile()
    local vehicle = getPedOccupiedVehicle(localPlayer)
	if vehicle and getElementModel(vehicle) == 425 then
		local x, y, z = getElementPosition(getLocalPlayer())
		local vehicles = getElementsWithinRange(x, y, z, 300, "vehicle")
    	local target = vehicles[1] ~= vehicle and vehicles[1] or vehicles[2]
		
		if target and isElementOnScreen(target) then
			createProjectile(vehicle, 20, x, y, z, 1, target)
		end
	end
end
bindKey( "lshift", "down", shootProjectile)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...