Jump to content

Vehicle Shot


RekZ

Recommended Posts

if there is a passengers in the swat , shot 2 rockets , how i can fixed ?

function Dhooter( )
    if isPedInVehicle ( localPlayer ) then
        local veh = getPedOccupiedVehicle ( localPlayer )
        if (veh) and getVehicleOccupant ( veh , 0 ) then
            if ( getElementModel ( veh ) == 601 ) then
                local X, Y, Z = getElementPosition(veh)
                createProjectile(veh, 19 , turX, turY, turZ, 0, nil, 0, 0, 0)
                --createExplosion(turX, turY, turZ , 8, false, 0.5, false)
            end
        end
    end
end

 

Link to comment
function Dhooter( )
    if isPedInVehicle ( localPlayer ) then
        local veh = getPedOccupiedVehicle ( localPlayer )
        if (veh) and getPedOccupiedVehicleSeat (localPlayer) == 0 then
            if ( getElementModel ( veh ) == 601 ) then
                local X, Y, Z = getElementPosition(veh)
                createProjectile(veh, 19 , turX, turY, turZ, 0, nil, 0, 0, 0)
                --createExplosion(turX, turY, turZ , 8, false, 0.5, false)
            end
        end
    end
end

 

Edited by Dimos7
Link to comment

I have the same problem , shoot 2 rockets whit passenger

 

12 minutes ago, Dimos7 said:

function Dhooter( )
    if isPedInVehicle ( localPlayer ) then
        local veh = getPedOccupiedVehicle ( localPlayer )
        if (veh) and getPedOccupiedVehicleSeat (localPlayer) == 0 then
            if ( getElementModel ( veh ) == 601 ) then
                local X, Y, Z = getElementPosition(veh)
                createProjectile(veh, 19 , turX, turY, turZ, 0, nil, 0, 0, 0)
                --createExplosion(turX, turY, turZ , 8, false, 0.5, false)
            end
        end
    end
end

 

 

Link to comment
function Dhooter( )
    if isPedInVehicle ( localPlayer ) then
        local veh = getPedOccupiedVehicle ( localPlayer )
       if getPedOccupiedVehicleSeat (localPlayer) == 0 then
            if ( getElementModel ( veh ) == 601 ) then
                local X, Y, Z = getElementPosition(veh)
                createProjectile(veh, 19 , turX, turY, turZ, 0, nil, 0, 0, 0)
                --createExplosion(turX, turY, turZ , 8, false, 0.5, false)
            end
        end
    end
end

 

Link to comment

If the problem still persists, and i understand right, is it possible that this is due a MTA bug? Wiki reports some issues 

Issue ID Description
#8132 Projectile target only allows player element (and a projectile?)
#5072 createProjectile creates one projectile for every person in the vehicle

 

If it's not due a bug, what happens if you temporary set as creator the localPlayer?

Link to comment

To @iPrestege

bindKey("w","down",  
    function ( ) 
local vehicle = getPedOccupiedVehicle ( localPlayer ); 
    if ( vehicle ) then 
    createProjectile(vehicle,19); 
    outputChatBox("Text "255,255,0,true); 
        else 
        outputChatBox("text",255,0,0,true); 
    end 
 end 
); 
  
addEventHandler("onClientResourceStart",resourceRoot, 
    function ( ) 
    setWorldSpecialPropertyEnabled ( "aircars",true ); 
end 
); 
  

If you want to SWAT team

Server !

	
	addEvent('check', true) 
addEventHandler('check', root, 
    function ( plr ) 
        if getElementData ( plr, "gang" ) == "SWAT" then 
                triggerClientEvent ("shoot", source) 
        end 
    end
) 

Client !

addEvent('shoot', true) 
addEventHandler('shoot', root, 
    function () 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        local rX,rY,rZ = getElementRotation(vehicle) 
        local x, y, z = getElementPosition(vehicle) 
        local x = x+4*math.cos(math.rad(rZ+90)) 
        local y = y+4*math.sin(math.rad(rZ+90)) 
        if ( vehicle ) then 
            createProjectile(vehicle, 19, x, y, z, 1.0, nil) 
        end 
    end) 

	
function shootProjectile() 
    triggerServerEvent("check", localPlayer, localPlayer) 
end 
bindKey("vehicle_fire", "down", shootProjectile) 
bindKey("lctrl", "down", shootProjectile) 
bindKey("rctrl", "down", shootProjectile) 

 

Edited by #_iMr,[E]coo
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...