BylemTu Posted July 10, 2018 Posted July 10, 2018 mp.events.addCommand('gp', (player) => { player.outputChatBox("Pozycja: " + player.position); }); My English is not very well, sorry. Today I started JS learning with RageMP. I made some easy scripts similar to examples. One of my first problems are this in top of the post. How can I round player.position? It's problem for me cause player.position have 3 values - X, Y and Z. In lua (MTA) it was easier for me. local X, Y, Z = getPlayerPosition print(X, Y, Z)
BylemTu Posted July 10, 2018 Author Posted July 10, 2018 Solved. function Round(n, k) { var factor = Math.pow(10, k+1); n = Math.round(Math.round(n*factor)/10); return n/(factor/10); } mp.events.addCommand('gp', (player) => { const pozaX = player.position.x; const pozaY = player.position.y; const pozaZ = player.position.z; player.outputChatBox("X: " +Round(pozaX,3)); player.outputChatBox("Y: " +Round(pozaY,3)); player.outputChatBox("Z: " +Round(pozaZ,3)); }); 2
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