I need some help with peace of code please -
DaneAMattie - 14.05.2010
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
Re: I need some help with peace of code please -
0ne - 14.05.2010
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.
Re: I need some help with peace of code please -
DaneAMattie - 14.05.2010
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'
Re: I need some help with peace of code please -
0ne - 14.05.2010
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?
Re: I need some help with peace of code please -
DaneAMattie - 14.05.2010
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++;
Re: I need some help with peace of code please -
DaneAMattie - 14.05.2010
oh and the error 017: undefined symbol "IsPlayerNpc" is just because it must be IsPlayerNPC
Re: I need some help with peace of code please -
0ne - 14.05.2010
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.
Re: I need some help with peace of code please -
DaneAMattie - 14.05.2010
Thanks man, it worked