20.12.2009, 15:24
pawn Код:
CreatePrice( Formatprice )
{
new
PriceStr[ 25 ] ,
formatted[ 25 ];
format( PriceStr , sizeof( PriceStr ) , "%d" , Formatprice );
formatted = addCommas( PriceStr );
return formatted;
}
addCommas( price[ 25 ] )
{
new
len = strlen( price );
if( len <= 3 )
{
return price;
}
new
offset = len ,
returnstr[ 25 ] ,
tempstr[ 25 ] ,
dots;
while( offset >= 3 )
{
offset = offset - 3;
strmid( tempstr , price , offset , ( offset + 3 ) );
if( dots == 0 )
{
returnstr = tempstr;
}
else
{
format( returnstr , sizeof( returnstr ) , "%s.%s" , tempstr , returnstr );
}
dots++;
}
if( offset > 0 )
{
strmid( tempstr , price , 0 , offset );
format( returnstr , sizeof( returnstr ) , "%s.%s" , tempstr , returnstr );
}
return returnstr;
}