SA-MP Forums Archive
[Help] I got an error. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] I got an error. (/showthread.php?tid=87948)



[Help] I got an error. - RyDeR` - 23.07.2009

Код:
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")



Re: [Help] I got an error. - ғαιιοцт - 23.07.2009

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;
}



Re: [Help] I got an error. - RyDeR` - 23.07.2009

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


Re: [Help] I got an error. - ғαιιοцт - 23.07.2009

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


Re: [Help] I got an error. - RyDeR` - 23.07.2009

Please anybody else who can help??


Re: [Help] I got an error. - yezizhu - 23.07.2009

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


Re: [Help] I got an error. - RyDeR` - 23.07.2009

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


Re: [Help] I got an error. - yezizhu - 23.07.2009

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