Jump to content

projectile script


Xwad

Recommended Posts

Posted

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" ) 
  

Posted

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" ) 
  

Posted
Tahnks now its working with lalt:D but the timer is still not working.

i think you don't need setTimer here.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Add this line before bindKey

addCommandHandler("Reloading",shootProjectile) 

Though idk why u need timer

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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) 

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Walid, your code does exactly the same thing as mine.

Yeh i know sorry bro i didn't see your code :).

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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