Jump to content

Question

10 answers to this question

Recommended Posts

Posted

pai daca ai antichat (oricine are) o sa se incurce cu ip de la alt svr si nu o poti face am avut si eu si cu virgula si cu punct .. si se incurcau cand playeri scriau suma de bani in orice chat..

Guest PlayON
Posted

pai daca ai antichat (oricine are) o sa se incurce cu ip de la alt svr si nu o poti face am avut si eu si cu virgula si cu punct .. si se incurcau cand playeri scriau suma de bani in orice chat..

Nu orice chat, exista doar un chat, nu se referea la bani scrisi in chat, ci cand vede cati bani are sa le puna virgula.

Iote! aici:


Functia:

FormatNumber( number )

{

new Str[ 10 ];

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

if ( strlen( Str ) != 0 )

{

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, ".", 4, sizeof( Str ) );

else if ( number >= 10000000 && number < 100000000 )strins( Str, ".", 2, sizeof( Str ) ),strins( Str, ".", 5, sizeof( Str ) );

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

}

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

return Str;

}

Folosire:

CMD:stats( playeid )

{

    new Str[ 256 ];

   

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

    SendClientMessage( playerid, 0xFF00FFFF, Str );

 

    return 1;

}

Rezultat:

Daca ai sa zicem, 15999555. Ar iesi $15.999.555

De notat:

- Cand folosesti aceasta functie, foloseste-o inlocul functii GetPlayerMoney sau variabilei care o ai tu

- Cand o folosesti ai grija sa folosesti %s nu %d deoarece functia FormatNumber returneaza un string!

- Daca vrei sa mearga cu sume mai mari de genu $150.000.500 modifica-o singur ca sti atata!

- Am adaugat-o la functii folositoare!

- Daca inloc de bani primesti <ERROR> inseamna ca ceva nu a mers bine, orinumarul este prea mare ca sa incapa in stringul new Str[ 10 ], adica depaseste 10 caractere.

Guest PlayON
Posted

Sryy ca deschid iar topicu, dar am o problema..

De ce imi apare 70.00.0000 ?:-?? de la 8 cifre in sus asa-mi apare, si n-am modificat nimic?:(

Ai modificat tu codul? Vezi la strins, numarul acela reprezinta locatia punctului.

1.000.000 ar veni strins...1 strins...4.

Posted

N-am modificat nimic.. uite..

FormatNumber(number)
{
   new Str[256];
   format(Str, 256, "%d", number);

   if (strlen(Str) != 0)
   {
      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, ",", 4, sizeof(Str));
      else if (number >= 10000000 && number < 100000000)strins(Str, ",", 2, sizeof(Str)),strins(Str, ",", 5, sizeof(Str));
      else format(Str, 10, "%d", number);
   }
   else  format(Str, 256, "<ERROR>");
   return Str;
}

 

Guest PlayON
Posted

N-am modificat nimic.. uite..

FormatNumber(number)
{
   new Str[256];
   format(Str, 256, "%d", number);

   if (strlen(Str) != 0)
   {
      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, ",", 4, sizeof(Str));
      else if (number >= 10000000 && number < 100000000)strins(Str, ",", 2, sizeof(Str)),strins(Str, ",", 5, sizeof(Str));
      else format(Str, 10, "%d", number);
   }
   else  format(Str, 256, "<ERROR>");
   return Str;
}

Sunt confuz pana si eu, tre sa verific in amanunt! Revin cu edit!

Guest PlayON
Posted

Ok,dar nush de ce nu mai merge, doar bine mia mers pana aseara.. :-s ..., poate ca il folosesc in prea multe locuri FormatNumber(etc..) ... poate fi o cauza?

Nu, deoarece odata procesata, ramane procesata, nu v-a afecta celelalte functii sau altceva!

Am rezolvat problema, dar inca o problema s-a ivit, maximu de bani care poti sa-l ai e... egal cu sau peste 1.410.000.000 ( Un miliard si 410 de milioane) deoarece atata este numaru cat il poate duce PAWN, deci este vina lu PAWN nu a noastra!

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;

}

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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.