Jump to content

Attaching minigun to a car.


pa3ck

Recommended Posts

I made this little code, but the minigun's fire is a bit weird. Its not shooting straight... Here's the pic of it:

http://s8.postimg.org/gdg1sstlv/gta_sa_ ... _00_34.png

The code is the following:

addEventHandler('onClientResourceStart', getResourceRootElement(getThisResource()), function() 
    local tp = getLocalPlayer() 
    local veh = getPedOccupiedVehicle(tp) 
    local vx, vy, vz = getElementPosition(veh) 
    local x, y, z = getElementPosition(tp) 
    local minigun1 = createWeapon('minigun', vx, vy, vz) 
    local minigun2 = createWeapon('minigun', vx, vy, vz) 
    attachElements(minigun1, veh, 0.8, 1.3, 0.7, 20, 30, 90) 
    attachElements(minigun2, veh, -0.57, 1.3, 0.7, 20, 30, 90) 
     
    function fire() 
        if getKeyState("num_6") == true then 
            fireWeapon(minigun1) 
        elseif getKeyState("num_4") == true then 
            fireWeapon(minigun2) 
        end 
    end 
    addEventHandler('onClientRender', getRootElement(), fire) 
     
end) 
  

Link to comment

The minigun created by createWeapon has a rotation problem, if you change it to be correctly in place, it'll fire in the wrong position.

What you could do is, create two weapons, one will be just visual, and the other will be the actual firing weapon.

P.S: You don't need to use fireWeapon every render, you can use setWeaponState.

Link to comment

Ohh, okay, thank you. Can I set one of them invisible ( actually the one that fires )? Is there any function for that? And I used onClientRender to check if the key is pressed down this was the simpliest solution I thought of :D

Edited by Guest
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...