AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CSGO] Plugin to block teams (https://forums.alliedmods.net/showthread.php?t=327371)

Rugal 09-14-2020 08:54

[CSGO] Plugin to block teams
 
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.

Bacardi 09-14-2020 09:19

Re: [CSGO] Plugin to block teams
 
How big or how many players fit your server ?
maxplayers

Rugal 09-14-2020 16:44

Re: [CSGO] Plugin to block teams
 
Quote:

Originally Posted by Bacardi (Post 2717766)
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.

Maxximou5 09-14-2020 17:22

Re: [CSGO] Plugin to block teams
 
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);



Rugal 09-14-2020 19:30

Re: [CSGO] Plugin to block teams
 
Quote:

Originally Posted by Maxximou5 (Post 2717808)
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.

Bacardi 09-14-2020 22:35

Re: [CSGO] Plugin to block teams
 
Try net compiler https://www.sourcemod.net/compiler.php
Copy code, paste to big blank space, compile

Rugal 09-16-2020 00:30

Re: [CSGO] Plugin to block teams
 
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.

Bacardi 09-16-2020 03:16

Re: [CSGO] Plugin to block teams
 
Show us:


meta version
sm version

Rugal 09-16-2020 13:40

Re: [CSGO] Plugin to block teams
 
Quote:

Originally Posted by Bacardi (Post 2717904)
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/

Bacardi 09-16-2020 15:04

Re: [CSGO] Plugin to block teams
 
Which version CSGO you are running ?

version


All times are GMT -4. The time now is 10:24.

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