WolfPire Posted March 31, 2012 Share Posted March 31, 2012 I'm not sure if it's this or idk. But whenever i drop the bomb of my rustler (Right Control) It triggers that to all the players around. Can you guys please help me? Client function RustlerNW() d = 5 r = getPedRotation ( localPlayer ) x, y, z = getElementPosition ( localPlayer ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * d ) ground = getGroundPosition ( x, y, z ) triggerServerEvent( "RustlerNWS", root, localPlayer, x, y, ground, r ) bindKey("rctrl", "down",bombinit) end addCommandHandler("rnw", RustlerNW) bindKey("c", "down", function() if not MT then MT = setTimer(fire, 1000, 1) end end ) function bombinit() if localPlayer then triggerServerEvent("dropBomb",root) end end addEvent("bombExplode",true) addEventHandler("bombExplode", root, function(BarrelC) if BarrelC then addEventHandler("onClientRender", root, explode) barrel = BarrelC end end ) function explode() if barrel then bx, by, bz = getElementPosition(barrel) groundBZ = getGroundPosition( bx, by, bz ) unbindKey("rctrl", "down") if bz <= groundBZ+3 then triggerServerEvent("goBoom",root, barrel, bx, by, bz, localPlayer) removeEventHandler("onClientRender", root, explode) end end end function fire() local v = getPedOccupiedVehicle( localPlayer ) local x, y, z = getElementPosition(v) local rx, ry, rz = getElementRotation(v) local velX, velY, velZ = getElementVelocity (v) local speed = ( velX^2 + velY^2 + velZ^2 ) ^ ( 0.5 ) if getElementModel( v ) == 476 then m1 = createProjectile( localPlayer, 19, x + 8, y + 5, z - 5, speed*2, nil, rx, ry, rz, velX*2.0, velY*2.0, velZ*2.0) m2 = createProjectile( localPlayer, 19, x + 4, y + 5, z - 5, speed*2, nil, rx, ry, rz, velX*2.0, velY*2.0, velZ*2.0) m3 = createProjectile( localPlayer, 19, x + -4, y + 5, z - 5, speed*2, nil, rx, ry, rz, velX*2.0, velY*2.0, velZ*2.0) m4 = createProjectile( localPlayer, 19, x + -8, y + 5, z - 5, speed*2, nil, rx, ry, rz, velX*2.0, velY*2.0, velZ*2.0) MT = nil end end Server local RustlerNW = {} local missile1 = {} local missile2 = {} local missile3 = {} local missile4 = {} local Barrel = {} local AC1 = {} local AC2 = {} local Satelite = {} addEvent("RustlerNWS",true) addEventHandler("RustlerNWS",root, function( localPlayer, x, y, ground, r ) RustlerNW[localPlayer] = createVehicle(476, x + 3, y + 2, ground + 3, 0, 0, r ) missile1[localPlayer] = createObject(3790, 0, 0 ,0) missile2[localPlayer] = createObject(3790, 0, 0 ,0) missile3[localPlayer] = createObject(3790, 0, 0 ,0) missile4[localPlayer] = createObject(3790, 0, 0 ,0) Barrel[localPlayer] = createObject(1225, 0, 0, 0) AC1[localPlayer] = createObject(3812, 0, 0 ,0) AC2[localPlayer] = createObject(3812, 0, 0 ,0) Satelite[localPlayer] = createObject(3031, 0, 0 ,0) attachElements(missile1[localPlayer], RustlerNW[localPlayer], -5.3, 0.6, -0.5, 0, 0, 270 ) attachElements(missile2[localPlayer], RustlerNW[localPlayer], -1.3, 0.6, -0.8, 0, 0, 270 ) attachElements(missile3[localPlayer], RustlerNW[localPlayer], 1.3, 0.6, -0.8, 0, 0, 270 ) attachElements(missile4[localPlayer], RustlerNW[localPlayer], 5.3, 0.6, -0.5, 0, 0, 270 ) attachElements(Barrel[localPlayer], RustlerNW[localPlayer], 0, 0, -1, 90, 0, 0) attachElements(AC1[localPlayer], RustlerNW[localPlayer], -0.3, 2.6, -0.2, 0, 0, 180 ) attachElements(AC2[localPlayer], RustlerNW[localPlayer], 0.3, 2.565, -0.2, 0, 0, 0 ) attachElements(Satelite[localPlayer], RustlerNW[localPlayer], 0.3, -4.3, 1.75, 0, 0, 90 ) BarrelC = Barrel[localPlayer] RustlerC = RustlerNW[localPlayer] Player = localPlayer end ) addEvent("dropBomb",true) addEventHandler("dropBomb",root, function() if BarrelC then detachElements(BarrelC, RustlerC) triggerClientEvent("bombExplode", root, BarrelC) end end ) addEvent("goBoom",true) addEventHandler("goBoom", root, function(barrel, bx, by, bz, localPlayer) if barrel then createExplosion( bx, by, bz, 2, localPlayer) destroyElement(barrel) end end ) Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 LOOOOL Another newbie Obviously, if you trigger for all players, will trigger for all players, no? Link to comment
WolfPire Posted March 31, 2012 Author Share Posted March 31, 2012 LOOOOL Another newbie Obviously, if you trigger for all players, will trigger for all players, no? I found your statement really offensive, as i have been in MTA since DP 2 and i've been learning LUA over 1 year now. I jsut don't master this area. Even if i trigger for one player, it will trigger on every. Show some respect. Link to comment
drk Posted March 31, 2012 Share Posted March 31, 2012 If you have learn for 1 year you need know that when you trigger for one player, will only execute the string for the PLAYER. Link to comment
WolfPire Posted March 31, 2012 Author Share Posted March 31, 2012 If you have learn for 1 year you need know that when you trigger for one player, will only execute the string for the PLAYER. 1 year is not enough. I'm not professional, nor newbie. Edit: Well, rather than getting help, we just fell into a little argument, so yeah, sorry for being so harsh. I really need help, can haz pl0x? Link to comment
Khtsjefen Posted March 31, 2012 Share Posted March 31, 2012 Client side (UNTESTED!): function dropbomb(source,command) if (isPedInVehicle(source)) then local x,y,z = getElementPosition(getPedOccupiedVehicle(source)) local model = getElementModel(getPedOccupiedVehicle(source)) if model == 476 then createProjectile ( source, 19, x, y, z-2, 1.0, nil, 180, 0, 0 ) outputChatBox("It's falling!", source ) else outputChatBox("Sorry, Rustler only.", source ) end end end addCommandHandler("bomb",dropbomb) Maybe that will work to make a bomb dropping down, but not sure as I have not tested it. EDIT: Bomb=Rocket Launcher shot going straight downwards, blowing up when it hits, not heat seeking so it will jsut go straight down. Link to comment
Kenix Posted March 31, 2012 Share Posted March 31, 2012 Fail. Only in server side you can add in first argument command-function-handler element player. The player who triggered the command. If not triggered by a player (e.g. by admin), this will be false. 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