Sign in to follow this  

How round player position?

Recommended Posts'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)


Share this post

Link to post
Share on other sites


function Round(n, k) 
    var factor = Math.pow(10, k+1);
    n = Math.round(Math.round(n*factor)/10);
    return n/(factor/10);
}'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));


  • Like 2

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.