Jump to content

help !!


Recommended Posts

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 :cry::cry::cry::cry:

Link to comment

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

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
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 :roll::roll:

Link to comment

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

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