pa3ck Posted October 16, 2013 Share Posted October 16, 2013 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
Castillo Posted October 16, 2013 Share Posted October 16, 2013 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
pa3ck Posted October 16, 2013 Author Share Posted October 16, 2013 (edited) 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 Edited October 16, 2013 by Guest Link to comment
Castillo Posted October 16, 2013 Share Posted October 16, 2013 Yeah, you can change the alpha to 0 using: setElementAlpha Link to comment
pa3ck Posted October 16, 2013 Author Share Posted October 16, 2013 You're my man! Thank you! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now