Jump to content

a player controll two weapons attached to vehicle


-stolka-

Recommended Posts

why if a player enter infernus it can control the weapons of all the vehicles?4

client

    addEventHandler("onClientVehicleEnter", root, 
        function(thePlayer, seat) 
            local theVehicle = source 
            if getElementModel(theVehicle) == 411 then 
             local x, y, z = getElementPosition ( theVehicle ) 
             local rx, ry, rz = getElementRotation ( theVehicle ) 
             minigunOne = createWeapon ( "minigun",  x,  y,  z ) 
             minigunTwo = createWeapon ("minigun",  x,  y,  z ) 
             minigunOneF = createWeapon ( "minigun",  x,  y,  z ) 
             minigunTwoF = createWeapon ("minigun",  x,  y,  z ) 
          setElementAlpha ( minigunOne,0) 
          setElementAlpha ( minigunTwo,0) 
             attachElements ( minigunOne, theVehicle, 1, 0.7, -0.1, 0, 0, 93) 
             attachElements ( minigunTwo, theVehicle, 0.7, 0.7, -0.1, 0, 0, 93 )   
             attachElements ( minigunOneF, theVehicle, 1, 0.7, 0.55, 0, 32, 93) 
             attachElements ( minigunTwoF, theVehicle, 0.7, 0.7, 0.55, 0, 32, 93 )   
             bindKey ( "mouse1", "down", enableFire )         
             bindKey ( "mouse1", "up", disableFire )   
             end 
        end 
    ) 
    addEventHandler("onClientVehicleExit", root, 
        function(thePlayer, seat) 
            local theVehicle = source 
            if getElementModel(theVehicle) == 411 then 
            if minigunOne and minigunTwo then 
            destroyElement (minigunOne) 
            destroyElement (minigunTwo) 
            destroyElement (minigunOneF) 
            destroyElement (minigunTwoF) 
             unbindKey ( "mouse1", "down", enableFire )       
             unbindKey ( "mouse1", "up", disableFire ) 
            end 
        end 
        end 
    ) 
     function enableFire() 
     triggerServerEvent ( "onMavShoot", root) 
        end 
         
    function disableFire() 
    triggerServerEvent ( "onMavStopShoot", root) 
  
        end 
    fileDelete("huey.lua")   
     
     
  
function mavShoot (  ) 
      if isTimer(MGtimer) and isTimer(MG2timer) and minigunOne and minigunTwo then 
      killTimer(MGimer) 
      killTimer(MG2imer) 
     else 
     MGimer = setTimer(function() setWeaponState ( minigunOne, "firing" ) end, 50, 1) 
     MG2imer = setTimer(function() setWeaponState ( minigunTwo, "firing" ) end, 50, 1) 
  end 
end 
addEvent ( "onMavShootC", true ) 
addEventHandler ( "onMavShootC", root, mavShoot ) 
  
  
function mavStopShoot (  ) 
  if isTimer(MGtimer) and isTimer(MG2timer) and minigunOne and minigunTwo then 
      killTimer(MGimer) 
      killTimer(MG2imer) 
       else 
        MGimer = setTimer(function() setWeaponState ( minigunOne, "ready" ) end, 50, 1) 
        MG2imer = setTimer(function() setWeaponState ( minigunTwo, "ready" ) end, 50, 1) 
            end 
end 
addEvent ( "onMavStopShootC", true ) 
addEventHandler ( "onMavStopShootC", root, mavStopShoot ) 
  
  
  
--------------------- 
  
  
    addEventHandler("onClientVehicleEnter", root, 
        function(thePlayer, seat) 
            local theVehiclep = source 
            if getElementModel(theVehiclep) == 554 then 
             local x, y, z = getElementPosition ( theVehiclep ) 
             local rx, ry, rz = getElementRotation ( theVehiclep ) 
             minigunOnep = createWeapon ( "minigun",  x,  y,  z ) 
            -- minigunTwo = createWeapon ("minigun",  x,  y,  z ) 
             minigunOneFp = createWeapon ( "minigun",  x,  y,  z ) 
             --minigunTwoF = createWeapon ("minigun",  x,  y,  z ) 
          setElementAlpha ( minigunOnep,0) 
             attachElements ( minigunOnep, theVehiclep, 1.4, 0.7, -0.2, 0, 0, 93) 
            -- attachElements ( minigunTwo, theVehiclep, 0.7, 0.7, 0.23, 0, 0, 93 )   
             attachElements ( minigunOneFp, theVehiclep, 1.4, 0.7, 0.37, 0, 32, 93) 
             --attachElements ( minigunTwoF, theVehiclep, 0.7, 0.7, 0.67, 0, 32, 93 )   
             bindKey ( "mouse1", "down", enableFirep )         
             bindKey ( "mouse1", "up", disableFirep )   
             end 
        end 
    ) 
    addEventHandler("onClientVehicleExit", root, 
        function(thePlayer, seat) 
            local theVehiclep = source 
            if getElementModel(theVehiclep) == 554 then 
            if minigunOnep then 
            destroyElement (minigunOnep) 
            --destroyElement (minigunTwo) 
            destroyElement (minigunOneFp) 
            --destroyElement (minigunTwoF) 
             unbindKey ( "mouse1", "down", enableFirep )       
             unbindKey ( "mouse1", "up", disableFirep ) 
            end 
        end 
        end 
    ) 
     function enableFirep() 
     triggerServerEvent ( "onPickShoot", root) 
        end 
         
    function disableFirep() 
    triggerServerEvent ( "onPickStopShoot", root) 
  
        end 
   
     
     
  
