Jump to content

how ?


Best-Killer

Recommended Posts

If you're trying to convert from user input, I'd recommend cleaning the string, so to speak.

str = str:gsub(" ", "") -- Remove whitespace as a precaution 
str = str:gsub(",", "") -- Some people feel the need to do this 
str = tonumber(str) 
-- If tonumber cannot convert, it will return nil 
if (str) then 
    str = math.abs(str) -- 6.480000000000 becomes 6.48. I've had cases where people were crashing other's MTA clients with numbers that had many zeroes on the end. 
end 

Link to comment

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...