SA-MP Forums Archive
Will this work? - 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: Will this work? (/showthread.php?tid=575108)



Will this work? - Blackazur - 24.05.2015

Will this work?

Код:
    if(playerOnline >= 2 || 4 || 6 || 8)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 0 || 1 || 2 || 3)
	   {
	       TeamBalance();
	   }
	}



Re: Will this work? - LMaxCo - 24.05.2015

Why you didn't search answered of your theread with testing it? xD


Re: Will this work? - SickAttack - 24.05.2015

This:
pawn Код:
switch(playerOnline)
{
    case 2..8:
    {
        switch(GetTeamPlayersAlive(TEAM_RED))
        {
            case 0..3:
            {
                TeamBalance();
            }
        }
    }
}
Or:
pawn Код:
if(playerOnline >= 2 && playerOnline <= 8)
{
   if(GetTeamPlayersAlive(TEAM_RED) >= 0 && GetTeamPlayersAlive(TEAM_RED) <= 3)
   {
       TeamBalance();
   }
}
Will work, yours won't. You can't do this "|| 1 || 2 || 3", you have to add the full condition.


AW: Will this work? - Blackazur - 24.05.2015

And
Код:
if(playerOnline >= 2 && playerOnline <= 8)
{
   if(GetTeamPlayersAlive(TEAM_RED) >= 0 && GetTeamPlayersAlive(TEAM_RED) <= 3)
   {
       TeamBalance();
   }
}
will do the same like

Код:
   if(playerOnline >= 2 || 4 || 6 || 8)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 0 || 1 || 2 || 3)
	   {
	       TeamBalance();
	   }
	}
?


Re: AW: Will this work? - SickAttack - 24.05.2015

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
And
Код:
if(playerOnline >= 2 && playerOnline <= 8)
{
   if(GetTeamPlayersAlive(TEAM_RED) >= 0 && GetTeamPlayersAlive(TEAM_RED) <= 3)
   {
       TeamBalance();
   }
}
will do the same like

Код:
   if(playerOnline >= 2 || 4 || 6 || 8)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 0 || 1 || 2 || 3)
	   {
	       TeamBalance();
	   }
	}
?
Yes, yes it will.


AW: Will this work? - Blackazur - 24.05.2015

Also it will for example like if there are 2 players online, it will check automatically and switch one player to TEAM_RED? Without checking if playerOnline is 4 for example?


Re: Will this work? - SickAttack - 24.05.2015

Let me translate that for you:
pawn Код:
if(playerOnline >= 2 && playerOnline <= 8)
{
   if(GetTeamPlayersAlive(TEAM_RED) >= 0 && GetTeamPlayersAlive(TEAM_RED) <= 3)
   {
       TeamBalance();
   }
}

if the variable "playerOnline" is above or equal to 2 AND if the variable "playerOnline" is below or equal to 3 => CONTINUE SEQUENCE
{
    if the condition "GetTeamPlayersAlive(TEAM_RED)" is above or equal to 0 AND if the condition "GetTeamPlayersAlive(TEAM_RED)" is below or equal to 3 => CONTINUE SEQUENCE
    {
        if all the conditions above are TRUE => PERFORM "TeamBalance();"
    }
}
It depends on what the variable "playerOnline" holds.


AW: Will this work? - Blackazur - 24.05.2015

Ok thank you but please help me if i want to do it like that, this doesn't work, can you fix it?

Код:
    if(playerOnline >= 2)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 0)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 4)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 1)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 6)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 2)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 8)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 3)
	   {
	       TeamBalance();
	   }
	}



Re: AW: Will this work? - SickAttack - 24.05.2015

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
Ok thank you but please help me if i want to do it like that, this doesn't work, can you fix it?

Код:
    if(playerOnline >= 2)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 0)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 4)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 1)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 6)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 2)
	   {
	       TeamBalance();
	   }
	}
	
    if(playerOnline >= 8)
	{
	   if(GetTeamPlayersAlive(TEAM_RED) == 3)
	   {
	       TeamBalance();
	   }
	}
pawn Код:
if(playerOnline >= 2 && GetTeamPlayersAlive(TEAM_RED) == 0) TeamBalance();
else if(playerOnline >= 4 && GetTeamPlayersAlive(TEAM_RED) == 1) TeamBalance();
else if(playerOnline >= 6 && GetTeamPlayersAlive(TEAM_RED) == 2) TeamBalance();
else if(playerOnline >= 8 && GetTeamPlayersAlive(TEAM_RED) == 3) TeamBalance();



AW: Will this work? - Blackazur - 24.05.2015

This doesn't work it just checks the first line of it, can you fix it?