Special Teaming System
#1

I'm trying to make a teaming system in which a certain number of players are assigned to team B depending on how many are on team A. I'll give an example: if 4 players are assigned to team A, 1 person is assigned to team B. How would I code this?
Reply
#2

pawn Код:
new teamA=0;

public OnPlayerConnect(playerid)
{
    if(teamA==4){
        //Do whatever here to put that player into team B
        teamA=0;
    }

    if(teamA<4){
        teamA++;
        //Do whatever here to put that player into team A
    }
}
Reply
#3

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

public OnPlayerConnect(playerid)
{
    if(teamA==4){
        //Do whatever here to put that player into team B
        teamA=0;
    }

    if(teamA<4){
        teamA++;
        //Do whatever here to put that player into team A
    }
}
I guess I should have specified that for every 4 players in a server on team A, there should be 1 on team B. The way I said it made it sound like 4 is the max number.
Reply
#4

The piece of code I sent you does exactly that

If there's 4 on team A, it adds one to team B. Then resets the variable back to 0, so it starts counting again.
Reply
#5

Quote:
Originally Posted by DrDoom151
Посмотреть сообщение
The piece of code I sent you does exactly that

If there's 4 on team A, it adds one to team B. Then resets the variable back to 0, so it starts counting again.
Oh, okay. Thank you, then. I've got another question now. I want to assign people to 3 different teams randomly. I'm a little rusty on coding and I'm having a brainfart. How do I do that?
Reply
#6

Place this somewhere:
pawn Код:
stock randomEx(minnum = cellmin, maxnum = cellmax){
    return random(maxnum - minnum + 1) + minnum;}

Then:
pawn Код:
public OnPlayerConnect(playerid)
{
    new team = randomEx(1,4); //I believe this would generate a number between 1 and 3, but it might be 1 and 4. Try it out ;)

    //Insert your code here. For example: SetPlayerCustomTeam(playerid, team);
}
Hope this helps
Reply
#7

Quote:
Originally Posted by DrDoom151
Посмотреть сообщение
Place this somewhere:
pawn Код:
stock randomEx(minnum = cellmin, maxnum = cellmax){
    return random(maxnum - minnum + 1) + minnum;}

Then:
pawn Код:
public OnPlayerConnect(playerid)
{
    new team = randomEx(1,4); //I believe this would generate a number between 1 and 3, but it might be 1 and 4. Try it out ;)

    //Insert your code here. For example: SetPlayerCustomTeam(playerid, team);
}
Hope this helps
I realized I don't even need that. Lol. Thanks for the help.

EDIT: fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)