Raised This Month: $32 Target: $400
 8% 

[REQ] TF2 Limit players' number per team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
duydangle
Senior Member
Join Date: May 2010
Old 12-12-2011 , 05:37   [REQ] TF2 Limit players' number per team
Reply With Quote #1

I really need this plugin because I want to limit 6 players per team for my competitive server. I think this plugin will be useful for another plugin. Please somebody make it, I really appreciate that.

Thanks
duydangle is offline
dylstew
Senior Member
Join Date: Jul 2011
Old 12-15-2011 , 05:59   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #2

Quote:
Originally Posted by duydangle View Post
I really need this plugin because I want to limit 6 players per team for my competitive server. I think this plugin will be useful for another plugin. Please somebody make it, I really appreciate that.

Thanks
You cna just decrease the mapxplayercount to 12 and it would be the same thing.
dylstew is offline
duydangle
Senior Member
Join Date: May 2010
Old 12-15-2011 , 10:03   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #3

Quote:
Originally Posted by dylstew View Post
You cna just decrease the mapxplayercount to 12 and it would be the same thing.
OK I will try to do this thing instead. This is a code I wrote. I learn a lot from warmod, but it still not work. If anyone could see what the problem is, I really appreciate that.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

#define TEAM_SPEC    1
#define TEAM_RED     2
#define TEAM_BLUE     3

new Handle:g_hTeamLimit;
new 
Handle:g_hEnableTeamLimit;

public 
Plugin:myinfo 
{
    
name "TF2 Limit 6 Players Per Team",
    
author "duydangle, noobcannonlol",
    
description "For use on competitive server",
    
version "1.0",
    
url "Xtremezone.VN"
}

public 
OnPluginStart()
{
    
g_hEnableTeamLimit CreateConVar("sm_enableteamlimit""1""1 (on) or 0 (off)");
    
g_hTeamLimit CreateConVar("sm_teamlimit""6""Limit teams to this value");
    
HookEvent("player_team"Event_Player_TeamEventHookMode_Pre);
}
public 
Action:Event_Player_Team(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
GetConVarBool(g_hEnableTeamLimit))
        return 
Plugin_Continue;
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
oldteam GetEventInt(event"oldteam");
    new 
newteam GetEventInt(event"team");
    
    if ((
newteam == TEAM_RED) || (newteam == TEAM_BLUE))
    {
        if (
GetTeamClientCount(newteam) > GetTeamLimit())
        {
            
PrintToChat(client"That team is full (%s/%s)!",g_hTeamLimitg_hTeamLimit);
            
ChangeClientTeam(clientoldteam);
            return 
Plugin_Handled;
        }
            
    }
    return 
Plugin_Continue;
}

