[SOLVED] $10000 > $10.000 - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] $10000 > $10.000 (
/showthread.php?tid=114714)
[SOLVED] $10000 > $10.000 -
GTAguillaume - 20.12.2009
How can i make a script that change intiger into money notation?
I tryed to make this, but it returns nothing:
pawn Код:
stock inttomoney(money)
{
new string2[256];
new string[256];
format(string,sizeof(string),"%i",money);
format(string2,sizeof(string2),"%i",money);
new lang = strlen(string2);
new totallang = lang+(lang/3);
new idx=lang;
for(new i;i<((lang/3)-1);i++)
{ //make space free for points
new idx2;
while(idx2 < lang)
{
string[idx2-1-(lang/3)] = string2[idx2];
idx2++;
}
string[i] = ' ';
}
for(new s=1;s<totallang;)
{
s*=3;
idx = lang-s;
if((lang-s) < 3)
{
for(new i=lang-s;i<s;i--)
{
string[idx-i] = string2[idx-i];
}
string[idx] = '.';
} else
{
for(new i=3;i<0;i--)
{
string[idx-i] = string2[idx-i];
}
string[idx] = '.';
}
}
return string;
}
Re: [HELP] $10000 > $10.000 -
Marcel - 20.12.2009
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.
Re: [SOLVED] $10000 > $10.000 -
GTAguillaume - 20.12.2009
Thank you very mutch