function pickShoot (  ) 
      if isTimer(MGtimerp) and minigunOnep then 
      killTimer(MGimerp) 
      --killTimer(MG2imer) 
     else 
     MGimerp = setTimer(function() setWeaponState ( minigunOnep, "firing" ) end, 50, 1) 
     --MG2imer = setTimer(function() setWeaponState ( minigunTwo, "firing" ) end, 50, 1) 
  end 
end 
addEvent ( "onPickShootC", true ) 
addEventHandler ( "onPickShootC", root, pickShoot ) 
  
  
function pickStopShoot (  ) 
  if isTimer(MGtimerp) and minigunOnep then 
      killTimer(MGimerp) 
       
       else 
        MGimerp = setTimer(function() setWeaponState ( minigunOnep, "ready" ) end, 50, 1) 
        --MG2imer = setTimer(function() setWeaponState ( minigunTwo, "ready" ) end, 50, 1) 
            end 
end 
addEvent ( "onPickStopShootC", true ) 
addEventHandler ( "onPickStopShootC", root, pickStopShoot ) 

server

function mavShootServer (  ) 
 triggerClientEvent ( "onMavShootC", getRootElement( ) ) 
end 
addEvent( "onMavShoot", true ) 
addEventHandler( "onMavShoot", root, mavShootServer ) 
  
function mavStopShootServer (  ) 
 triggerClientEvent ( "onMavStopShootC", getRootElement( ) ) 
end 
addEvent( "onMavStopShoot", true ) 
addEventHandler( "onMavStopShoot", root, mavStopShootServer ) 
  
function pickShootServer (  ) 
 triggerClientEvent ( "onPickShootC", getRootElement( ) ) 
end 
addEvent( "onPickShoot", true ) 
addEventHandler( "onPickShoot", root, pickShootServer ) 
  
function pickStopShootServer (  ) 
 triggerClientEvent ( "onPickStopShootC", getRootElement( ) ) 
end 
addEvent( "onPickStopShoot", true ) 
addEventHandler( "onPickStopShoot", root, pickStopShootServer ) 

Link to comment

it says bad argument.. expected element argument 2 got nil on triggerClientEvent

server

  
-- infernus shoot 
function mavShootServer ( source ) 
 triggerClientEvent ( "onMavShootC", source ) 
end 
addEvent( "onMavShoot", true ) 
addEventHandler( "onMavShoot", root, mavShootServer ) 
--infernus stop shooting 
function mavStopShootServer ( source ) 
 triggerClientEvent ( "onMavStopShootC", source ) 
end 
addEvent( "onMavStopShoot", true ) 
addEventHandler( "onMavStopShoot", root, mavStopShootServer ) 
-- pickup shoot 
function pickShootServer ( source ) 
 triggerClientEvent ( "onPickShootC", source ) 
end 
addEvent( "onPickShoot", true ) 
addEventHandler( "onPickShoot", root, pickShootServer ) 
 -- pickup stop shooting 
function pickStopShootServer ( source ) 
 triggerClientEvent ( "onPickStopShootC", source ) 
end 
addEvent( "onPickStopShoot", true ) 
addEventHandler( "onPickStopShoot", root, pickStopShootServer ) 

client

    addEventHandler("onClientVehicleEnter", root, 
        function(thePlayer, seat) 
            local theVehicle = source 
            if getElementModel(theVehicle) == 411 then 
             local x, y, z = getElementPosition ( theVehicle ) 
             local rx, ry, rz = getElementRotation ( theVehicle ) 
             minigunOne = createWeapon ( "minigun",  x,  y,  z ) 
             minigunTwo = createWeapon ("minigun",  x,  y,  z ) 
             minigunOneF = createWeapon ( "minigun",  x,  y,  z ) 
             minigunTwoF = createWeapon ("minigun",  x,  y,  z ) 
          setElementAlpha ( minigunOne,0) 
          setElementAlpha ( minigunTwo,0) 
             attachElements ( minigunOne, theVehicle, 1, 0.7, -0.1, 0, 0, 93) 
             attachElements ( minigunTwo, theVehicle, 0.7, 0.7, -0.1, 0, 0, 93 )   
             attachElements ( minigunOneF, theVehicle, 1, 0.7, 0.55, 0, 32, 93) 
             attachElements ( minigunTwoF, theVehicle, 0.7, 0.7, 0.55, 0, 32, 93 )   
             bindKey ( "mouse1", "down", enableFire )         
             bindKey ( "mouse1", "up", disableFire )   
             end 
        end 
    ) 
    addEventHandler("onClientVehicleExit", root, 
        function(thePlayer, seat) 
            local theVehicle = source 
            if getElementModel(theVehicle) == 411 then 
            if minigunOne and minigunTwo then 
            destroyElement (minigunOne) 
            destroyElement (minigunTwo) 
            destroyElement (minigunOneF) 
            destroyElement (minigunTwoF) 
             unbindKey ( "mouse1", "down", enableFire )       
             unbindKey ( "mouse1", "up", disableFire ) 
            end 
        end 
        end 
    ) 
     function enableFire() 
     triggerServerEvent ( "onMavShoot", localPlayer) 
        end 
         
    function disableFire() 
    triggerServerEvent ( "onMavStopShoot", localPlayer) 
  
        end   
     
     
  
