Atton Posted April 30, 2014 Posted April 30, 2014 I want to ask how would it be possible to get the position say in front of a car. Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
Karuzo Posted April 30, 2014 Posted April 30, 2014 https://wiki.multitheftauto.com/wiki/Ge ... enPoints3D
Moderators IIYAMA Posted April 30, 2014 Moderators Posted April 30, 2014 https://wiki.multitheftauto.com/wiki/GetElementMatrix function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end -- Get the position of a point 2 units in front of the element: x,y,z = getPositionFromElementOffset(element,0,2,0) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
denny199 Posted April 30, 2014 Posted April 30, 2014 IIYAMA code works only client side (getElementMatrix) This function works client side & server side, I didn't made it but JR10 posted it once. function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end Usage: local x,y,z = getPositionInfrontOfElement ( element , meters ) element = the element's position you want to get in front off meters = how many units from the element it needs to check Sometimes I dream about cheese
Moderators IIYAMA Posted April 30, 2014 Moderators Posted April 30, 2014 @Denny there is also an example at the same page which also can give the matrix at serverside. (Example 3) https://wiki.multitheftauto.com/wiki/GetElementMatrix Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Atton Posted May 1, 2014 Author Posted May 1, 2014 Thanks it works. Nikola Tesla is love Nikola Tesla is light. Email: [email protected]
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