ZenoS Posted October 30, 2011 Share Posted October 30, 2011 Hai people, I'm trying to make a bomber script, now most of the people will think: hey, there is one on the community, i know, but it doesn't work. I've heard its pretty messed up with bugs & stuff, so i tryed to script my own, so i could learn something with it. here is my lua so far: marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () detachElements (bomb, el) v = createVehicle (464, 0, 0, 0) attachelements (bomb, v) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) a,b,c = getElementRotation (bomb) setElementRotation(v, a,b,c) x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) it goes fine untill function dropbomb, the following bugs will appear: 1: v doesn't appear (its a rc baron) 2: the next debugscript 3 errors: - bad argument @ getElementVelocity - Bad argument @ setElementVelocity as far as i know, this just should work also i've been studying this bomber resource, but i don't understand the most of the things used there, so thats why i need help :3 also if someone could help me with a nice explosion, that would be nice, but also i've got to start with that one yet, so i might be possible to do something myself I hope someone would like to help me ;D Link to comment
BinSlayer1 Posted October 30, 2011 Share Posted October 30, 2011 attachelements (bomb, v) should be attachElements (bomb, v) about bad argument @ getElementVelocity it happens because el doesnt exist in the dropbomb() function , it is only a MarkerHit parameter so instead of 'el' you could do getPedOccupiedVehicle(player) and that means 'player' has to be defined (actually bindKey would return it as a parameter) so just do this: function dropbomb (player) instead of function dropbomb () edit: same thing goes for detachElements (bomb, el) --> el doesnt exist like i said Link to comment
ZenoS Posted October 30, 2011 Author Share Posted October 30, 2011 attachelements (bomb, v)should be attachElements (bomb, v) about bad argument @ getElementVelocity it happens because el doesnt exist in the dropbomb() function , it is only a MarkerHit parameter so instead of 'el' you could do getPedOccupiedVehicle(player) and that means 'player' has to be defined (actually bindKey would return it as a parameter) so just do this: function dropbomb (player) instead of function dropbomb () edit: same thing goes for detachElements (bomb, el) --> el doesnt exist like i said yeh thanks, @ the attachelements thingy, copyed it from pastebin instead of my notepad ++, saw it before too :3 anyways watched a few of your tips, and it helps, also i tryed something myself and now the misile thingy is gone. now i need to some more stuff, but i'll start with what i want to do first: now i want to make the explosion getting triggered, i tryed it by the idea of: if Z velocity is smaller then the previous velocity, then start blowing that shit up. full script: marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () el = getPedOccupiedVehicle(player) detachElements (bomb, el) outputChatBox ("Wups missile is gone qq") v = createVehicle (464, 0, 0, 0) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) outputChatBox ("New position for V") a,b,c = getElementRotation (el) setElementRotation(v, a,b,c) outputChatBox ("New rotation for V") x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) outputChatBox ("New speed for V") attachElements (bomb, v, 0, 0, 0) setTimer (explosiontrigger, 50, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 0) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 == < z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end the error is at line 43, it says there is an unexpected symbol near < also i want to make the vehicle inside the missile ( v ) to be invisible, i know this is possible, but how? thanks also binslayer, thanks for helping me out ;D Link to comment
Castillo Posted October 30, 2011 Share Posted October 30, 2011 marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () el = getPedOccupiedVehicle(player) detachElements (bomb, el) outputChatBox ("Wups missile is gone qq") v = createVehicle (464, 0, 0, 0) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) outputChatBox ("New position for V") a,b,c = getElementRotation (el) setElementRotation(v, a,b,c) outputChatBox ("New rotation for V") x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) outputChatBox ("New speed for V") attachElements (bomb, v, 0, 0, 0) setTimer (explosiontrigger, 50, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 0) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 == z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end Link to comment
ZenoS Posted October 30, 2011 Author Share Posted October 30, 2011 marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () el = getPedOccupiedVehicle(player) detachElements (bomb, el) outputChatBox ("Wups missile is gone qq") v = createVehicle (464, 0, 0, 0) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) outputChatBox ("New position for V") a,b,c = getElementRotation (el) setElementRotation(v, a,b,c) outputChatBox ("New rotation for V") x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) outputChatBox ("New speed for V") attachElements (bomb, v, 0, 0, 0) setTimer (explosiontrigger, 50, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 0) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 == z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end sorry i guess my explanation sucked but i meant the Z velocity should be less then the previous Z velocity, like this it is the same edit: btw i've edited it a little, saw a little thing which wasn't the way it was supposed to be: edited the last functions to this: function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 1) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 == < z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end Link to comment
Castillo Posted October 30, 2011 Share Posted October 30, 2011 marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () el = getPedOccupiedVehicle(player) detachElements (bomb, el) outputChatBox ("Wups missile is gone qq") v = createVehicle (464, 0, 0, 0) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) outputChatBox ("New position for V") a,b,c = getElementRotation (el) setElementRotation(v, a,b,c) outputChatBox ("New rotation for V") x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) outputChatBox ("New speed for V") attachElements (bomb, v, 0, 0, 0) setTimer (explosiontrigger, 50, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 0) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 < z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end Link to comment
ZenoS Posted October 30, 2011 Author Share Posted October 30, 2011 marker1 = getElementByID ("marker (cylinder) (1)") function MarkerHit (el) if getElementType ( el ) == "vehicle" and getVehicleName ( el ) == "Rustler" then if source == marker1 then bomb = createObject (345, 0,0,0) attachElements (bomb, el, 0, 0, -1 ) player = getVehicleOccupant (el) bindKey (player, "lshift", "down", dropbomb) end end end function dropbomb () el = getPedOccupiedVehicle(player) detachElements (bomb, el) outputChatBox ("Wups missile is gone qq") v = createVehicle (464, 0, 0, 0) p,q,r = getElementPosition (bomb) setElementPosition(v, p, q, r) outputChatBox ("New position for V") a,b,c = getElementRotation (el) setElementRotation(v, a,b,c) outputChatBox ("New rotation for V") x, y, z = getElementVelocity ( el ) setElementVelocity (v, x, y, 0) outputChatBox ("New speed for V") attachElements (bomb, v, 0, 0, 0) setTimer (explosiontrigger, 50, 0) end addEventHandler( "onMarkerHit", getRootElement(), MarkerHit) function explosiontrigger1 () x1, y1, z1 = getElementVelocity( v ) setTimer(explosiontrigger2, 50, 0) end function explosiontrigger2 () x2, y2, z2 = getElementVelocity ( v ) if z2 < z1 then x3, y3, z3 = getElementPosition ( v ) createExplosion (x3,y3,z3, 10) end end I've checked every single step in my script and still it doesn't work, the following part isn't working somehow if z2 < z1 then i've changed this into if z2 > z1 then and still it doesn't work also thanks for helping me out also if someone knows the answer to the following question: is it possible to make the vehicle inside the missile invisable? please answer thanks solidsnake for your help so far ;D Link to comment
Castillo Posted October 30, 2011 Share Posted October 30, 2011 To set a vehicle alpha use: setElementAlpha(theVehicle, alpha) Link to comment
ZenoS Posted October 30, 2011 Author Share Posted October 30, 2011 To set a vehicle alpha use: setElementAlpha(theVehicle, alpha) sweet thanks for all your help, my script is working perfect now 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