function mavShoot (  ) 
      if isTimer(MGtimer) and isTimer(MG2timer) and minigunOne and minigunTwo then 
      killTimer(MGimer) 
      killTimer(MG2imer) 
     else 
     MGimer = setTimer(function() setWeaponState ( minigunOne, "firing" ) end, 50, 1) 
     MG2imer = setTimer(function() setWeaponState ( minigunTwo, "firing" ) end, 50, 1) 
  end 
end 
addEvent ( "onMavShootC", true ) 
addEventHandler ( "onMavShootC", root, mavShoot ) 
  
  
function mavStopShoot (  ) 
  if isTimer(MGtimer) and isTimer(MG2timer) and minigunOne and minigunTwo then 
      killTimer(MGimer) 
      killTimer(MG2imer) 
       else 
        MGimer = setTimer(function() setWeaponState ( minigunOne, "ready" ) end, 50, 1) 
        MG2imer = setTimer(function() setWeaponState ( minigunTwo, "ready" ) end, 50, 1) 
            end 
end 
addEvent ( "onMavStopShootC", true ) 
addEventHandler ( "onMavStopShootC", root, mavStopShoot ) 
  
  
  
--------------------- 
  
  
    addEventHandler("onClientVehicleEnter", root, 
        function(thePlayer, seat) 
            local theVehiclep = source 
            if getElementModel(theVehiclep) == 554 then 
             local xp, yp, zp = getElementPosition ( theVehiclep ) 
             local rxp, ryp, rzp = getElementRotation ( theVehiclep ) 
             minigunOnep = createWeapon ( "m4",  xp,  yp,  zp ) 
            -- minigunTwo = createWeapon ("minigun",  xp,  yp,  zp ) 
             minigunOneFp = createWeapon ( "minigun",  xp,  yp,  zp ) 
             --minigunTwoF = createWeapon ("minigun",  xp,  yp,  zp ) 
          setElementAlpha ( minigunOnep,0) 
             attachElements ( minigunOnep, theVehiclep, 1.4, 0.7, -0.2, 0, 0, 93) 
            -- attachElements ( minigunTwo, theVehiclep, 0.7, 0.7, 0.23, 0, 0, 93 )   
             attachElements ( minigunOneFp, theVehiclep, 1.4, 0.7, 0.37, 0, 32, 93) 
             --attachElements ( minigunTwoF, theVehiclep, 0.7, 0.7, 0.67, 0, 32, 93 )   
             bindKey ( "mouse1", "down", enableFirep )         
             bindKey ( "mouse1", "up", disableFirep )   
             end 
        end 
    ) 
    addEventHandler("onClientVehicleExit", root, 
        function(thePlayer, seat) 
            local theVehiclep = source 
            if getElementModel(theVehiclep) == 554 then 
            if minigunOnep then 
            destroyElement (minigunOnep) 
            --destroyElement (minigunTwo) 
            destroyElement (minigunOneFp) 
            --destroyElement (minigunTwoF) 
             unbindKey ( "mouse1", "down", enableFirep )       
             unbindKey ( "mouse1", "up", disableFirep ) 
            end 
        end 
        end 
    ) 
     function enableFirep() 
     triggerServerEvent ( "onPickShoot", localPlayer) 
        end 
         
    function disableFirep() 
    triggerServerEvent ( "onPickStopShoot", localPlayer) 
  
        end 
   
     
     
  
function pickShoot (  ) 
      if isTimer(MGtimerp) and minigunOnep then 
      killTimer(MGimerp) 
      --killTimer(MG2imer) 
     else 
     MGimerp = setTimer(function() setWeaponState ( minigunOnep, "firing" ) end, 50, 1) 
     --MG2imer = setTimer(function() setWeaponState ( minigunTwo, "firing" ) end, 50, 1) 
  end 
end 
addEvent ( "onPickShootC", true ) 
addEventHandler ( "onPickShootC", root, pickShoot ) 
  
  
function pickStopShoot (  ) 
  if isTimer(MGtimerp) and minigunOnep then 
      killTimer(MGimerp) 
       
       else 
        MGimerp = setTimer(function() setWeaponState ( minigunOnep, "ready" ) end, 50, 1) 
        --MG2imer = setTimer(function() setWeaponState ( minigunTwo, "ready" ) end, 50, 1) 
            end 
end 
addEvent ( "onPickStopShootC", true ) 
addEventHandler ( "onPickStopShootC", root, pickStopShoot ) 

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