For loop not working
#1

Hello Guys. I am having a little trouble with my For Loop.
The Public: "Verify_ITAU" is called 1 time, with NO LOOPING.

Here is my code:
Код:
public Verify_ITAU()
{
	if(ITAU_FASE == 3)
	{
	    new Cont = 0;
	    for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
			    if(BankRobbery[i] == true)
			    {
                    if(IsPlayerInRangeOfPoint(i, 20.0, 829.0986,6.4355,1004.1870) || IsPlayerInRangeOfPoint(i, 300.0, 700.5287,-1162.6360,15.5628)) // Center of the Bank
			    	{
                        Cont++;
			    	}
		    	    if(Cont > 0) // if has anyone in area
                    {
                        SetTimer("Verify_ITAU", 15000, false);
                    }
                    else if(Cont == 0)
                    {
						new ExpGanho = 15; // not Important, giving Experience for player
                        Entrada_ITAU_Trancado = true; // Not Important, Locking the Bank's door.
                        SendClientMessage(i, COLOR_WHITE, "Conseguiu assaltar com sucesso!"); // the msg said: "Robbery sucess"
                        AssaltandoBanco[i] = false; // set the Player Var to false, not important here.
						PlayerInfo[i][pCash] = (PlayerInfo[i][pCash] + Grana_COFRES[i]); // giving money to player
						Grana_COFRES[i] = 0; // setting the money robbed of the player to 0 (var of the player)
						ITAU_FASE = 4; // this is the Phase (sequence)
						GameTextForPlayer(i, "~g~conseguiu!", 5000, 4); // "You did it"
						KillTimer(ALARME_TIMER); // Stopping the Alarm Sound
						SetTimerEx("GanhoExp", 6500, false, "i", i); // Giving the MSG "EXP +"
      				}
				}
			}
		}
	}
	if(ITAU_FASE == 4)
	{
		for(new w = 0; w < MAX_PLAYERS; w++)
		{
			if(IsPlayerConnected(w))
			{
			    SendClientMessage(w,COLOR_AVISO, "Banco ITAЪ trancado! Quem estiver dentro SAIA IMEDIATAMENTE. O Interior serб resetado dentro de 5 minutos. (2)"); // "ITAU BANK locked! Who is inside it, get out now. The interior will be reset in 5 minutes.(2)"
			}
		}
	}
	return 1;
}
And the Result INGAME (screenshot): http://i.imgur.com/aK4HS7Q.png

As you can see, its giving 8 Times the Message. Dont know why. In my point, have no reason for this is happening.
Reply
#2

The function is called 8 times (only explanation).

= timer issue
Reply
#3

Hint: if you expect help here, code in English. I can't be bothered to dissect a piece of code if I can't understand its context.
Reply
#4

Exactly what Vince said, It's pretty annoying...
Reply
#5

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Exactly what Vince said, It's pretty annoying...
Quote:
Originally Posted by Vince
Посмотреть сообщение
Hint: if you expect help here, code in English. I can't be bothered to dissect a piece of code if I can't understand its context.
I traslated now.
Try to read now. Thanks.
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
The function is called 8 times (only explanation).

= timer issue
I dont think so. Because the Public "Verify ITAU" is called 1 time, with Loop: false. And the this public ONLY WILL BE CALLED AGAIN in this line:
Код:
Cont++;
}
if(Cont > 0) // if has anyone in area
{
           SetTimer("Verify_ITAU", 15000, false);
}
Cont = the number of the people inside area. If there is no one inside, Cont will be = 0 . And will not pass the If (Cont > 0) resulting not calling the
Код:
SetTimer("Verify_ITAU", 15000, false);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)