SA-MP Forums Archive
Seperate numbers by comma? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Seperate numbers by comma? (/showthread.php?tid=609446)



Seperate numbers by comma? - MayaEU - 12.06.2016

Hello, i am trying to seperate the moneys in /stats by commas, i have made this but for some reason it doesnt work, i hope that someone can help me

pawn Код:
new totalwealth;
        totalwealth = PlayerInfo[targetid][pCash]+PlayerInfo[targetid][pAccount];
pawn Код:
format(string, sizeof(string), "Details: "COL_WHITE"Money:[$%d] Bank:[$%d] Total wealth:[$%d] Job:[%s]",Comma(PlayerInfo[targetid][pCash]),Comma(PlayerInfo[targetid][pAccount]),Comma(totalwealth),jtext);
        SendClientMessage(playerid, COLOR_SZR,string);
pawn Код:
stock Comma(numbers)
{
    new temp[24],counter = -1;
    valstr(temp,numbers);
    for(new i = strlen(temp);i > 0; i--)
    {
        counter++;
        if(counter == 3)
        {
            strins(temp,",",i);
            counter = 0;
        }
    }
    return temp;
}



Re: Seperate numbers by comma? - Sjn - 12.06.2016

Change the %d to %s

The Comma function returns a string so if you use an integer specifier, it will give weird kind of looking texts.


Re: Seperate numbers by comma? - MayaEU - 12.06.2016

weird, but thank you