Jump to content

getAttachedElements


Xwad

Recommended Posts

Hello. As you can see, in my script i attached 2 weapons to a vehicle. I set a bind for shooting one of the gun. My problem is that when i start the function called "fire_gun_c" then both of the weapons will be fired. So my question is how can i only shoot the weapon "gun1" by using getAttachedElements? 

 

 

client

function attach()
local gun1 = createWeapon(31, 0,0,0)
local gun2 = createWeapon(31, 0,0,0)

attachElements ( gun1, veh, 0, 1, 0)
attachElements ( gun1, veh, 0, -1, 0)
end



function fire_gun_c(veh)
local attachedElements = getAttachedElements(veh)
for ElementKey, ElementValue in ipairs ( attachedElements ) do
  
fireWeapon ( ElementValue ) -- it fires both of the guns because it gets all the data with getAttachedElements 
end
end
addEvent("fire_gun_c", true)
addEventHandler ( "fire_gun_c", resourceRoot, fire_gun_c)

 

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