Message showing two times
#1

Code:
forward duelstart();
public duelstart()
{
	DuelCountdown --;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(InDuel[i] == true)
            {
				if(DuelCountdown == 5)
				{
				    GameTextForPlayer(i, "~r~5", 1000, 3);
				    PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
				if(DuelCountdown == 4)
				{
				    GameTextForPlayer(i, "~r~4", 1000, 3);
				    PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
				if(DuelCountdown == 3)
				{
				    GameTextForPlayer(i, "~r~3", 1000, 3);
				    PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
				if(DuelCountdown == 2)
				{
				    GameTextForPlayer(i, "~r~2", 1000, 3);
				    PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
				if(DuelCountdown == 1)
				{
				    GameTextForPlayer(i, "~r~1", 1000, 3);
				    PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
				}
				if(DuelCountdown == 0)
				{
					KillTimer(dueltimer);
					Duel = true;
	                new string[128];
	                format(string, sizeof(string), "Boxing duel between %s and %s started!", Dueler1, Dueler2);
	                SendClientMessageToAll(DUEL, string);
	                TogglePlayerControllable(i, 1);
	                GameTextForPlayer(i, "~g~BOX YOURSELF!", 2000, 3);
	                PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
				}
			}
		}
	}
	return 1;
}
I have this function in timer, it is 1000ms timer (1 second). The problem is, that when the DuelCountdown gets to 0, it like starts the duel twice (writes the Boxing duel between message twice). Do you guys have any reason why this could occur?
Reply
#2

You might want to change the
PHP Code:
SendClientMessageToAll(DUELstring); 
or add break in that last if condition
PHP Code:
if(DuelCountdown == 0)
{
/*your code*/
   
break;

It sends to all players and the loop still iterates for other players in duel too as no break in iteration is provided and therefore, it repeats the message.
Reply
#3

When i broke it there, one player (of the two) is not getting unfrozen (toggleplayercontrolable), how to fix this?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)