Special Teaming System - 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)
+--- Thread: Special Teaming System (
/showthread.php?tid=416877)
Relative Teaming System -
austin070 - 18.02.2013
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?
Re: Special Teaming System -
DrDoom151 - 18.02.2013
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
}
}
Re: Special Teaming System -
austin070 - 18.02.2013
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.
Re: Special Teaming System -
DrDoom151 - 18.02.2013
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.
Re: Special Teaming System -
austin070 - 18.02.2013
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?
Re: Special Teaming System -
DrDoom151 - 18.02.2013
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
Re: Special Teaming System -
austin070 - 18.02.2013
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.