SA-MP Forums Archive
AddCommas issue. - 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: AddCommas issue. (/showthread.php?tid=565334)



AddCommas issue. - Dokins - 26.02.2015

pawn Код:
stock AddCommas(number)
{
    new
        tStr[13]; // Up to 9,999,999,999,999

    format(tStr,sizeof(tStr),"%d",number);

    if(strlen(tStr) < 4)
    return tStr;

    new
        //rNumber = floatround((number+(number/3)),floatround_floor),
        iPos = strlen(tStr),
        iCount = 1;

    while(iPos > 0)
    {
    if(iCount == 4)
    {
        iCount = 0;
        strins(tStr,",",iPos,1);
            iPos ++;
        }

        iCount ++;
        iPos --;
    }
    return tStr;
}
I use this, which is found at :
https://sampwiki.blast.hk/wiki/AddCommas

But for some reason this function doesn't work, it makes everything '49' strangely.
I'm using it here.

pawn Код:
format(string, sizeof(string), "Welcome to San Fierro Roleplay, %s Level: %d | Money: $%d | Admin Level: %d | Donator Level %d |", GetNameEx(playerid), PlayerLevel[playerid],AddCommas(PlayerMoney[playerid]), AdminLevel[playerid], Donator[playerid]);
EDIT: I REALISE IT'S A STRING. IGNORE.


Re: AddCommas issue. - Aerotactics - 26.02.2015

Quote:

it makes everything '49' strangely

Elaborate please.


Re: AddCommas issue. - Schneider - 26.02.2015

@Aerotactics: He already solved it. (Read the last line...)