public 
GetTeamLimit()
{
    return 
GetConVarInt(g_hTeamLimit);


Last edited by duydangle; 12-15-2011 at 10:04.
duydangle is offline
duydangle
Senior Member
Join Date: May 2010
Old 12-15-2011 , 10:14   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #4

This is the code I rewrite from warmod to limit 12 players. Please look at this @@.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

#define TEAM_SPEC    1
#define TEAM_RED     2
#define TEAM_BLUE     3

new Handle:g_h_max_players;

public 
Plugin:myinfo 
{
    
name "TF2 Limit 12 Players",
    
author "duydangle, noobcannonlol",
    
description "For use on competitive server",
    
version "1.0",
    
url "Xtremezone.VN"
}

public 
OnPluginStart()
{
    
g_h_max_players CreateConVar("sm_maxplayers""12""Limit max players to this value");
    
RegConsoleCmd("jointeam"ChooseTeam);
    
RegConsoleCmd("spectate"ChooseTeam);
}
public 
Action:ChooseTeam(clientargs)
{
        
    if (
client == 0)
    {
        return 
Plugin_Continue;
    }
    
    new 
max_players GetConVarInt(g_h_max_players);
    if (
max_players != && GetClientTeam(client) <= && CS_GetPlayingCount() >= max_players)
    {
        
PrintToChat(client"%s players already!"max_players);
        
ChangeClientTeam(clientTEAM_SPEC);
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

stock CS_GetPlayingCount()
{
    new 
count;
    new 
max_clients GetMaxClients();
    for (new 
1<= max_clientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
        {
            
count++;
        }
    }
    return 
count;


Last edited by duydangle; 12-15-2011 at 11:22.
duydangle is offline
duydangle
Senior Member
Join Date: May 2010
Old 12-15-2011 , 11:21   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #5

The latter code works... Now I can limit max players. Can anyone fix the first code?
duydangle is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 12-15-2011 , 13:18   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #6

If the second example works, then why do you want to fix the first one?
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
duydangle
Senior Member
Join Date: May 2010
Old 12-15-2011 , 22:27   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #7

Quote:
Originally Posted by McFlurry View Post
If the second example works, then why do you want to fix the first one?
I really don't understand why the first one don't work. BTW I think restrict one team is better than restrict the whole max players.
duydangle is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 12-16-2011 , 16:49   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #8

We went over this in the other thread you made, jointeam has an argument. that argument is the team they want to join (I'm not sure if that could be 1(spectators)).
I'm not sure why you're hooking spectate, since only teams 2 and 3 have to be managed.
Use GetCmdArg(1, stringhere, sizeof(stringhere)) to get the team they want to join and then use StringToInt(stringhere) to get an integer. Then compare team counts, etc.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
duydangle
Senior Member
Join Date: May 2010
Old 12-17-2011 , 02:54   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #9

Quote:
Originally Posted by McFlurry View Post
We went over this in the other thread you made, jointeam has an argument. that argument is the team they want to join (I'm not sure if that could be 1(spectators)).
I'm not sure why you're hooking spectate, since only teams 2 and 3 have to be managed.
Use GetCmdArg(1, stringhere, sizeof(stringhere)) to get the team they want to join and then use StringToInt(stringhere) to get an integer. Then compare team counts, etc.
So we should not hook the event player_team but hook the command jointeam like the second code?
duydangle is offline
generals
Senior Member
Join Date: Aug 2018
Old 10-18-2018 , 17:28   Re: [REQ] TF2 Limit players' number per team
Reply With Quote #10

Quote:
Originally Posted by duydangle View Post
This is the code I rewrite from warmod to limit 12 players. Please look at this @@.

PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <tf2>

#define TEAM_SPEC    1
#define TEAM_RED     2
#define TEAM_BLUE     3

new Handle:g_h_max_players;

public 
Plugin:myinfo 
{
    
name "TF2 Limit 12 Players",
    
author "duydangle, noobcannonlol",
    
description "For use on competitive server",
    
version "1.0",
    
url "Xtremezone.VN"
}

public 
OnPluginStart()
{
    
g_h_max_players CreateConVar("sm_maxplayers""12""Limit max players to this value");
    
RegConsoleCmd("jointeam"ChooseTeam);
    
RegConsoleCmd("spectate"ChooseTeam);
}
public 
Action:ChooseTeam(clientargs)
{
        
    if (
client == 0)
    {
        return 
Plugin_Continue;
    }
    
    new 
max_players GetConVarInt(g_h_max_players);
    if (
max_players != && GetClientTeam(client) <= && CS_GetPlayingCount() >= max_players)
    {
        
PrintToChat(client"%s players already!"max_players);
        
ChangeClientTeam(clientTEAM_SPEC);
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

stock CS_GetPlayingCount()
{
    new 
count;
    new 
max_clients GetMaxClients();
    for (new 
1<= max_clientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && GetClientTeam(i) > 1)
        {
            
count++;
        }
    }
    return 
count;

Hi

Can someone make this plugin for css?

I really need it
generals is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 12:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode