Jump to content

SWAT turret


5150

Recommended Posts

Its Possible To Make It But Theres A Problem When S.W.A.T Shoots Theres Water And It Can't Be Stop!

how can i turn this

function shootProjectile() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    -- Only create projectile if we are inside a vehicle 
    if(vehicle)then 
        local x, y, z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z) 
    end 
end 
  
bindKey("vehicle_fire", "down", shootProjectile) 

into only SWAT though?

Link to comment

Its Possible To Make It But Theres A Problem When S.W.A.T Shoots Theres Water And It Can't Be Stop!

how can i turn this

function shootProjectile() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    -- Only create projectile if we are inside a vehicle 
    if(vehicle)then 
        local x, y, z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z) 
    end 
end 
  
bindKey("vehicle_fire", "down", shootProjectile) 

into only SWAT though?

function shootProjectile() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    -- Only create projectile if we are inside a vehicle 
    if(vehicle)then 
        if getVehicleModelFromName(vehicle) == 601 then 
            local x, y, z = getElementPosition(vehicle) 
            createProjectile(vehicle, 19, x, y, z) 
        end 
    end 
end 
  
bindKey("vehicle_fire", "down", shootProjectile) 

Link to comment
  function shootProjectile() 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        -- Only create projectile if we are inside a vehicle 
        if(vehicle)then 
            if getVehicleModelFromName(vehicle) == 601 then 
                local x, y, z = getElementPosition(vehicle) 
                createProjectile(vehicle, 19, x, y, z) 
            end 
        end 
    end 
      
  
  
function swatEnter ( thePlayer, seat ) 
    if getElementModel ( source ) == 'Put swat tank id here' then 
    bindKey("mouse1", "down", shootProjectile) 
    toggleControl ( "vehicle_fire", false ) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), swatEnter )  
  
  
  
function swatExit ( thePlayer, seat ) 
    if getElementModel ( source ) == 'Put swat tank id here' then 
    unbindKey("mouse1", "down", shootProjectile) 
    toggleControl ( "vehicle_fire", true ) 
    end 
end 
addEventHandler ( "onVehicleExit", getRootElement(), swatExit )) 

-- Not tested --

Link to comment
  • 2 weeks later...

i built upon CodyL's code:

function shootProjectile() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
        -- Only create projectile if we are inside a SWAT 
    if(vehicle) and getVehicleModel(vehicle) == 601 then 
    local x, y, z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z+1.7) 
    end 
end 
  
function toggleDemControls(bool) 
    toggleControl ( "vehicle_fire", bool ) 
    toggleControl ( "vehicle_secondary_fire", bool) 
end 
  
function swatEnter (player) 
    if player ~= localPlayer then return end 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if getElementModel (vehicle) == 601 then 
        toggleDemControls(false) 
        bindKey("vehicle_fire", "down", shootProjectile) 
        bindKey("vehicle_secondary_fire", "down", shootProjectile) 
    end 
end 
addEventHandler ( "onClientVehicleEnter", root, swatEnter )  
  
-- enable vehicle fire when player exits the SWAT, or when he dies 
-- so he can use hunter or anything else. 
  
function enableVehicleFireIfDead () 
    if source ~= localPlayer then return end 
    toggleDemControls(true) 
end 
  
function swatExit (player) 
    if player ~= localPlayer then return end 
    toggleDemControls(true) 
end 
addEventHandler ( "onClientVehicleExit", root, swatExit ) 
addEventHandler ( "onClientPlayerWasted", root, enableVehicleFireIfDead ) 
  

if you could make the rocket rotation change with the camera that would be a bonus.

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...