Jump to content

invisible guns


-misterX-

Recommended Posts

when i enter the car other players doesn't see the weapons and when i shot to someone i have no effect

addEventHandler("onClientVehicleEnter", root, 
    function(thePlayer, seat) 
        local theVehicle = source 
        if seat == 0 and thePlayer == localPlayer and  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, 0.7, 1, -0.1, 0, 0, 93)  
         attachElements ( minigunTwo, theVehicle, 0.55, 1, -0.1, 0, 0, 93 )    
      attachElements ( minigunOneF, theVehicle, 0.7, 1, 0.50, 0, 30, 93)  
       attachElements ( minigunTwoF, theVehicle, 0.55, 1, 0.50, 0, 30, 93 )   
         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) == 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() 
 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) 
   -- MiniSound = playSound ( "Pro_Minigun.wav",true) 
   -- setSoundVolume(MiniSound, 0.4) 
    --setSoundEffectEnabled(MiniSound,"gargle",true) 
    --setSoundSpeed ( MiniSound, 0.9 ) 
        end 
    end 
     
addEventHandler("onClientPlayerWasted", getLocalPlayer(), 
    function() 
        if minigunOne and minigunTwo then 
        destroyElement (minigunOne) 
        destroyElement (minigunTwo) 
         unbindKey ( "mouse1", "down", enableFire )       
         unbindKey ( "mouse1", "up", disableFire ) 
    end 
    end 
) 
     
function disableFire() 
 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) 
      stopSound ( MiniSound ) 
        end 
    end 
fileDelete("infernus.lua")   
  

Link to comment

What's so hard to understand? When you create a weapon, do this on every client, not just the one who entered the vehicle. That means, sync them manually. When the key is pressed, this information has to be synced too. The general ways to transfer the information between the server and client are element data and events:

setElementData 
getElementData 
  
addEvent 
addEventHandler 
triggerClientEvent 
triggerServerEvent 

Link to comment

minigun dont have effect

and delete this if you want see ...

    setElementAlpha ( minigunOne,0) 
      setElementAlpha ( minigunTwo,0) 

or change like that

    setElementAlpha ( minigunOne,255) 
      setElementAlpha ( minigunTwo,255) 
    setElementAlpha ( minigunOneF,255) 
      setElementAlpha ( minigunTwoF,255) 

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