MajdMTA Posted March 9, 2016 Share Posted March 9, 2016 How I can format/convert a Grid List number? please help me. Link to comment
Captain Cody Posted March 10, 2016 Share Posted March 10, 2016 If you wanna round it to a smaller number math.floor. Link to comment
MajdMTA Posted March 11, 2016 Author Share Posted March 11, 2016 Hey, show us an example Example: If the car price is : 5000 for example, I wanna it 5,000 Link to comment
Mann56 Posted March 11, 2016 Share Posted March 11, 2016 Hey, show us an example Example: If the car price is : 5000 for example, I wanna it 5,000 I didn't understand what you are trying to say... Please elaborate? Link to comment
denny199 Posted March 11, 2016 Share Posted March 11, 2016 Take a look at this function: function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if ( k==0 ) then break end end return formatted end More information here: https://wiki.multitheftauto.com/wiki/ConvertNumber Link to comment
GTX Posted March 11, 2016 Share Posted March 11, 2016 Alternate version with no loops: function commaNumber(n) local left, num, right = string.match(n, "^([^%d]*%d)(%d*)(.-)$") return left..(num:reverse():gsub("(%d%d%d)", "%1,"):reverse())..right end Link to comment
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