14.05.2014, 07:43
Use switch statement, it's much faster than using if-else statements.
pawn Код:
stock GiveMoney(playerid,money)
{
new str[64];
switch(money)
{
case 1 .. 9: format(str, sizeof(str), "$0000000%d", money);
case 10 .. 99: format(str, sizeof(str), "$000000%d", money);
case 100 .. 999: format(str, sizeof(str), "$00000%d", money);
case 1000 .. 9999: format(str, sizeof(str), "$0000%d", money);
case 10000 .. 99999: format(str, sizeof(str), "$000%d", money);
case 100000 .. 999999: format(str, sizeof(str), "$00%d", money);
case 1000000 .. 9999999: format(str, sizeof(str), "$00%d", money);
case 10000000 .. 99999999: format(str, sizeof(str), "$0%d", money);
case 100000000 .. 999999999: format(str, sizeof(str), "$%d", money);
default: format(str, sizeof(str), "$00000000");
TextDrawSetString(ShowMoneyEarned[playerid], str);
}
pInfo[playerid][pMoney] += money;
TextDrawShowForPlayer(playerid, ShowMoneyEarned[playerid]);
return 1;
}