Jump to content

projectile script


Xwad

Recommended Posts

Hi i made a script that makes possible when i press alt in the helicopter the it will shoot a rocket but its not working:/

  
function shootProjectile() 
     local vehicle = getPedOccupiedVehicle(localPlayer) 
     if getElementModel(source) == 497 then 
        local vX, vY, vZ = getElementPosition(source) 
        createProjectile(vehicle, 19, x, y, z) 
    end 
end 
  
bindKey("alt", "down", shootProjectile) 
setTimer ( shootProjectile, 1000, 1, "Reloading" ) 
  

Link to comment

not working:(

  
function shootProjectile() 
     local vehicle = getPedOccupiedVehicle(localPlayer) 
     if getElementModel(vehicle) == 497 then 
        local x,y,z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z) 
    end 
end 
  
bindKey("alt", "down", shootProjectile) 
setTimer ( shootProjectile, 1000, 1, "Reloading" ) 
  

Link to comment
Add this line before bindKey
addCommandHandler("Reloading",shootProjectile) 

Though idk why u need timer

Why he need to use addCommanHandler() , he already use bindKey

Example:

function shootProjectile() 
     local vehicle = getPedOccupiedVehicle(localPlayer) 
     if getElementModel(vehicle) == 497 then 
        local x,y,z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z) 
    end 
end  
bindKey("lalt", "down", shootProjectile) 
bindKey("ralt", "down", shootProjectile) 

Link to comment
local reloadTime = 4000  -- in miliseconds 
  
function shootProjectile() 
     local vehicle = getPedOccupiedVehicle(localPlayer) 
     if vehicle then 
        if getElementModel(vehicle) == 497 then 
           if not getElementData(localPlayer,"shoot") then 
              local x,y,z = getElementPosition(vehicle) 
              createProjectile(vehicle, 19, x, y, z) 
              setElementData(localPlayer,"shoot",true) 
              local p = localPlayer 
              setTimer(function() 
                 setElementData(p,"shoot",false) 
              end,reloadTime,1) 
           end 
       end 
    end 
end 
bindKey("lalt", "down", shootProjectile) 

Link to comment
I want to set 4 sec time betwen the projectile shoots.
local antiSpamAds = {} 
  
function shootProjectile() 
     local vehicle = getPedOccupiedVehicle(localPlayer) 
     if vehicle then 
     if getElementModel(vehicle) == 497 then 
        if isTimer(antiSpamAds[localPlayer]) then return end 
        local x,y,z = getElementPosition(vehicle) 
        createProjectile(vehicle, 19, x, y, z) 
        antiSpamAds[localPlayer] = setTimer(function() end, 4000, 1) 
    end 
end 
end  
bindKey("lalt", "down", shootProjectile) 
bindKey("ralt", "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...