Jump to content

script Rozdělení peněz ( 1 200 000 $ ) SplitMoney


FreeWall

Recommended Posts

Čau. Už jsem dlouho něco nenapsal, tak sem hodim jednoduchej scriptík (pro zpřehlednění) na rozdělení čísla (nejčastěji peněz) podle řádů (po třech), nazval jsem jí SplitMoney. Snad se to bude někomu hodit. Jestli to tu už je tak sem jen zabil nudu :d

 

Použití:

SplitMoney(12053012) = "12 053 012"

 

stock SplitMoney(money){
   new d,string[14],string2[11];
   format(string2,sizeof(string2),"%d",money);
   for(new i=strlen(string2)-1;i>=0;i--){
       new string3[2];
       strmid(string3,string2,i,i+1);
       if(d%3 == 0 && i != strlen(string2)-1) format(string,sizeof(string),"%s %s",string3,string);
       else format(string,sizeof(string),"%s%s",string3,string);
       d ++;
   }
   return string;
}

- parametr funkce je celé číslo (integer)

- funkce vrací řetězec (string)

 


Příklad:

 

new penize = GetPlayerMoney(playerid); // hráč bude mít např. 12053012 $
new string[256];
format(string, sizeof(string), "U sebe máte %s dolarů", SplitMoney(penize));
SendClientMessage(playerid, COLOR_WHITE, string);

řětezec string se nám promění v "U sebe máte 12 053 012 dolarů"

Link to comment
Share on other sites

Nikdo ti sem nepíše, tak abys nebyl smutnej, tak já budu 1. :d

 

Je to pěkné, mohlo by se hodit pro nějáký ty RP ale já to neuvyužiju.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...