Yang Posted October 14, 2018 Share Posted October 14, 2018 Pleease I have this local Up_Down1 = createMarker(0, 0, 3, 'checkpoint', 10.0, 255, 0, 0, 150) local Up_Down2 = createMarker(10, 0, 3, 'checkpoint', 10.0, 255, 0, 0, 150) local Up_Down3 = createMarker(20, 0, 3, 'checkpoint', 10.0, 255, 0, 0, 150) function Down (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x, y - 60, z) end function Up (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x, y + 60, z) end addEventHandler( "onMarkerHit", Up_Down1, Down ) addEventHandler( "onMarkerHit", Up_Down2, Down ) addEventHandler( "onMarkerHit", Up_Down3, Down ) Link to comment
Z4Zy Posted October 14, 2018 Share Posted October 14, 2018 You mean that marker should keep going with a same velocity when someone hit it ? Link to comment
Z4Zy Posted October 14, 2018 Share Posted October 14, 2018 I suggest you to use "moveObject" in this position. Can you please post your lua code with code option in edit panel ? Link to comment
Yang Posted October 14, 2018 Author Share Posted October 14, 2018 How can I do that? I can't, I am new Link to comment
Z4Zy Posted October 14, 2018 Share Posted October 14, 2018 Well, can you see some edit options [ B, I, u] where you typing the texts to post ? There you can see a symbols like this <>. Click on it and paste your lua code there and click insert into post. Link to comment
Yang Posted October 14, 2018 Author Share Posted October 14, 2018 local Up_Down1 = createMarker(0, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down2 = createMarker(10, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down3 = createMarker(20, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down4 = createMarker(30, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down5 = createMarker(40, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down6 = createMarker(50, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down7 = createMarker(60, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down8 = createMarker(70, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down9 = createMarker(80, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down10 = createMarker(90, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up1 = createMarker(0, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up2 = createMarker(10, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up3 = createMarker(20, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up4 = createMarker(30, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up5 = createMarker(40, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up6 = createMarker(50, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up7 = createMarker(60, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up8 = createMarker(70, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up9 = createMarker(80, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up10 = createMarker(90, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) ------------------------------------------------------------------------------------ local Right_Left1 = createMarker(0, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left2 = createMarker(0, -10, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left3 = createMarker(0, -20, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left4 = createMarker(0, -30, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left5 = createMarker(0, -40, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left6 = createMarker(0, -50, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left7 = createMarker(0, -60, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left8 = createMarker(0, -70, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left9 = createMarker(0, -80, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left10 = createMarker(0, -90, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right1 = createMarker(100, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right2 = createMarker(100, -10, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right3 = createMarker(100, -20, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right4 = createMarker(100, -30, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right5 = createMarker(100, -40, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right6 = createMarker(100, -50, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right7 = createMarker(100, -60, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right8 = createMarker(100, -70, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right9 = createMarker(100, -80, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right10 = createMarker(100, -90, 3, 'checkpoint', 5.0, 255, 0, 0, 150) function Down (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x, y - 80, z, false) end function Up (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x, y + 80, z, false) end function Right (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x- 80, y, z, false) end function Left (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x+ 80, y, z, false) end addEventHandler( "onMarkerHit", Up_Down1, Down ) addEventHandler( "onMarkerHit", Up_Down2, Down ) addEventHandler( "onMarkerHit", Up_Down3, Down ) addEventHandler( "onMarkerHit", Up_Down4, Down ) addEventHandler( "onMarkerHit", Up_Down5, Down ) addEventHandler( "onMarkerHit", Up_Down6, Down ) addEventHandler( "onMarkerHit", Up_Down7, Down ) addEventHandler( "onMarkerHit", Up_Down8, Down ) addEventHandler( "onMarkerHit", Up_Down9, Down ) addEventHandler( "onMarkerHit", Up_Down10, Down ) addEventHandler( "onMarkerHit", Down_up1, Up ) addEventHandler( "onMarkerHit", Down_up2, Up ) addEventHandler( "onMarkerHit", Down_up3, Up ) addEventHandler( "onMarkerHit", Down_up4, Up ) addEventHandler( "onMarkerHit", Down_up5, Up ) addEventHandler( "onMarkerHit", Down_up6, Up ) addEventHandler( "onMarkerHit", Down_up7, Up ) addEventHandler( "onMarkerHit", Down_up8, Up ) addEventHandler( "onMarkerHit", Down_up9, Up ) addEventHandler( "onMarkerHit", Down_up10, Up ) ------------------------------------------------------------------- addEventHandler( "onMarkerHit", Right_Left1, Left ) addEventHandler( "onMarkerHit", Right_Left2, Left ) addEventHandler( "onMarkerHit", Right_Left3, Left ) addEventHandler( "onMarkerHit", Right_Left4, Left ) addEventHandler( "onMarkerHit", Right_Left5, Left ) addEventHandler( "onMarkerHit", Right_Left6, Left ) addEventHandler( "onMarkerHit", Right_Left7, Left ) addEventHandler( "onMarkerHit", Right_Left8, Left ) addEventHandler( "onMarkerHit", Right_Left9, Left ) addEventHandler( "onMarkerHit", Right_Left10, Left ) addEventHandler( "onMarkerHit", Left_Right1, Right ) addEventHandler( "onMarkerHit", Left_Right2, Right ) addEventHandler( "onMarkerHit", Left_Right3, Right ) addEventHandler( "onMarkerHit", Left_Right4, Right ) addEventHandler( "onMarkerHit", Left_Right5, Right ) addEventHandler( "onMarkerHit", Left_Right6, Right ) addEventHandler( "onMarkerHit", Left_Right7, Right ) addEventHandler( "onMarkerHit", Left_Right8, Right ) addEventHandler( "onMarkerHit", Left_Right9, Right ) addEventHandler( "onMarkerHit", Left_Right10, Right ) Link to comment
Storm-Hanma Posted October 14, 2018 Share Posted October 14, 2018 (edited) You didn't use set element velocity function add this function before set element position https://wiki.multitheftauto.com/wiki/SetElementVelocity Edited October 14, 2018 by KINGKHAN Link to comment
Yang Posted October 14, 2018 Author Share Posted October 14, 2018 local Up_Down1 = createMarker(0, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down2 = createMarker(10, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down3 = createMarker(20, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down4 = createMarker(30, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down5 = createMarker(40, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down6 = createMarker(50, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down7 = createMarker(60, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down8 = createMarker(70, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down9 = createMarker(80, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Up_Down10 = createMarker(90, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up1 = createMarker(0, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up2 = createMarker(10, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up3 = createMarker(20, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up4 = createMarker(30, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up5 = createMarker(40, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up6 = createMarker(50, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up7 = createMarker(60, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up8 = createMarker(70, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up9 = createMarker(80, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Down_up10 = createMarker(90, -100, 3, 'checkpoint', 5.0, 255, 0, 0, 150) ------------------------------------------------------------------------------------ local Right_Left1 = createMarker(0, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left2 = createMarker(0, -10, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left3 = createMarker(0, -20, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left4 = createMarker(0, -30, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left5 = createMarker(0, -40, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left6 = createMarker(0, -50, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left7 = createMarker(0, -60, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left8 = createMarker(0, -70, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left9 = createMarker(0, -80, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Right_Left10 = createMarker(0, -90, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right1 = createMarker(100, 0, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right2 = createMarker(100, -10, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right3 = createMarker(100, -20, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right4 = createMarker(100, -30, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right5 = createMarker(100, -40, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right6 = createMarker(100, -50, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right7 = createMarker(100, -60, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right8 = createMarker(100, -70, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right9 = createMarker(100, -80, 3, 'checkpoint', 5.0, 255, 0, 0, 150) local Left_Right10 = createMarker(100, -90, 3, 'checkpoint', 5.0, 255, 0, 0, 150) function Down (source ) local Sx, Sy, Sz = getElementVelocity (source) local Px, Py, Pz = getElementPosition (source) setElementVelocity ( source, Sx, Sy, Sz) setElementPosition ( source, Px, Py - 80, Pz, false) end function Up (source ) local Sx, Sy, Sz = getElementVelocity(source) local Px, Py, Pz = getElementPosition(source) setElementVelocity (source, Sx, Sy, Sz) setElementPosition ( source, Px, Py + 80, Pz, false) end function Right (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x- 80, y, z, false) end function Left (source ) local x, y, z = getElementPosition(source) setElementPosition ( source, x+ 80, y, z, false) end addEventHandler( "onMarkerHit", Up_Down1, Down ) addEventHandler( "onMarkerHit", Up_Down2, Down ) addEventHandler( "onMarkerHit", Up_Down3, Down ) addEventHandler( "onMarkerHit", Up_Down4, Down ) addEventHandler( "onMarkerHit", Up_Down5, Down ) addEventHandler( "onMarkerHit", Up_Down6, Down ) addEventHandler( "onMarkerHit", Up_Down7, Down ) addEventHandler( "onMarkerHit", Up_Down8, Down ) addEventHandler( "onMarkerHit", Up_Down9, Down ) addEventHandler( "onMarkerHit", Up_Down10, Down ) addEventHandler( "onMarkerHit", Down_up1, Up ) addEventHandler( "onMarkerHit", Down_up2, Up ) addEventHandler( "onMarkerHit", Down_up3, Up ) addEventHandler( "onMarkerHit", Down_up4, Up ) addEventHandler( "onMarkerHit", Down_up5, Up ) addEventHandler( "onMarkerHit", Down_up6, Up ) addEventHandler( "onMarkerHit", Down_up7, Up ) addEventHandler( "onMarkerHit", Down_up8, Up ) addEventHandler( "onMarkerHit", Down_up9, Up ) addEventHandler( "onMarkerHit", Down_up10, Up ) ------------------------------------------------------------------- addEventHandler( "onMarkerHit", Right_Left1, Left ) addEventHandler( "onMarkerHit", Right_Left2, Left ) addEventHandler( "onMarkerHit", Right_Left3, Left ) addEventHandler( "onMarkerHit", Right_Left4, Left ) addEventHandler( "onMarkerHit", Right_Left5, Left ) addEventHandler( "onMarkerHit", Right_Left6, Left ) addEventHandler( "onMarkerHit", Right_Left7, Left ) addEventHandler( "onMarkerHit", Right_Left8, Left ) addEventHandler( "onMarkerHit", Right_Left9, Left ) addEventHandler( "onMarkerHit", Right_Left10, Left ) addEventHandler( "onMarkerHit", Left_Right1, Right ) addEventHandler( "onMarkerHit", Left_Right2, Right ) addEventHandler( "onMarkerHit", Left_Right3, Right ) addEventHandler( "onMarkerHit", Left_Right4, Right ) addEventHandler( "onMarkerHit", Left_Right5, Right ) addEventHandler( "onMarkerHit", Left_Right6, Right ) addEventHandler( "onMarkerHit", Left_Right7, Right ) addEventHandler( "onMarkerHit", Left_Right8, Right ) addEventHandler( "onMarkerHit", Left_Right9, Right ) addEventHandler( "onMarkerHit", Left_Right10, Right ) It doesn't work Link to comment
savour Posted October 20, 2018 Share Posted October 20, 2018 you need to use the setElementVelocity after changing the position, not before. function Down (source ) local Sx, Sy, Sz = getElementVelocity (source) local Px, Py, Pz = getElementPosition (source) setElementPosition ( source, Px, Py - 80, Pz, false) setTimer(function() setElementVelocity ( source, Sx, Sy, Sz) end, 100, 1) end 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