[SOLVED] $10000 > $10.000
#2

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;
}
Note that this is not made by me, I got it from someone, can't remember who send it.
Reply


Messages In This Thread
[SOLVED] $10000 > $10.000 - by GTAguillaume - 20.12.2009, 15:16
Re: [HELP] $10000 > $10.000 - by Marcel - 20.12.2009, 15:24
Re: [SOLVED] $10000 > $10.000 - by GTAguillaume - 20.12.2009, 15:54

Forum Jump:


Users browsing this thread: 1 Guest(s)