Jump to content

Shooting with S.W.A.T. vehicle


Xwad

Recommended Posts

do you mean this? becaouse this makes only possible to shoot rockets with minigun

-- This function gets triggered everytime player shoots.

function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)

if weapon == 38 then -- if source is a local player and he uses minigun...

x,y,z = getElementPosition(getLocalPlayer())

if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile...

outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message

end

end

end

-- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire.

addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)

Link to comment

i have convert the example. is it now good or i goind the bad way?xD

-- This function gets triggered everytime player shoots.

function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)

if vehicle == 601 then -- if source is a local player and he uses minigun...

x,y,z = getElementPosition(getLocalPlayer())

if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile...

outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message

end

end

end

-- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire.

addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)

Link to comment

he meant the vehicle is defined above ?? , it should be like this

  
function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) 
local vehicle = getPedOccupiedVehicle(localPlayer) 
if vehicle == 601 then -- if source is a local player and he uses minigun... 
x,y,z = getElementPosition(getLocalPlayer()) 
if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... 
outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message 
end 
end 
end 

Link to comment
function onSwatFire(key, keyState, vehicleFireType) 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    local vehModel = getElementModel(vehicle) 
    if vehModel == 601 then 
        if vehicleFireType == "primary" or vehicleFireType == "secondary" then -- your choice 
            local _,_,_,shootX, shootY, shootZ = getCameraMatrix() 
            local ped = createPed(0, shootX, shootY, shootZ) 
            local x,y,z = getElementPosition(vehicle) 
            createProjectile(vehicle--[[vehicle or localPlayer - Your choice]],19,x,y,z+1,200,ped) 
            if isElement(ped) then 
                destroyElement(ped) 
            end 
        end 
    end 
end 
bindKey("vehicle_fire", "down", onSwatFire, "primary") 
bindKey("vehicle_secondary_fire", "down", onSwatFire, "secondary") 

Try it.

(I do not test.)

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