Loop Spam
#1

Hi. I'm a real newbie with loops. Can anyone help me? This whole function is spammed every hour.

pawn Код:
public Payday()
{
    foreach (new i : Player)
    {
            new wstring[256];
            new randcheck = 20 + random(300);
            new interest = (PlayerInfo[i][pBankAccount]/1000)*(intrate);
            new newbank = PlayerInfo[i][pBankAccount] + randcheck;
            new randtax = 5 + random(20);

            SCM(i, -1, "___________________[PAYDAY INFORMATION]___________________");
            format(wstring, sizeof(wstring), "~w~PayDay ~n~~g~$%d", randcheck);
            GameTextForPlayer(i, wstring, 3000, 1);
            PlayerInfo[i][pBankAccount] += randcheck;

            format(wstring, sizeof(wstring), "PayCheck: $%d", randcheck);
            SendClientMessage(i,COLOR_WHITE, wstring);
            format(wstring, sizeof(wstring), "Interest Gained: $%d, Interest Rate: 0.%d percent.", interest, intrate);
            SendClientMessage(i,COLOR_WHITE, wstring);
            format(wstring, sizeof(wstring), "Government Taxes: $-%d.", randtax);
            SendClientMessage(i,COLOR_WHITE, wstring);
            format(wstring,sizeof(wstring), "New bank balance: $%d", newbank);
            SCM(i, COLOR_WHITE, wstring);
            PlayerInfo[i][pBankAccount] += interest;
            PlayerInfo[i][pBankAccount] -= randtax;
            PlayerInfo[i][pPlayingHours] += 1;
            break;
    }
}
Reply
#2

Maybe you should add return ? As I know this stops the code, but I'm not sure
Reply
#3

... then change Payday timer to something you like.
Reply
#4

Quote:
Originally Posted by doreto
Посмотреть сообщение
... then change Payday timer to something you like.
It's supposed to happen every hour. But it's not supposed to get spammed..
Reply
#5

Quote:
Originally Posted by Chrillzen
Посмотреть сообщение
It's supposed to happen every hour. But it's not supposed to get spammed..
How does it get spammed, would you mind to say few more information so we can understand what happens?

Quote:
Originally Posted by Lajko1
Посмотреть сообщение
Maybe you should add return ? As I know this stops the code, but I'm not sure
break; stops the loop.
Reply
#6

@Konstantinos Everything in that code repeats itself like 100 times or something. I just want it to show once every hour not 100 times every hour.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)