Jump to content

Question

Posted

Vreau sa fac un script sa desparta banii de ex 10000 sa fie sub forma 10.000 in game.

Am facut stock dar nu imi apare, ce am gresit?

stock FormatMoney(Float:amount, delimiter[2]=".")
{
#define MAX_MONEY_STRING 16
new txt[MAX_MONEY_STRING];
format(txt, MAX_MONEY_STRING, "$%d", floatround(amount));
new l = strlen(txt);
if (amount < 0)
{
    if (l > 5) strins(txt, delimiter, l-3);
if (l > 8) strins(txt, delimiter, l-6);
if (l > 11) strins(txt, delimiter, l-9);
}
else
{
if (l > 4) strins(txt, delimiter, l-3);
if (l > 7) strins(txt, delimiter, l-6);
if (l > 10) strins(txt, delimiter, l-9);
}
return txt;
}

9 answers to this question

Recommended Posts

Posted

FormatNumber( number )

{

  new Str[ 15 ];

  format( Str, 15, "%d", number );

  if ( strlen( Str ) < sizeof( Str ) )

  {

      if ( number >= 1000 && number < 10000 )

            strins( Str, ".", 1, sizeof( Str ) );

           

      else if ( number >= 10000 && number < 100000 )

          strins( Str, ".", 2, sizeof( Str ) );

         

      else if ( number >= 100000 && number < 1000000 )

          strins( Str, ".", 3, sizeof( Str ) );

         

      else if ( number >= 1000000 && number < 10000000 )

          strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) );

         

      else if ( number >= 10000000 && number < 100000000)

          strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) );

         

      else if ( number >= 100000000 && number < 1000000000 )

          strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) );

         

      else if ( number >= 1000000000 && number < 10000000000 )

          strins( Str, ".", 1, sizeof( Str ) ),

          strins( Str, ".", 5, sizeof( Str ) ),

          strins( Str, ".", 9, sizeof( Str ) );

      else format( Str, 10, "%d", number );

  }

  else  format( Str, 15, "<ERROR>" );

  return Str;

}

asa il pun in script sau cum?

Posted

Folosire adica:

new Str[ 256 ],

          zMoney = GetPlayerMoney( playerid ) ;

 

    format( Str, sizeof (Str), "Ai $%s", FormatNumber( zMoney );

    SendClientMessage( playerid, 0xFF00FFFF, Str );

e pentru cand apelez comanda?

E bine si

new Str[ 128];
format( Str, 128, "Ai $%s", FormatNumber( GetPlayerMoney( playerid ) ) );
SendClientMessage( playerid, 0xFF00FFFF, Str );

Posted

FormatNumber( number )

{

  new Str[ 15 ];

  format( Str, 15, "%d", number );

  if ( strlen( Str ) < sizeof( Str ) )

  {

      if ( number >= 1000 && number < 10000 )

            strins( Str, ".", 1, sizeof( Str ) );

           

      else if ( number >= 10000 && number < 100000 )

          strins( Str, ".", 2, sizeof( Str ) );

         

      else if ( number >= 100000 && number < 1000000 )

          strins( Str, ".", 3, sizeof( Str ) );

         

      else if ( number >= 1000000 && number < 10000000 )

          strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) );

         

      else if ( number >= 10000000 && number < 100000000)

          strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) );

         

      else if ( number >= 100000000 && number < 1000000000 )

          strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) );

         

      else if ( number >= 1000000000 && number < 10000000000 )

          strins( Str, ".", 1, sizeof( Str ) ),

          strins( Str, ".", 5, sizeof( Str ) ),

          strins( Str, ".", 9, sizeof( Str ) );

      else format( Str, 10, "%d", number );

  }

  else  format( Str, 15, "<ERROR>" );

  return Str;

}

asa il pun in script?

pun cu public FormatNumber( number )

sau stock FormatNumber( number )

sau cum?

Posted

FormatNumber( number )

{

  new Str[ 15 ];

  format( Str, 15, "%d", number );

  if ( strlen( Str ) < sizeof( Str ) )

  {

      if ( number >= 1000 && number < 10000 )

            strins( Str, ".", 1, sizeof( Str ) );

           

      else if ( number >= 10000 && number < 100000 )

          strins( Str, ".", 2, sizeof( Str ) );

         

      else if ( number >= 100000 && number < 1000000 )

          strins( Str, ".", 3, sizeof( Str ) );

         

      else if ( number >= 1000000 && number < 10000000 )

          strins( Str, ".", 1, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) );

         

      else if ( number >= 10000000 && number < 100000000)

          strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 6, sizeof( Str ) );

         

      else if ( number >= 100000000 && number < 1000000000 )

          strins( Str, ".", 3, sizeof( Str ) ),strins( Str, ".", 7, sizeof( Str ) );

         

      else if ( number >= 1000000000 && number < 10000000000 )

          strins( Str, ".", 1, sizeof( Str ) ),

          strins( Str, ".", 5, sizeof( Str ) ),

          strins( Str, ".", 9, sizeof( Str ) );

      else format( Str, 10, "%d", number );

  }

  else  format( Str, 15, "<ERROR>" );

  return Str;

}

asa il pun in script?

Ala il pui undeva in script ( jos in script de preferat ), iar apoi il folosesti asa:

stuntman[]! link=topic=13870.msg84786#msg84786 date=1310574669]

new Str[ 128];
format( Str, 128, "Ai $%s", FormatNumber( GetPlayerMoney( playerid ) ) );
SendClientMessage( playerid, 0xFF00FFFF, Str );
Sfat: Pentru coduri foloseste [nobbc]
//cod\\

[/nobbc]

Posted

asta las putea folosi sa imi delimiteze si suma de la /stats adica cash si bank?

Da, poti sa-l folosesti oricum, exemplu:

FormatNumber( Bank[ playerid ][ Money ] ); //doar un exemplu !
FormatNumber( GetPlayerMoney( playerid ) ); //doar un exemplu !
//iar astea vin cam asa:
FormatNumber( 5000000 ); //va veni 5.000.000

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.