[Help] I got an error.
#1

Код:
new gTeam[MAX_PLAYERS];
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new tcount[2];
for(new i, m = GetMaxPlayers(); i < m; i++)
if(IsPlayerConnected(i))
tcount[gTeam]++; // <<<=================== THE ERROR LINE
if(tcount[gTeam[playerid]] > tcount[!gTeam[playerid]])
return SendClientMessage(playerid, RED, "To balance the teams, please select the other team."), 0;
return 1;
}
When I use these code i'll get an error I can't solve it :S

The error is
Код:
J:\Mini-Missions\Xtreme Tьrk Mini-Missions\gamemodes\campany.pwn(228) : error 033: array must be indexed (variable "gTeam")
Reply
#2

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  new tcount[2];
  for(new i=0; i<GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      tcount[gTeam[playerid]] ++;
      if(tcount[gTeam[playerid]] > tcount[!gTeam[playerid]])
      {
        SendClientMessage(playerid, RED, "To balance the teams, please select the other team.");
        return 0;
      }
    }
  }
  return 1;
}
Reply
#3

Quote:
Originally Posted by °ғαιιοцт°
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  new tcount[2];
  for(new i=0; i<GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      tcount[gTeam[playerid]] ++;
      if(tcount[gTeam[playerid]] > tcount[!gTeam[playerid]])
      {
        SendClientMessage(playerid, RED, "To balance the teams, please select the other team.");
        return 0;
      }
    }
  }
  return 1;
}
Do not work

There comes always To balance the theams, please select the other team. but there is nobody in each team
Reply
#4

I don't know what this function should do, all I did was removing the errors.
Reply
#5

Please anybody else who can help??
Reply
#6

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new tcount[2];
for(new i, m = GetMaxPlayers(); i < m; i++)
if(IsPlayerConnected(i))
tcount[gTeam[i]]++; // <<<=================== THE ERROR LINE
if(tcount[gTeam[playerid]] > tcount[gTeam[playerid]?0:1])
return SendClientMessage(playerid, RED, "To balance the teams, please select the other team."), 0;
return 1;
}
Note:Only works with 2 teams
Reply
#7

Quote:
Originally Posted by yezizhu
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new tcount[2];
for(new i, m = GetMaxPlayers(); i < m; i++)
if(IsPlayerConnected(i))
tcount[gTeam[i]]++; // <<<=================== THE ERROR LINE
if(tcount[gTeam[playerid]] > tcount[gTeam[playerid]?0:1])
return SendClientMessage(playerid, RED, "To balance the teams, please select the other team."), 0;
return 1;
}
Note:Only works with 2 teams
Don't work, I got always a message 'To balance the teams, please select the other team.' and it will not spawn
Reply
#8

Quote:

Don't work, I got always a message 'To balance the teams, please select the other team.' and it will not spawn
Код:
public OnPlayerRequestSpawn(playerid)
{
new tcount[2];
for(new i, m = GetMaxPlayers(); i < m; i++)
if(IsPlayerConnected(i))
tcount[gTeam[i]]++; 
if(tcount[gTeam[playerid]]-1 > tcount[gTeam[playerid]?0:1])
return SendClientMessage(playerid, RED, "To balance the teams, please select the other team."),0;
return 1;
}
Quote:
Код:
return SendClientMessage(playerid, RED, "To balance the teams, please select the other team."),0;
Awesome code lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)