Jump to content

help


WASSIm.

Recommended Posts

hi guys i have problem

  
addEventHandler ( "onClientVehicleEnter", root, 
    function(thePlayer, seat) 
        local theVehicle = source 
        if seat == 0 and thePlayer == localPlayer and  getElementModel(theVehicle) == 601 then 
         local x, y, z = getElementPosition ( theVehicle )  
         local rx, ry, rz = getElementRotation ( theVehicle )  
         local xt, yt = getVehicleTurretPosition (theVehicle)  
         minigunOne = createWeapon ( "minigun",  x,  y,  z ) 
         setElementAlpha (minigunOne,255) 
         xt = math.deg ( xt ) 
         yt = math.deg ( yt ) 
         setTimer ( function() 
         attachElements ( minigunOne, theVehicle, 0.15, 0, 1.3, 0, yt, xt + 90 ) 
         end, 500, 0 )   
         bindKey ( "mouse1", "down", enableFire )         
         bindKey ( "mouse1", "up", disableFire )     
        end 
    end) 
  
addEventHandler("onClientVehicleExit", root, 
    function(thePlayer, seat) 
        local theVehicle = source 
        if seat == 0 and thePlayer == localPlayer and getElementModel(theVehicle) == 601 then 
        if minigunOne then 
        destroyElement (minigunOne) 
         unbindKey ( "mouse1", "down", enableFire )       
         unbindKey ( "mouse1", "up", disableFire ) 
        end 
    end 
    end 
) 
 function enableFire() 
 if isTimer(MGtimer) and minigunOne then 
  killTimer(MGtimer) 
   else 
                    MGtimer = setTimer(function() setWeaponState ( minigunOne, "firing" ) end, 50, 1) 
    MiniSound = playSound3D("Pro_Minigun.wav", x, y, z, true)  
                        setSoundVolume(MiniSound, 1) 
                        setSoundSpeed ( MiniSound, 0.9 ) 
                        setSoundMaxDistance(MiniSound, 50) 
                            end 
                        end 
function disableFire() 
                     if isTimer(MGtimer) and minigunOne then 
                      killTimer(MGtimer) 
                       else 
                        MGtimer = setTimer(function() setWeaponState ( minigunOne, "ready" ) end, 50, 1) 
                            end 
                        end 

i have problem here:

  
         setTimer ( function() 
         attachElements ( minigunOne, theVehicle, 0.15, 0, 1.3, 0, yt, xt + 90 ) 
         end, 500, 0 ) 
  

Link to comment

Try this :

addEventHandler ( "onClientVehicleEnter", root, 
    function(thePlayer, seat) 
        local theVehicle = source 
        if seat == 0 and thePlayer == localPlayer and  getElementModel(theVehicle) == 601 then 
         local x, y, z = getElementPosition ( theVehicle ) 
         local rx, ry, rz = getElementRotation ( theVehicle ) 
         local xt, yt = getVehicleTurretPosition (theVehicle) 
         minigunOne = createWeapon ( "minigun",  x,  y,  z ) 
         setElementAlpha (minigunOne,255) 
         xt = math.deg ( xt ) 
         yt = math.deg ( yt ) 
         setTimer ( function() 
         if ( theVehicle and isElement(theVehicle) and minigunOne and isElement(minigunOne)  ) then 
         attachElements ( minigunOne, theVehicle, 0.15, 0, 1.3, 0, yt, xt + 90 ) 
         end 
         end, 500, 0 )  
         bindKey ( "mouse1", "down", enableFire )         
         bindKey ( "mouse1", "up", disableFire )    
        end 
    end) 
  
addEventHandler("onClientVehicleExit", root, 
    function(thePlayer, seat) 
        local theVehicle = source 
        if seat == 0 and thePlayer == localPlayer and getElementModel(theVehicle) == 601 then 
        if minigunOne then 
        destroyElement (minigunOne) 
         unbindKey ( "mouse1", "down", enableFire )       
         unbindKey ( "mouse1", "up", disableFire ) 
        end 
    end 
end 
) 
 function enableFire() 
    if isTimer(MGtimer) and minigunOne then 
        killTimer(MGtimer) 
 else 
       MGtimer = setTimer(function() setWeaponState ( minigunOne, "firing" ) end, 50, 1) 
       MiniSound = playSound3D("Pro_Minigun.wav", x, y, z, true) 
       setSoundVolume(MiniSound, 1) 
       setSoundSpeed ( MiniSound, 0.9 ) 
       setSoundMaxDistance(MiniSound, 50) 
    end 
end 
  
function disableFire() 
    if isTimer(MGtimer) and minigunOne then 
        killTimer(MGtimer) 
 else 
       MGtimer = setTimer(function() setWeaponState ( minigunOne, "firing" ) end, 50, 1) 
    end 
end 

Not tested ,

Link to comment

i fix attach but problem to xt. minigun its moving Versa

addEventHandler ( "onClientRender", root, 
function () 
    if minigunOne and getElementModel(theVehicle) == 601 then 
         local xt, yt = getVehicleTurretPosition (theVehicle) 
         xt = math.deg ( xt ) 
         yt = math.deg ( yt ) 
         attachElements ( minigunOne, theVehicle, 0.15, 0, 1.3, 0, yt, xt+90 ) 
         end 
    end 
) 

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