Jump to content

Help convertMoney


1LoL1

Recommended Posts

I don't see point of saving a converted number, but if you want just use this function to 'unconvert' the 'number':

function unconvertNumber ( number ) 
    local result = number:gsub ( ",", "" ); 
    return tonumber ( result ); 
end 

obs: you can convert the number directly in the function, there is no need to use 'unconvertNumber'.

about saving lang, you have to edit your "CREATE TABLE [...]" to support other column.

Link to comment
I don't see point of saving a converted number, but if you want just use this function to 'unconvert' the 'number':
function unconvertNumber ( number ) 
    local result = number:gsub ( ",", "" ); 
    return tonumber ( result ); 
end 

obs: you can convert the number directly in the function, there is no need to use 'unconvertNumber'.

about saving lang, you have to edit your "CREATE TABLE [...]" to support other column.

what with this?

function unconvertNumber ( number ) 
    local result = number:gsub ( ",", "" ); 
    return tonumber ( result ); 
end 

i need to use here

local money = getPlayerMoney ( source ) -- save 99,999,999$

setPlayerMoney ( source, poll[1]["Money"] ) -- load 99999999$ or 99,999,999$

Link to comment

Why would you want to save the money formatted? It should be a number value. You need to alter your SQL table if you want to store a string instead of a number.

Its a lot more efficient to store the number 99,999,999 as 99999999 (4 bytes) than as 99,999,999 (10 bytes) (it's not because of the commas), furthermore, all Lua functions take money as a number, not a formatted string, so you'll waste CPU to un-format the number.

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