Raised This Month: $ Target: $400
 0% 

IntToMoney


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
dalto
Veteran Member
Join Date: Jul 2007
Old 09-04-2007 , 09:31   Re: IntToMoney
Reply With Quote #3

Well, since everyone is sharing their money formatting code, I have a stock I for this as well.

Code:
stock FormatMoney(String:moneyString[], moneySize)
{
    if(strlen(moneyString) <= 3)
    {
        Format(moneyString, moneySize, "$%s", moneyString);
        return;
    }
    new String:buffer[20];
    strcopy(buffer, sizeof(buffer), moneyString[strlen(moneyString) - 3]);
    moneyString[strlen(moneyString) - 3] = 0;
    while(strlen(moneyString) > 3)
    {
        Format(buffer, sizeof(buffer), "%s,%s", moneyString[strlen(moneyString) - 3], buffer);
        moneyString[strlen(moneyString) - 3] = 0;
    }
    Format(moneyString, moneySize, "$%s,%s", moneyString, buffer);
}

Last edited by dalto; 09-04-2007 at 19:34.
dalto is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode