SA-MP Forums Archive
Loop Spam - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Loop Spam (/showthread.php?tid=498887)



Loop Spam - Chrillzen - 05.03.2014

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;
    }
}



Re: Loop Spam - Lajko1 - 05.03.2014

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


Re: Loop Spam - doreto - 05.03.2014

... then change Payday timer to something you like.


Re: Loop Spam - Chrillzen - 05.03.2014

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..


Re: Loop Spam - Konstantinos - 05.03.2014

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.


Re: Loop Spam - Chrillzen - 06.03.2014

@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.