Oh I see what you want.
You don't use periods for this, you use commas.
Code:
AddCommas(const input[], output[], const len)
{
new stop = contain(input, ".");
if(stop == -1)
{
stop = strlen(input);
}
new o, i;
while(i < stop && o < len)
{
output[o++] = input[i++];
if(o < len && i < stop && ((stop - i) % 3) == 0)
{
output[o++] = ',';
}
}
if(o < len)
{
o += copy(output[o], len - o, input[stop]);
}
return o;
}
Works for both integers and floats.
Code:
new iNum = 123456;
new szNum[ 12 ];
num_to_str( iNum, szNum, charsmax( szNum ) );
new szNumComma[ 15 ];
AddCommas( szNum, szNumComma, charsmax( szNumComma ) );
client_print( 0, print_chat, "%i is %s", iNum, szNumComma );
Code:
new Float:fNum = 123.456;
new szNum[ 16 ];
float_to_str( fNum, szNum, charsmax( szNum ) );
new szNumComma[ 19 ];
AddCommas( szNum, szNumComma, charsmax( szNumComma ) );
client_print( 0, print_chat, "%f is %s", fNum, szNumComma );
__________________