Jump to content

[HELP] Question


1LoL1

Recommended Posts

Posted
function round(num, idp) 
  local mult = 10^(idp or 0) 
  return math.floor(num * mult + 0.5) 
end 
  
-- example 
print(round(5.14542123232, 1)) 
-- result: 5.1  

Posted
function round(num, idp) 
  local mult = 10^(idp or 0) 
  return math.floor(num * mult + 0.5) 
end 
  
-- example 
print(round(5.14542123232, 1)) 
-- result: 5.1  

Not work number 5.14542123232 was only example. I need for all numbers.

Posted

Not work number 5.14542123232 was only example. I need for all numbers.

What sort of numbers?

sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
speed = ((sx^2 + sy^2 + sz^2)^(0.5)*180) 

Posted

This will round numbers to 10ths. In other words, 0.1, 25.9, 56.2, etc...

sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 1) 

Or, if you want just integers

sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 0) 

Posted
This will round numbers to 10ths. In other words, 0.1, 25.9, 56.2, etc...
sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 1) 

Or, if you want just integers

sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) 
speed = round(((sx^2 + sy^2 + sz^2)^(0.5))*180, 0) 

Not work it's same what i had.

Posted

You're not describing specifically what you want so how could we help you?

Be more specific on what you want.

You can Private Message me and I will help you with Lua questions.

10 / 10 Lua scripter.

8 / 10 MTA scripter.

10 / 10 C++ embedded Lua.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...