-stolka- Posted October 12, 2013 Share Posted October 12, 2013 why people see the miniguns but dont they see them shooting? addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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.15, 2, -1.3, 0, 0, 93) attachElements ( minigunTwo, theVehicle, -1.15, 2, -1.3, 0, 0, 93 ) attachElements ( minigunOneF, theVehicle, 1.15, 2, -0.62, 0, 30, 93) attachElements ( minigunTwoF, theVehicle, -1.15, 2, -0.62, 0, 30, 93 ) bindKey ( "mouse1", "down", enableFire ) bindKey ( "mouse1", "up", disableFire ) end end ) addEventHandler("onClientVehicleExit", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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) 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) end end fileDelete("huey.lua") Link to comment
Castillo Posted October 12, 2013 Share Posted October 12, 2013 Because the state just changes on the client that fires it. Link to comment
-stolka- Posted October 12, 2013 Author Share Posted October 12, 2013 is it possible to make it serversided so the state change for everyone? Link to comment
Castillo Posted October 12, 2013 Share Posted October 12, 2013 The functions are all client sided, so you'll have to make some sort of sync. Link to comment
-stolka- Posted October 12, 2013 Author Share Posted October 12, 2013 how should i do that? Link to comment
myonlake Posted October 12, 2013 Share Posted October 12, 2013 Triggers? It's quite a basic thing to know of. Link to comment
-stolka- Posted October 12, 2013 Author Share Posted October 12, 2013 i still dont understand Link to comment
iPrestege Posted October 12, 2013 Share Posted October 12, 2013 You can call between the server and client via triggers as myonlake said Link to comment
-stolka- Posted October 12, 2013 Author Share Posted October 12, 2013 with triggerserverevent? how? Edit: is it correct? i used triggerEvent function... addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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.15, 2, -1.3, 0, 0, 93) attachElements ( minigunTwo, theVehicle, -1.15, 2, -1.3, 0, 0, 93 ) attachElements ( minigunOneF, theVehicle, 1.15, 2, -0.62, 0, 30, 93) attachElements ( minigunTwoF, theVehicle, -1.15, 2, -0.62, 0, 30, 93 ) bindKey ( "mouse1", "down", enableFire ) bindKey ( "mouse1", "up", disableFire ) end end ) addEventHandler("onClientVehicleExit", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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() triggerEvent ( "onMavShoot", root) end function disableFire() triggerEvent ( "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 ( "onMavShoot", true ) addEventHandler ( "onMavShoot", 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 ( "onMavStopShoot", true ) addEventHandler ( "onMavStopShoot", root, mavStopShoot ) Link to comment
Castillo Posted October 14, 2013 Share Posted October 14, 2013 No, that'll make the same effect. You must trigger to the server side and then trigger back to the client side. Link to comment
-stolka- Posted October 15, 2013 Author Share Posted October 15, 2013 is it correct? 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 ) client addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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.15, 2, -1.3, 0, 0, 93) attachElements ( minigunTwo, theVehicle, -1.15, 2, -1.3, 0, 0, 93 ) attachElements ( minigunOneF, theVehicle, 1.15, 2, -0.62, 0, 30, 93) attachElements ( minigunTwoF, theVehicle, -1.15, 2, -0.62, 0, 30, 93 ) bindKey ( "mouse1", "down", enableFire ) bindKey ( "mouse1", "up", disableFire ) end end ) addEventHandler("onClientVehicleExit", root, function(thePlayer, seat) local theVehicle = source if getElementModel(theVehicle) == 487 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 ) 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