max players in team
#1

Hello community,

I' m searching for long time now something with teams.
I have 4 teams but I don't want a team balance I want something like 2 players max in this team 10 in the others if there is less than 10 players in it you can join it or if it's 10 players so full, you can't (you click spawn but nothing happen).

(If someone can reminding me how to post code thanks (: )

Thanks for helping
Reply
#2

Ok, first create a global variable (on the GM/FS top [depends what your using] )

pawn Код:
new count = 0;

And on the command / class selection, which redirects player for the team, add (DEPENDS WHAT YOUR USING) :
pawn Код:
count++;

Also add the condition on the samewhere:
pawn Код:
if(count > 2) return GameTextForPlayer(playerid,"~r~There are already 2 people on this team",5000,5);
Reply
#3

how to post code ?
I want show you mine
Reply
#4

Quote:
Originally Posted by gereter
Посмотреть сообщение
how to post code ?
I want show you mine
[pawn] [ /pawn]

Without the spaces.
Reply
#5

OK thank you so here it is :

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(count > 2) return GameTextForPlayer(playerid,"~r~There are already 2 people on this team",5000,5);
    if(gTeam[playerid] == BODYGUARD)
    {
        count++;
    }
    return 1;
}
Is it here?
I want do 2 max only for bodyguard ...
Reply
#6

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == BODYGUARD)
    {
        count++;
        if(count > 2) return GameTextForPlayer(playerid,"~r~There are already 2 people on this team",5000,5);
    }
    return 1;
}
Try that.
Reply
#7

I did and i have one warning:

pta.pwn(970) : warning 219: local variable "count" shadows a variable at a preceding level
Reply
#8

Delete the:
pawn Код:
new count = 0;

On the top. It means the simbol is already defined, but the second one isn't in use. So, delete that
Reply
#9

Quote:
Originally Posted by blackwave
Посмотреть сообщение
Delete the:
pawn Код:
new count = 0;

On the top. It means the simbol is already defined, but the second one isn't in use. So, delete that
Why did you add that in?

It's not needed because it will always start from 0 unless you make it start at a different number.
Reply
#10

pta.pwn(257) : error 017: undefined symbol "count"
pta.pwn(257) : warning 215: expression has no effect
pta.pwn(25 : error 017: undefined symbol "count"

xD was better before
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)