I need some help with peace of code please
#1

Hello,

I found this peace of code somewhere on the internet:

ReturnPlayersInTeam(teamid)
{
new t;
for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++)if(gTeam[a]==teamid)t++;

return t;

}

Now what this do, it will return a value with the amount of people in a team
but my problem is it also detects NPC's so i want to bypass them using this:

if(IsPlayerNPC(playerid))
{
return 1;
}

but i have no idea how to put this code into that for(new a; etc.) code

I hope you guys respond fast with some answers

Thanks,

ikbenhet
Reply
#2

pawn Код:
ReturnPlayersInTeam(teamid)
{
  if(!IsPlayerNpc(playerid))
  {
    new t;
    for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++)if(gTeam[a]==teamid)t++;
    return t;
  }
}
try it.
Reply
#3

Quote:
Originally Posted by 0ne
pawn Код:
ReturnPlayersInTeam(teamid)
{
  if(!IsPlayerNpc(playerid))
  {
    new t;
    for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++)if(gTeam[a]==teamid)t++;
    return t;
  }
}
try it.
i tried, but there is a problem because playerid dont exist in that function so it must be the 'a' one but when i put instead of playerid a it sais undefined symbol 'a'
Reply
#4

OH right, didn't see that.

pawn Код:
ReturnPlayersInTeam(teamid)
{
    new t;
    for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++) && if(!IsPlayerNpc(a)) if(gTeam[a]==teamid)t++;
    return t;
}
how about this?
Reply
#5

Quote:
Originally Posted by 0ne
OH right, didn't see that.

pawn Код:
ReturnPlayersInTeam(teamid)
{
    new t;
    for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++) && if(!IsPlayerNpc(a)) if(gTeam[a]==teamid)t++;
    return t;
}
how about this?
**\SW.pwn(1553) : error 029: invalid expression, assumed zero
**\SW.pwn(1553) : warning 215: expression has no effect
**\SW.pwn(1553) : error 001: expected token: ";", but found "if"
**\SW.pwn(1553) : error 017: undefined symbol "IsPlayerNpc"
**\SW.pwn(1553) : fatal error 107: too many error messages on one line

and line 1553 = for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++) && if(!IsPlayerNpc(a)) if(gTeam[a]==teamid)t++;
Reply
#6

oh and the error 017: undefined symbol "IsPlayerNpc" is just because it must be IsPlayerNPC
Reply
#7

pawn Код:
ReturnPlayersInTeam(teamid)
{
    new t;
    for(new a;a<MAX_PLAYERS,IsPlayerConnected(a);a++)
    {
        if(!IsPlayerNPC(a))
        {
            if(gTeam[a]==teamid)t++;
            return t;
        }
    }
}

Sorry, just woke up can't get things right, this should totaly work lol.
Reply
#8

Thanks man, it worked
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)