Jump to content

Function convertNumber not work ?[solved]


#RooTs

Recommended Posts

is no longer working? :o:o:o:o

local money = convertNumber(getPlayerMoney(localPlayer)) --money format 1,000,000,0 
dxDrawBorderedText("R$: "..money, x*0.875, y*0.155, x*800, y*030, tocolor(255, 255, 255,255), 1.7, "default", "left", "top", false, false, true, false, false) 

Edited by Guest
Link to comment

convertNumber is not a native function of the MTA, then you need to add this function in your script

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 

Edited by Guest
Link to comment
No, MTA has no default function to do this, and is not required either.

@Castilho, I had this function, and because it no longer works? :o:o ( because it became so complicated? )

local money = convertNumber(getPlayerMoney(localPlayer)) 

makes no sense why she no longer works

Link to comment
do not know WHAT is talking, looks the Solidsnake14 spoke, :x:x:x:x

LekRoots I did not understand what you said

Castillo said that this function is not standard MTA

and I did not say anything contrary to what he said ...

https://wiki.multitheftauto.com/wiki/Useful_Functions

This page lists user-made Lua functions that are not included by default in MTA. Its purpose is to quickly provide some useful functions for scripters, so they do not waste time recreating them when needed.
Link to comment
What's the difference between convertNumber and tonumber? :|

an example for tonumber :

https://wiki.multitheftauto.com/wiki/SetPlayerMoney

convertNumber and tonumber bears no resemblance

ConverteNumber will show the number with commas, for example: 1,000,000

In this example the wiki, tonumber will be the number you want to set your Money, example: / setcash 1000000

If you are asking this because of the lcd1232 reply, he is wrong, it is not necessary to use tonumber because getPlayerMoney already generates a number

Link to comment

I repeat, convertNumber is not a function of the MTA

convertNumber is a function created by any one person, she has no connection with the MTA

So it will not work if you do not add the code to your script !!!

if you do not put the code in your script, you will have no result

https://wiki.multitheftauto.com/wiki/ConvertNumber

ezimba18742047652104.png

@Edit

I tested it and it works normally

3zFJ97

you just need to add the convertNumber function in your script. Can not you understand that?

Link to comment

LOLLSSS :o:o I'm already thinking that my mta is in trouble

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 
  
local money = formatted -- what to put here? I've tried ( number, formatted, k ) 
dxDrawText("R$: "..money, x*0.835, y*0.150, x*800, y*030, tocolor(255, 255, 255,255), 0.7, "bankgothic", "left", "top", false, false, true, false, false) 
  
  

Link to comment
  • Moderators
dxDrawText("R$: "..convertNumber(money), x*0.835, y*0.150, x*800, y*030, tocolor(255, 255, 255,255), 0.7, "bankgothic", "left", "top", false, false, true, false, false) 
  
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 

P.S: 'money' must be defined.

Link to comment
dxDrawText("R$: "..convertNumber(money), x*0.835, y*0.150, x*800, y*030, tocolor(255, 255, 255,255), 0.7, "bankgothic", "left", "top", false, false, true, false, false) 
  
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 

P.S: 'money' must be defined.

WORKING.......

my MTA really was in trouble

SORRY MY FRIENDS, thanks all, by patience with me

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