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

[CSGO] Plugin to block teams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 09-14-2020 , 08:54   [CSGO] Plugin to block teams
Reply With Quote #1

Hello guys, I'm looking for a plugin to block the entry of new players in the teams when they are already full (5x5) forcing this player to go to the spectator, I already tried some plugins like MaxTeamSize, but it didn't work correctly.

Last edited by Rugal; 09-14-2020 at 08:55.
Rugal is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-14-2020 , 09:19   Re: [CSGO] Plugin to block teams
Reply With Quote #2

How big or how many players fit your server ?
maxplayers
__________________
Do not Private Message @me
Bacardi is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 09-14-2020 , 16:44   Re: [CSGO] Plugin to block teams
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
How big or how many players fit your server ?
maxplayers
My server has 16 slots, I need teams to be blocked in 5x5, (my server is competitive) I just need this simple block.
Rugal is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-14-2020 , 17:22   Re: [CSGO] Plugin to block teams
Reply With Quote #4

MaxTeamSize works, just need to modify it and compile it.
PHP Code:
#include <sourcemod>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

ConVar g_hMaxTeamSizeCvar;
ConVar g_hEnabledCvar;

public 
Plugin myinfo = {
    
name "CS:GO Max team size",
    
author "splewis",
    
description "Sets a maximum number of players per team",
    
version "1.0.0",
    
url "https://github.com/splewis/csgo-pug-setup"
};

public 
void OnPluginStart() {
    
g_hMaxTeamSizeCvar CreateConVar("sm_max_team_size""5""Maximum number of players allowed on a team");
    
g_hEnabledCvar CreateConVar("sm_max_team_size_enabled""1""Whether the plugin is enabled");

    
AutoExecConfig(true"maxteamsize");
    
AddCommandListener(Command_JoinTeam"jointeam");
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
}

public 
Action Event_OnPlayerTeam(Event event, const char[] namebool dontBroadcast) {
    return 
Plugin_Continue;
}

/**
 * Full connect event right when a player joins.
 * This sets the auto-pick time to a high value because mp_forcepicktime is broken and
 * if a player does not select a team but leaves their mouse over one, they are
 * put on that team and spawned, so we can't allow that.
 * This may not be needed anymore.
 */
public Action Event_PlayerConnectFull(Handle event, const char[] namebool dontBroadcast) {
    if (
g_hEnabledCvar.IntValue == 0)
        return;

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"3600.0);
}

public 
Action Command_JoinTeam(int client, const char[] commandint argc) {
    if (
g_hEnabledCvar.IntValue == 0)
        return 
Plugin_Continue;

    if (!
IsValidClient(client))
        return 
Plugin_Stop;

    
char arg[4];
    
GetCmdArg(1argsizeof(arg));
    
int team_to StringToInt(arg);

    
// don't let someone change to a "none" team (e.g. using auto-select)
    
if (team_to == CS_TEAM_NONE)
        return 
Plugin_Stop;

    if (
team_to == CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    
int playerCount 0;
    for (
int i 1<= MaxClientsi++) {
        if (
IsPlayer(i) && GetClientTeam(i) == team_to) {
            
playerCount++;
        }
    }

    if (
playerCount >= g_hMaxTeamSizeCvar.IntValue) {
        
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
        return 
Plugin_Stop;
    } else {
        return 
Plugin_Continue;
    }
}

public 
bool IsValidClient(int client) {
    return 
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client);
}

