iFerasMO Posted March 16, 2015 Share Posted March 16, 2015 Hello.. I have a script beating weapons out of the car and running a sound when hit The script works seriously, but at the client side .. when someone hits me I do not see the weapon and do not hear the sound Only he sees and hears, and he can not kill one What should I put any server-side ? addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) local theVehicle = source if seat == 0 and thePlayer == localPlayer and getElementModel(theVehicle) == 405 then local x, y, z = getElementPosition ( theVehicle ) local rx, ry, rz = getElementRotation ( theVehicle ) minigun = createWeapon ( "minigun", x, y, z ) setElementAlpha ( minigun,0) attachElements ( minigun, theVehicle, -0.09, -1.1, 1.245, 0, 0, 90) 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) == 405 then if minigun then destroyElement (minigun) unbindKey ( "mouse1", "down", enableFire ) unbindKey ( "mouse1", "up", disableFire ) end end end ) function enableFire() if isTimer(MGtimer) and minigun then killTimer(MGimer) else MGimer = setTimer(function() local PlayerMoney = getPlayerMoney(source) if PlayerMoney >= 10000 then triggerServerEvent ("myLK", root) setTimer(setWeaponState (minigun, "firing"),5000,1) stopSound ( MiniSound ) MiniSound = playSound ( "LK.mp3",true) setSoundVolume(MiniSound, 1) outputChatBox("#D31141 Libyan Kingdom #E2F50F|#FFFFFF تم سحب منك 10,000 ثمن الذخيرة", 255, 255, 255, true) else outputChatBox("#D31141 Libyan Kingdom #E2F50F|#FFFFFF ليس لديك المال الكافي", 255, 255, 255, true) end end, 50, 1) end end function disableFire() if isTimer(MGtimer) and minigun then killTimer(MGimer) else MGimer = setTimer(function() setWeaponState ( minigun, "ready" ) end, 50, 1) stopSound ( MiniSound ) end end function unb () unbindKey ( "mouse1", "down", unb ) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), unb ) addEvent("myLK",true) addEventHandler("myLK",resourceRoot, function() takePlayerMoney(source, 10000) end) Link to comment
xXMADEXx Posted March 16, 2015 Share Posted March 16, 2015 It's extremely hard to understand your English. Could you please try to directly state your problem? Link to comment
iFerasMO Posted March 17, 2015 Author Share Posted March 17, 2015 google translator the script works in Client-Side only .. how can i make it in Server-Side ? i want all the players see the minigun bullets & hear the sound . this's my english :] Link to comment
xXMADEXx Posted March 17, 2015 Share Posted March 17, 2015 google translator the script works in Client-Side only .. how can i make it in Server-Side ? i want all the players see the minigun bullets & hear the sound . this's my english :] Alright, I see. You'll need to trigger an event when "enableFire" is called, send an event to the server, and then bounce it back to all the clients. Try using this ((not tested)): ------------------------- -- Client-Side ------------------------- addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) local theVehicle = source if seat == 0 and thePlayer == localPlayer and getElementModel(theVehicle) == 405 then local x, y, z = getElementPosition ( theVehicle ) local rx, ry, rz = getElementRotation ( theVehicle ) minigun = createWeapon ( "minigun", x, y, z ) setElementAlpha ( minigun,0) attachElements ( minigun, theVehicle, -0.09, -1.1, 1.245, 0, 0, 90) 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) == 405 then if minigun then destroyElement (minigun) unbindKey ( "mouse1", "down", enableFire ) unbindKey ( "mouse1", "up", disableFire ) end end end ) function enableFire() if isTimer(MGtimer) and minigun then killTimer(MGimer) else if ( getPlayerMoney ( localPlayer ) >= 10000 ) then triggerServerEvent ( "onMinigunBeginFireSound", localPlayer ); outputChatBox("#D31141 Libyan Kingdom #E2F50F|#FFFFFF تم سحب منك 10,000 ثمن الذخيرة", 255, 255, 255, true) else outputChatBox("#D31141 Libyan Kingdom #E2F50F|#FFFFFF ليس لديك المال الكافي", 255, 255, 255, true) end end end function disableFire() if isTimer(MGtimer) and minigun then killTimer(MGimer) else MGimer = setTimer(function() setWeaponState ( minigun, "ready" ) end, 50, 1) stopSound ( MiniSound ) end end function unb () unbindKey ( "mouse1", "down", unb ) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), unb ) local players = { } addEvent ( "onMinigunBeginFireSoundToClient", true ) addEventHandler ( "onMinigunBeginFireSoundToClient", root, function ( plr ) if ( players [ plr ] ) then if ( players [ plr ].timer and isTimer ( players [ plr ].timer ) ) then killTimer ( players [ plr ].timer ) end if ( players [ plr ].sound and isElement ( players [ plr ].sound ) ) then destroyElement ( players [ plr ].sound ) end players [ plr ] = nil; end players [ plr ] = { } players [ plr ].timer = setTimer ( function ( plr ) if ( players [ plr ].sound and isElement ( players [ plr ].sound ) ) then destroyElement ( players [ plr ].sound ) end players [ plr ].sound = playSound ( "LK.mp3", true ); setSoundVolume ( players [ plr ].sound, 1 ); end, 50, 1, plr ) end ); ------------------------- -- Server-Side ------------------------- addEvent("myLK",true) addEventHandler("myLK",resourceRoot, function() takePlayerMoney(source, 10000) end ) addEvent ( "onMinigunBeginFireSound", true ) addEventHandler ( "onMinigunBeginFireSound", root, function ( ) triggerClientEvent ( root, "onMinigunBeginFireSoundToClient", root, source ); end ); Really not sure if it'll work, but if it gives an error just post it. Link to comment
iFerasMO Posted March 19, 2015 Author Share Posted March 19, 2015 not working ,, 1 - the minigun dont fire ( just sound ) 2 - when i press mouse1 the sound starts and doesn't stop Link to comment
TAPL Posted March 19, 2015 Share Posted March 19, 2015 http://bugs.multitheftauto.com/view.php?id=7313 Link to comment
xeon17 Posted March 19, 2015 Share Posted March 19, 2015 http://bugs.multitheftauto.com/view.php?id=7313 You didn't understood him at all , he created the weapon on client side so the weapon is visible only to the local player. Other players can't see the weapon, that's his problem. 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