TwicH Posted December 28, 2017 Share Posted December 28, 2017 hi scripters of mta, I had an idea to make a platform cj would automatically "slide" on for my parkour server. so here is what i did: function standingcheck() local slide_platform = getElementModel (getPedContactElement ( localPlayer )) --get the model of the object cj is standing on if slide_platform == 8558 then --if its this object then local x,y,z = getElementRotation ( localPlayer ) --do some math with z variable here :D setElementVelocity ( localPlayer, 0, 0, 0) --push cj the way hes facing somehow end end addEventHandler ( "onClientPreRender", root, standingcheck ) thank you in advance. Link to comment
DRW Posted December 28, 2017 Share Posted December 28, 2017 Found this thing long ago and been using it on my scripts ever since, so props to the original creator: function getPositionInFront(element,meters) local x, y, z = getElementPosition ( element ) local a,b,r = getVehicleRotation ( element ) x = x - math.sin ( math.rad(r) ) * meters y = y + math.cos ( math.rad(r) ) * meters return x,y,z end This gets the position in front of the player. I think I have used setElementVelocity before and I'm pretty sure that function won't work if the player is standing over a surface, so you should find a workaround. But try it anyway, I might be wrong. 1 Link to comment
TwicH Posted December 28, 2017 Author Share Posted December 28, 2017 26 minutes ago, MadnessReloaded said: Found this thing long ago and been using it on my scripts ever since, so props to the original creator: function getPositionInFront(element,meters) local x, y, z = getElementPosition ( element ) local a,b,r = getVehicleRotation ( element ) x = x - math.sin ( math.rad(r) ) * meters y = y + math.cos ( math.rad(r) ) * meters return x,y,z end This gets the position in front of the player. I think I have used setElementVelocity before and I'm pretty sure that function won't work if the player is standing over a surface, so you should find a workaround. But try it anyway, I might be wrong. works perfect, thank you so much 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