public 
bool IsPlayer(int client) {
    return 
IsValidClient(client) && !IsFakeClient(client);

If you don't ever have bots you can take out the loop and use the sdktool.
PHP Code:
#include <cstrike>
#include <sdktools>

#pragma newdecls required

ConVar g_hMaxTeamSizeCvar;
ConVar g_hEnabledCvar;

public 
void OnPluginStart()
{
    
g_hMaxTeamSizeCvar CreateConVar("sm_max_team_size""5""Maximum number of players allowed on a team");
    
g_hEnabledCvar CreateConVar("sm_max_team_size_enabled""1""Whether the plugin is enabled");

    
AutoExecConfig(true"maxteamsize");
    
AddCommandListener(Command_JoinTeam"jointeam");
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
}

public 
Action Event_OnPlayerTeam(Event event, const char[] namebool dontBroadcast)
{
    return 
Plugin_Continue;
}

public 
Action Event_PlayerConnectFull(Handle event, const char[] namebool dontBroadcast)
{
    if (
g_hEnabledCvar.IntValue == 0)
        return;

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"3600.0);
}

public 
Action Command_JoinTeam(int client, const char[] commandint argc)
{
    if (
g_hEnabledCvar.IntValue == 0) return Plugin_Continue;

    if (!
IsValidClient(client)) return Plugin_Stop;

    
char arg[4];
    
GetCmdArg(1argsizeof(arg));
    
int team_to StringToInt(arg);

    
// don't let someone change to a "none" team (e.g. using auto-select)
    
if (team_to == CS_TEAM_NONE) return Plugin_Stop;

    if (
team_to == CS_TEAM_SPECTATOR) return Plugin_Continue;

    
int teamCount GetTeamClientCount(team_to);

    if (
teamCount >= g_hMaxTeamSizeCvar.IntValue)
    {
        
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
        return 
Plugin_Stop;
    }
    else return 
Plugin_Continue;
}

public 
bool IsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client);

Maxximou5 is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 09-14-2020 , 19:30   Re: [CSGO] Plugin to block teams
Reply With Quote #5

Quote:
Originally Posted by Maxximou5 View Post
MaxTeamSize works, just need to modify it and compile it.
PHP Code:
#include <sourcemod>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required

ConVar g_hMaxTeamSizeCvar;
ConVar g_hEnabledCvar;

public 
Plugin myinfo = {
    
name "CS:GO Max team size",
    
author "splewis",
    
description "Sets a maximum number of players per team",
    
version "1.0.0",
    
url "https://github.com/splewis/csgo-pug-setup"
};

public 
void OnPluginStart() {
    
g_hMaxTeamSizeCvar CreateConVar("sm_max_team_size""5""Maximum number of players allowed on a team");
    
g_hEnabledCvar CreateConVar("sm_max_team_size_enabled""1""Whether the plugin is enabled");

    
AutoExecConfig(true"maxteamsize");
    
AddCommandListener(Command_JoinTeam"jointeam");
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
}

public 
Action Event_OnPlayerTeam(Event event, const char[] namebool dontBroadcast) {
    return 
Plugin_Continue;
}

/**
 * Full connect event right when a player joins.
 * This sets the auto-pick time to a high value because mp_forcepicktime is broken and
 * if a player does not select a team but leaves their mouse over one, they are
 * put on that team and spawned, so we can't allow that.
 * This may not be needed anymore.
 */
public Action Event_PlayerConnectFull(Handle event, const char[] namebool dontBroadcast) {
    if (
g_hEnabledCvar.IntValue == 0)
        return;

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"3600.0);
}

public 
Action Command_JoinTeam(int client, const char[] commandint argc) {
    if (
g_hEnabledCvar.IntValue == 0)
        return 
Plugin_Continue;

    if (!
IsValidClient(client))
        return 
Plugin_Stop;

    
char arg[4];
    
GetCmdArg(1argsizeof(arg));
    
int team_to StringToInt(arg);

    
// don't let someone change to a "none" team (e.g. using auto-select)
    
if (team_to == CS_TEAM_NONE)
        return 
Plugin_Stop;

    if (
team_to == CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    
int playerCount 0;
    for (
int i 1<= MaxClientsi++) {
        if (
IsPlayer(i) && GetClientTeam(i) == team_to) {
            
playerCount++;
        }
    }

    if (
playerCount >= g_hMaxTeamSizeCvar.IntValue) {
        
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
        return 
Plugin_Stop;
    } else {
        return 
Plugin_Continue;
    }
}

public 
bool IsValidClient(int client) {
    return 
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client);
}

public 
bool IsPlayer(int client) {
    return 
IsValidClient(client) && !IsFakeClient(client);

If you don't ever have bots you can take out the loop and use the sdktool.
PHP Code:
#include <cstrike>
#include <sdktools>

#pragma newdecls required

ConVar g_hMaxTeamSizeCvar;
ConVar g_hEnabledCvar;

public 
void OnPluginStart()
{
    
g_hMaxTeamSizeCvar CreateConVar("sm_max_team_size""5""Maximum number of players allowed on a team");
    
g_hEnabledCvar CreateConVar("sm_max_team_size_enabled""1""Whether the plugin is enabled");

    
AutoExecConfig(true"maxteamsize");
    
AddCommandListener(Command_JoinTeam"jointeam");
    
HookEvent("player_connect_full"Event_PlayerConnectFull);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
}

public 
Action Event_OnPlayerTeam(Event event, const char[] namebool dontBroadcast)
{
    return 
Plugin_Continue;
}

public 
Action Event_PlayerConnectFull(Handle event, const char[] namebool dontBroadcast)
{
    if (
g_hEnabledCvar.IntValue == 0)
        return;

    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntPropFloat(clientProp_Send"m_fForceTeam"3600.0);
}

public 
Action Command_JoinTeam(int client, const char[] commandint argc)
{
    if (
g_hEnabledCvar.IntValue == 0) return Plugin_Continue;

    if (!
IsValidClient(client)) return Plugin_Stop;

    
char arg[4];
    
GetCmdArg(1argsizeof(arg));
    
int team_to StringToInt(arg);

    
// don't let someone change to a "none" team (e.g. using auto-select)
    
if (team_to == CS_TEAM_NONE) return Plugin_Stop;

    if (
team_to == CS_TEAM_SPECTATOR) return Plugin_Continue;

    
int teamCount GetTeamClientCount(team_to);

    if (
teamCount >= g_hMaxTeamSizeCvar.IntValue)
    {
        
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
        return 
Plugin_Stop;
    }
    else return 
Plugin_Continue;
}

public 
bool IsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client);

Sorry, but I don't know how to compile a plugin, I don't understand anything about it. Could you teach me how to do this, or leave a link to a tutorial.
Note: When I used MaxteamSize, it even worked, but sometimes the player was able to join a team, the player entered the server, but the team selection screen does not appear, he automatically joined a team, I know there is a command for this, but the same is correct. This happened at random. And in the LOG file, the MaxTeamSize plugin was to blame for the error.
Rugal is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-14-2020 , 22:35   Re: [CSGO] Plugin to block teams
Reply With Quote #6

Try net compiler https://www.sourcemod.net/compiler.php
Copy code, paste to big blank space, compile
__________________
Do not Private Message @me

Last edited by Bacardi; 09-15-2020 at 01:38.
Bacardi is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 09-16-2020 , 00:30   Re: [CSGO] Plugin to block teams
Reply With Quote #7

I really don't understand what is going on with this plugin .. It presents me with this error.


L 09/16/2020 - 00:15:26: SourceMod error session started
L 09/16/2020 - 00:15:26: Info (map "de_mirage") (file "C:\CSGO\csgo\addons\sourcemod\logs\errors_20 200916.log")
L 09/16/2020 - 00:15:26: [SM] Exception reported: Property "m_fForceTeam" not found (entity 0/worldspawn)
L 09/16/2020 - 00:15:26: [SM] Blaming: maxteamsize.smx
L 09/16/2020 - 00:15:26: [SM] Call stack trace:
L 09/16/2020 - 00:15:26: [SM] [0] SetEntPropFloat
L 09/16/2020 - 00:15:26: [SM] [1] Line 44, /home/forums/content/files/2/4/5/6/8/3/147169.attach::Event_PlayerConnectFull
L 09/16/2020 - 00:21:46: Error log file session closed.
Rugal is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-16-2020 , 03:16   Re: [CSGO] Plugin to block teams
Reply With Quote #8

Show us:


meta version
sm version
Bacardi is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 09-16-2020 , 13:40   Re: [CSGO] Plugin to block teams
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
Show us:


meta version
sm version
SourceMod Version Information:
SourceMod Version: 1.10.0.6492
SourcePawn Engine: 1.10.0.6492, jit-x86 (build 1.10.0.6492)
SourcePawn API: v1 = 5, v2 = 12
Compiled on: Jul 24 2020 20:10:15
Built from: https://github.com/alliedmodders/sou...ommit/250886fe
Build ID: 6492:250886fe
http://www.sourcemod.net/
Rugal is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-16-2020 , 15:04   Re: [CSGO] Plugin to block teams
Reply With Quote #10

Which version CSGO you are running ?

version
Bacardi 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 11:48.


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