SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/05/2020, 06:59 AM   #1
_GHT_MarK445
Huge Clucker
 
Join Date: Oct 2010
Posts: 303
Reputation: 11
Default Message showing two times

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?
_GHT_MarK445 is offline   Reply With Quote
Old 05/05/2020, 07:15 AM   #2
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: Message showing two times

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.
SyS is offline   Reply With Quote
Old 06/05/2020, 02:38 PM   #3
_GHT_MarK445
Huge Clucker
 
Join Date: Oct 2010
Posts: 303
Reputation: 11
Default Re: Message showing two times

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing the same name two times Groc Scripting Help 1 18/03/2017 05:42 PM
Message displayes more times AndreiWow Scripting Help 5 30/08/2016 10:23 PM
Message appear four times AndreiWow Scripting Help 5 30/08/2016 08:04 AM
Heelo need help with pen:ls (Multiple times showing OnPlayerUpdate) trapped1 Scripting Help 3 15/02/2012 04:59 AM
Message comes up 50 times insted of once JoeeeFm8 Help Archive 14 27/12/2009 12:48 PM


All times are GMT. The time now is 03:30 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.