WASSIm. Posted May 12, 2013 Share Posted May 12, 2013 slm lolad scripte hadha ya3ml miniguns fi hunter ama dra chbih lé yadhrab wa ta3mlt fi krahab il kol Client local miniguns = {} addEvent( "onEnter", true ) addEventHandler( "onEnter",root,function(thePlayer, seat) if seat ~= 0 and getElementModel(source) ~= 425 then return end if not miniguns[thePlayer] then miniguns[thePlayer] = {} end local x, y, z = getElementPosition ( source ) local rx, ry, rz = getElementRotation ( source ) miniguns[thePlayer][1] = createWeapon ( "minigun", x, y, z ) miniguns[thePlayer][2] = createWeapon ( "minigun", x, y, z ) miniguns[thePlayer][3] = createWeapon ( "minigun", x, y, z ) miniguns[thePlayer][4] = createWeapon ("minigun", x, y, z ) for i = 1,#miniguns[thePlayer] do setWeaponOwner ( miniguns[thePlayer][i], thePlayer) setElementAlpha ( miniguns[thePlayer][i],0) end attachElements ( miniguns[thePlayer][1], source, 2.15, 0.5, -1.2, 0, 0, 90 ) attachElements ( miniguns[thePlayer][2], source, -2.10, 0.5, -1.2, 0, 0, 90 ) attachElements ( miniguns[thePlayer][3], source, 2.57, 0.5, -1.1, 0, 0, 90 ) attachElements ( miniguns[thePlayer][4], source, -2.52, 0.5, -1.1, 0, 0, 90 ) if thePlayer~=localPlayer then return end toggleControl ( "vehicle_fire", false ) toggleControl ( "vehicle_secondary_fire", false ) for _,key in ipairs(getBoundKeys("vehicle_fire"))do bindKey ( key, "down",fire ) bindKey ( key, "up",fire ) end end) addEvent( "onExit", true ) addEventHandler( "onExit",root,function(thePlayer, seat) if seat ~= 0 and getElementModel(source) ~= 425 then return end for _,minigun in ipairs(miniguns[thePlayer])do destroyElement (minigun) end miniguns[thePlayer] = nil if thePlayer~=localPlayer then return end toggleControl ( "vehicle_fire", false ) toggleControl ( "vehicle_secondary_fire", false ) for _,key in ipairs(getBoundKeys("vehicle_fire"))do unbindKey ( key, "down",fire ) unbindKey ( key, "up",fire ) end end) function fire(_,state) triggerServerEvent("fire",localPlayer,state) end function move(source) local MiniSound = playSound3D("test.wav", x, y, z,false) setSoundMaxDistance(MiniSound, 140) setSoundEffectEnabled(MiniSound,"gargle",true) attachElements ( MiniSound, getPedOccupiedVehicle(source), 0, 0.5, -1.1, 0, 0, 90 ) end addEvent( "onEnableFire", true ) addEventHandler( "onEnableFire",root,function() for _,minigun in ipairs(miniguns[source])do setWeaponState ( minigun, "firing") end move(source) end) addEvent( "onDisableFire", true ) addEventHandler( "onDisableFire",root,function() for _,minigun in ipairs(miniguns[source])do setWeaponState ( minigun, "ready") end move(source) end) SERVER addEventHandler ("onVehicleEnter", root,function(player,seat) triggerClientEvent("onEnter",source,player,seat) end) addEventHandler("onVehicleExit", root,function(player,seat) triggerClientEvent ( "onExit",source,player,seat) end) addEvent("fire",false) addEventHandler("fire",root,function(state) if state=="down"then triggerClientEvent("onEnableFire",client) elseif state=="up"then triggerClientEvent ("onDisableFire",client) end end) Link to comment
Sparrow Posted May 12, 2013 Share Posted May 12, 2013 fel server side, fi triggerClientEvent, el wa7da mte3ha: triggerClientEvent ( [element sendTo=getRootElement()], string name, element theElement, [arguments...] ) enti 3aml: triggerClientEvent("onEnter",source,player,seat) Link to comment
Sparrow Posted May 13, 2013 Share Posted May 13, 2013 zid element 9bal el "event" triggerClientEvent(player,"onEnter",source,player,seat) 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