TwicH Posted December 28, 2017 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.
DRW Posted December 28, 2017 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 Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
TwicH Posted December 28, 2017 Author 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
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