SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 31/07/2019, 03:47 AM   #1
soobya
Little Clucker
 
Join Date: Mar 2017
Posts: 28
Reputation: 0
Default TEAM Limit Help!

hi i want to Limit 4 teams like TEAM_ONE TEAM_TWO TEAM_THREE TEAM_FOUR
i want Limit Teams becuase everyone join team one or two like 10 players from team_one also team_two 7 players but team_three and team_four Just 1 or 2 players
and Thanks
soobya is offline   Reply With Quote
Old 31/07/2019, 07:18 AM   #2
Hammad123
Big Clucker
 
Join Date: Jan 2017
Location: Locating...
Posts: 91
Reputation: 1
Default Re: TEAM Limit Help!

#DEFINE TEAM_ONE 0
#DEFINR TEAM_TWO 1
#DEFINE TEAM_THREE 2
#DEFINE TEAM_FOUR 3
Hammad123 is offline   Reply With Quote
Old 31/07/2019, 07:52 AM   #3
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 323
Reputation: 22
Default Re: TEAM Limit Help!

pawn Code:
#define TEAM_NONE 255
#define TEAM_ONE 1
#define TEAM_TWO 2
#define TEAM_THREE 3
#define TEAM_FOUR 4

new count = (team1players+team2players); // counts how many players are in team1 and team2

if(count < 10) // if team 1 and 2 players are lesser than 10, it will execute this if statement
{
      if(team1players <= team2players)
      {
          team1players++;
          SetPlayerTeam(playerid, TEAM_ONE);
      }
      else if(team2players <= team1players)
      {
          team2players++;
          SetPlayerTeam(playerid, TEAM_TWO);
      }
}
else // else if team 1 and 2 players are greater than 10 , it will execute this else statement
{
        if(team3players <= team4players)
        {
           team3players++;
           SetPlayerTeam(playerid, TEAM_THREE);
        }
        else if(team4players <= team3players)
        {
           team4players++;
           SetPlayerTeam(playerid, TEAM_FOUR);
        }
}


CMD:resetteam(playerid) return SetPlayerTeam(playerid, TEAM_NONE);
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 31/07/2019, 08:09 AM   #4
soobya
Little Clucker
 
Join Date: Mar 2017
Posts: 28
Reputation: 0
Default Re: TEAM Limit Help!

not working i want to Limiting Players Per Teams
no more players from team_one or team_two or team_three or team_four
and thanks!
soobya is offline   Reply With Quote
Old 31/07/2019, 08:12 AM   #5
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 323
Reputation: 22
Default Re: TEAM Limit Help!

You need 10 players in team 1 and 7 players in team 2 and 2-4 players in team 3 and 4?
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 31/07/2019, 08:14 AM   #6
soobya
Little Clucker
 
Join Date: Mar 2017
Posts: 28
Reputation: 0
Default Re: TEAM Limit Help!

no i mean players count more of team_one and also team_two
but no players in team_four also team_three
soobya is offline   Reply With Quote
Old 31/07/2019, 08:19 AM   #7
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 323
Reputation: 22
Default Re: TEAM Limit Help!

pawn Code:
if(team1players < team2players) // sets player team 1
      {
          team1players++;
          SetPlayerTeam(playerid, TEAM_ONE);
      }
      else if(team2players < team1players) // sets player team 2
      {
          team2players++;
          SetPlayerTeam(playerid, TEAM_TWO);
      }
      else if(team1players == team2players) // if team 1 and team 2 players are equal ,then goto random.
      {
              switch(random(2)) // choose random team for player
              {
                    case 0:
                   { // team 3
                      SetPlayerTeam(playerid, TEAM_THREE);
                       team3players++;
                   }
                   case 1:
                   {
                     SetPlayerTeam(playerid, TEAM_FOUR); // team 4
                       team4players++;
                   }  
            }
        }
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Old 31/07/2019, 08:32 AM   #8
soobya
Little Clucker
 
Join Date: Mar 2017
Posts: 28
Reputation: 0
Default Re: TEAM Limit Help!

hey i mean team Limit...
Limiting Players per Team
team full like this

If the count of players in TEAM_ONE is greater than the count of and TEAM_TWO TEAM_THREE TEAM_FOUR

team full. Join another team.
i want to make it for all teams
and sorry for my bad english
soobya is offline   Reply With Quote
Old 31/07/2019, 09:04 AM   #9
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,120
Reputation: 68
Default Re: TEAM Limit Help!

you need to choose max number of players in team.
after that, you can add code which checks the current count on that team, than allow or disallow to join that team.

for me, I would do something like that: I'll define 10 players per team as max, than I'll increase that amount if all of the teams are full.

how to do that:
PHP Code:
#define DEFAULT_MAX_PLAYERS 10

new MaxPlayersInTeam DEFAULT_MAX_PLAYERS//at the top of the code
new PlayersInTeam[4];

stock IfTeamsAreFull() //bool - returns true if teams are full, false if teams aren't full.
{
    for(new 
iTOTAL_TEAMSi++)
    {
        if(
PlayersInTeam[i] < MaxPlayersInTeam) return false;
    }
    return 
true;
}

stock PlayerJoinTeam(playeridteam//playerid, team number (id) | returns true if player joined in current slot, returns false if player joined in a new slot and he increased slots.
{
    if(
IfTeamsAreFull())
    {
        
MaxPlayersInTeam++;
        
Team[playerid] = team;    
        return 
false;
    }
    else if(
PlayersInTeam[team] < MaxPlayersInTeam)
    {
        
Team[playerid] = team;
        
PlayersInTeam[team]++;
    }
    else
    {
        
SendClientMessage(playerid,-1,"Team is full.");
    }
    return 
true;
}

stock CanDecreaseTeams() //checks if every team have less than max allowed players.
{
    if(
MaxPlayersInTeam == DEFAULT_MAX_PLAYERS) return false//can't decrease lower than default maxs.
    
new count 0;
    for (new 
iTOTAL_TEAMSi++)
    {
        if(
PlayersInTeam[i] < MaxPlayersInTeam)
        {
            
count++;
        }
    }
    if(
count == TOTAL_TEAMS) return true;
    else return 
false;
}

stock PlayerLeftTeam(playerid)
{
    if(
CanDecreaseTeams())
    {
        
MaxPlayersInTeam--;
    }
    
PlayersInTeam[Team[playerid]]--;
    
Team[playerid] = -1;
    return 
true;

change Team[playerid] into something else, that you have in code.
code is calculated for TEAM_NONE is -1, TEAM 0 is counting as a team.

p.s. I wrote that code in browser, missing semicolons is expected, just fix if you find something.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 31/07/2019, 09:14 AM   #10
soobya
Little Clucker
 
Join Date: Mar 2017
Posts: 28
Reputation: 0
Default Re: TEAM Limit Help!

can u please check this link
https://forum.sa-mp.com/showthread.php?t=453190
i`m tried to make it in my gm but not working
i want like this please
soobya is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random team assigning, team members limit: Twizted Scripting Help 2 20/07/2014 02:05 PM
Team Limit DarkLored Scripting Help 5 03/02/2014 07:41 PM
[HELP] Team/class limit lSCARl Help Archive 0 31/07/2010 04:14 PM
How to set a team limit on my faction ruckfules99 Help Archive 17 18/02/2010 11:18 PM
- Team limit Hot Help Archive 1 02/09/2009 11:04 PM


All times are GMT. The time now is 09:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.