HustraDev Posted July 30, 2015 Share Posted July 30, 2015 Hi Guys, I Want to create Mounted Minigun like the one on this video So Please I need some Help somebody give me functions i well be grateful Tnx Link to comment
MisterQuestions Posted July 30, 2015 Share Posted July 30, 2015 Well i think you shout use this ones... createWeapon attachElements Link to comment
HustraDev Posted July 30, 2015 Author Share Posted July 30, 2015 ok man but how about rotate the gun ?~ i mean i need the gun to move around and aim like the one on the video i tried very hard and i made this local x,y,z = getElementPosition(localPlayer) local gunCol = createColSphere ( x, y, z, 2 ) local vehicle = getPedOccupiedVehicle (localPlayer) local x2,y2,z2 = getElementPosition(vehicle) local screenW,screenH = guiGetScreenSize() local weapon function attach ( ) local detection = isElementWithinColShape ( localPlayer, gunCol ) if detection then weapon = createWeapon("minigun", x2, y2, z2+2) attachElements ( weapon, vehicle, 0, -1.5, 0.7 ) setWeaponClipAmmo(weapon, 99999) -- setWeaponState(weapon, "firing") setWeaponProperty(weapon, "fire_rotation", 0, -30, 0) --setElementPosition ( localPlayer, x2, y2-1.5, z2+2 ) attachElements ( localPlayer, weapon, 0, 0, 0 ) setElementRotation(weapon,0,0,180) setPedRotation(localPlayer,90 ) setPedAnimation( localPlayer, "WEAPONS", "SHP_Tray_Pose",0,false) setWeaponOwner(weapon,localPlayer) end end addCommandHandler ( "attach", attach ) local aimSensitivity = 30; function rotateGun_Handler(cX, cY, aX, aY, wX, wY, wZ) local oX, oY, oZ, oRX, oRY, oRZ = getElementAttachedOffsets(weapon); --if (oRX-((cY-0.5)*aimSensitivity) > 45 or oRX-((cY-0.5)*aimSensitivity) < 30) then -- Pitch Restriction --oRX = oRX-((cY-0.5)*aimSensitivity); --end if (oRZ-((cX-0.5)*aimSensitivity) > 30 or oRZ-((cX-0.5)*aimSensitivity) < 50) then -- Yaw Restriction oRZ = oRZ-((cX-0.5)*aimSensitivity); end setCameraTarget(localPlayer,localPlayer) setElementAttachedOffsets(weapon, oX, oY, oZ, oRX, oRY, oRZ); setCursorPosition(screenW/2, screenH/2); end addEventHandler( "onClientCursorMove", getRootElement( ), rotateGun_Handler) addEventHandler("onClientRender", root, function() local _,_,rZ = getElementRotation(weapon) setElementRotation(localPlayer, 0, 0, rZ-10) end ) function fireme() setTimer(function() if getWeaponState(weapon) == "ready" then setWeaponState(weapon, "firing") else return end end,1000,0) end bindKey("mouse1", "down",fireme) the problem in the code i posted is that when ped mount the gun the gun rotate so slow and the gun not match with the ped in rotation ! please anybody help me Link to comment
GTX Posted July 30, 2015 Share Posted July 30, 2015 If you made that, you would know how to make gun rotate faster. You even made a variable. Therefore, I doubt this is your script. local x,y,z = getElementPosition(localPlayer) local gunCol = createColSphere ( x, y, z, 2 ) local vehicle = getPedOccupiedVehicle (localPlayer) local x2,y2,z2 = getElementPosition(vehicle) local screenW,screenH = guiGetScreenSize() local weapon function attach ( ) local detection = isElementWithinColShape ( localPlayer, gunCol ) if detection then weapon = createWeapon("minigun", x2, y2, z2+2) attachElements ( weapon, vehicle, 0, -1.5, 0.7 ) setWeaponClipAmmo(weapon, 99999) -- setWeaponState(weapon, "firing") setWeaponProperty(weapon, "fire_rotation", 0, -30, 0) --setElementPosition ( localPlayer, x2, y2-1.5, z2+2 ) attachElements ( localPlayer, weapon, 0, 0, 0 ) setElementRotation(weapon,0,0,180) setPedRotation(localPlayer,90 ) setPedAnimation( localPlayer, "WEAPONS", "SHP_Tray_Pose",0,false) setWeaponOwner(weapon,localPlayer) end end addCommandHandler ( "attach", attach ) local aimSensitivity = 330; function rotateGun_Handler(cX, cY, aX, aY, wX, wY, wZ) local oX, oY, oZ, oRX, oRY, oRZ = getElementAttachedOffsets(weapon); --if (oRX-((cY-0.5)*aimSensitivity) > 45 or oRX-((cY-0.5)*aimSensitivity) < 30) then -- Pitch Restriction --oRX = oRX-((cY-0.5)*aimSensitivity); --end if (oRZ-((cX-0.5)*aimSensitivity) > 30 or oRZ-((cX-0.5)*aimSensitivity) < 50) then -- Yaw Restriction oRZ = oRZ-((cX-0.5)*aimSensitivity); end setCameraTarget(localPlayer,localPlayer) setElementAttachedOffsets(weapon, oX, oY, oZ, oRX, oRY, oRZ); setCursorPosition(screenW/2, screenH/2); end addEventHandler( "onClientCursorMove", getRootElement( ), rotateGun_Handler) addEventHandler("onClientRender", root, function() local _,_,rZ = getElementRotation(weapon) setElementRotation(localPlayer, 0, 0, rZ-10) end ) function fireme() setTimer(function() if getWeaponState(weapon) == "ready" then setWeaponState(weapon, "firing") else return end end,1000,0) end bindKey("mouse1", "down",fireme) Link to comment
HustraDev Posted July 30, 2015 Author Share Posted July 30, 2015 GTX thanks man, the aiming now works 100% but it seem that the rotation of the ped and weapon different i want the weapon to be Completely in front of the ped And thanks Very very much Link to comment
GTX Posted July 30, 2015 Share Posted July 30, 2015 Stop bumping after 30 minutes. local x,y,z = getElementPosition(localPlayer) local gunCol = createColSphere ( x, y, z, 2 ) local vehicle = getPedOccupiedVehicle (localPlayer) local x2,y2,z2 = getElementPosition(vehicle) local screenW,screenH = guiGetScreenSize() local weapon function attach ( ) local detection = isElementWithinColShape ( localPlayer, gunCol ) if detection then weapon = createWeapon("minigun", x2, y2, z2+2) attachElements ( weapon, vehicle, 0, -1.5, 0.7 ) setWeaponClipAmmo(weapon, 99999) -- setWeaponState(weapon, "firing") setWeaponProperty(weapon, "fire_rotation", 0, -30, 0) --setElementPosition ( localPlayer, x2, y2-1.5, z2+2 ) attachElements ( localPlayer, weapon, 0, 0, 0 ) setElementRotation(weapon,0,0,180) setPedRotation(localPlayer,90 ) setPedAnimation( localPlayer, "WEAPONS", "SHP_Tray_Pose",0,false) setWeaponOwner(weapon,localPlayer) end end addCommandHandler ( "attach", attach ) local aimSensitivity = 330; function rotateGun_Handler(cX, cY, aX, aY, wX, wY, wZ) local oX, oY, oZ, oRX, oRY, oRZ = getElementAttachedOffsets(weapon); --if (oRX-((cY-0.5)*aimSensitivity) > 45 or oRX-((cY-0.5)*aimSensitivity) < 30) then -- Pitch Restriction --oRX = oRX-((cY-0.5)*aimSensitivity); --end if (oRZ-((cX-0.5)*aimSensitivity) > 30 or oRZ-((cX-0.5)*aimSensitivity) < 50) then -- Yaw Restriction oRZ = oRZ-((cX-0.5)*aimSensitivity); end setCameraTarget(localPlayer,localPlayer) setElementAttachedOffsets(weapon, oX, oY, oZ, oRX, oRY, oRZ); setCursorPosition(screenW/2, screenH/2); end addEventHandler( "onClientCursorMove", getRootElement( ), rotateGun_Handler) addEventHandler("onClientRender", root, function() local _,_,rZ = getElementRotation(weapon) setElementRotation(localPlayer, 0, 0, rZ) end ) function fireme() setTimer(function() if getWeaponState(weapon) == "ready" then setWeaponState(weapon, "firing") else return end end,1000,0) end bindKey("mouse1", "down",fireme) Link to comment
HustraDev Posted July 30, 2015 Author Share Posted July 30, 2015 same problem ! what changes you have made to the script !? sorry for bumping Link to comment
HustraDev Posted July 30, 2015 Author Share Posted July 30, 2015 Stop bumping after 30 minutes. local x,y,z = getElementPosition(localPlayer) local gunCol = createColSphere ( x, y, z, 2 ) local vehicle = getPedOccupiedVehicle (localPlayer) local x2,y2,z2 = getElementPosition(vehicle) local screenW,screenH = guiGetScreenSize() local weapon function attach ( ) local detection = isElementWithinColShape ( localPlayer, gunCol ) if detection then weapon = createWeapon("minigun", x2, y2, z2+2) attachElements ( weapon, vehicle, 0, -1.5, 0.7 ) setWeaponClipAmmo(weapon, 99999) -- setWeaponState(weapon, "firing") setWeaponProperty(weapon, "fire_rotation", 0, -30, 0) --setElementPosition ( localPlayer, x2, y2-1.5, z2+2 ) attachElements ( localPlayer, weapon, 0, 0, 0 ) setElementRotation(weapon,0,0,180) setPedRotation(localPlayer,90 ) setPedAnimation( localPlayer, "WEAPONS", "SHP_Tray_Pose",0,false) setWeaponOwner(weapon,localPlayer) end end addCommandHandler ( "attach", attach ) local aimSensitivity = 330; function rotateGun_Handler(cX, cY, aX, aY, wX, wY, wZ) local oX, oY, oZ, oRX, oRY, oRZ = getElementAttachedOffsets(weapon); --if (oRX-((cY-0.5)*aimSensitivity) > 45 or oRX-((cY-0.5)*aimSensitivity) < 30) then -- Pitch Restriction --oRX = oRX-((cY-0.5)*aimSensitivity); --end if (oRZ-((cX-0.5)*aimSensitivity) > 30 or oRZ-((cX-0.5)*aimSensitivity) < 50) then -- Yaw Restriction oRZ = oRZ-((cX-0.5)*aimSensitivity); end setCameraTarget(localPlayer,localPlayer) setElementAttachedOffsets(weapon, oX, oY, oZ, oRX, oRY, oRZ); setCursorPosition(screenW/2, screenH/2); end addEventHandler( "onClientCursorMove", getRootElement( ), rotateGun_Handler) addEventHandler("onClientRender", root, function() local _,_,rZ = getElementRotation(weapon) setElementRotation(localPlayer, 0, 0, rZ) end ) function fireme() setTimer(function() if getWeaponState(weapon) == "ready" then setWeaponState(weapon, "firing") else return end end,1000,0) end bindKey("mouse1", "down",fireme) i just now need the weapon to be Completely in front of the ped Link to comment
HustraDev Posted July 30, 2015 Author Share Posted July 30, 2015 Please Guys Almost Done With this script Help Me to Attach the weapon and player with the same rotation because i tried attachElements ( localPlayer,weapon, 0, -1.5, 0.7 , rx,ry,180) ---Here at RZ but the rotation not 180 and not the same rotation with the attached elements Link to comment
Dealman Posted July 31, 2015 Share Posted July 31, 2015 Please Guys Almost Done With this script Help Me to Attach the weapon and player with the same rotation because i tried attachElements ( localPlayer,weapon, 0, -1.5, 0.7 , rx,ry,180) ---Here at RZ but the rotation not 180 and not the same rotation with the attached elements No idea what you're talking about, could you post a screenshot? Did you get my aiming script to work? 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