Raised This Month: $51 Target: $400
 12% 

[HELP] CS-GO Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 12-07-2020 , 18:40   [HELP] CS-GO Plugin
Reply With Quote #1

Hello guys, I have a plugin that before the new CS-GO update, it worked fine, but after it updated the game, it doesn't work properly.
The plugin basically blocks new players from entering any of the teams when they are full.
EXAMPLE: a game is already 5x5, if any other player enters the server, the only option left for him, is to enter the spectators.
I will leave the source code of the plugin here, I really need this to work again, after all I need to block the times on my server.

Code:

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma newdecls required

public Plugin myinfo =
{
name = "[CSGO] Team Manager",
author = "yelks/Agent",
description = "Made for Stifler",
version = "1.3",
url = ""
};

public void OnPluginStart()
{
AddCommandListener(Listener_JoinTeam, "jointeam");
}

public Action Listener_JoinTeam(int client, const char[] command, int args)
{
if (args < 1)
return Plugin_Continue;

char strTeam[10];
GetCmdArg(1, strTeam, 10);
int team = StringToInt(strTeam);

if (team == 2 || team == 3)
{
if (GetTeamClientCount(team) >= 5)
{
return Plugin_Handled;
}

return Plugin_Continue;
}
else if (team == 1)
{
return Plugin_Continue;
}

return Plugin_Handled;
}

Last edited by Rugal; 12-07-2020 at 18:42.
Rugal is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-08-2020 , 05:11   Re: [HELP] CS-GO Plugin
Reply With Quote #2

Hi,
I do not find anything wrong with your awesome plugins. Probably something else causing it to not working.
I hear many people talking about the "warmup round" to be somewhat troublesome.
Probably start investigate there.

Here i change something to make it even cooler and handsome.
Spoiler


EDIT: I got myself confused while reading what the awesome plugins do. Probably not what you want.
.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.

Last edited by GsiX; 12-08-2020 at 05:14.
GsiX is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 12-08-2020 , 06:13   Re: [HELP] CS-GO Plugin
Reply With Quote #3

Quote:
Originally Posted by GsiX View Post
Hi,
I do not find anything wrong with your awesome plugins. Probably something else causing it to not working.
I hear many people talking about the "warmup round" to be somewhat troublesome.
Probably start investigate there.

Here i change something to make it even cooler and handsome.
Spoiler


EDIT: I got myself confused while reading what the awesome plugins do. Probably not what you want.
.
As for problematic heating, I have already solved it, external heating also happens, when a game is in progress, for example.
Sometimes the plugin does its job correctly, which is to block teams, but sometimes it doesn't block anyone, everyone can join.
Rugal is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 12-08-2020 , 07:06   Re: [HELP] CS-GO Plugin
Reply With Quote #4

Quote:
Originally Posted by GsiX View Post
Hi,
I do not find anything wrong with your awesome plugins. Probably something else causing it to not working.
I hear many people talking about the "warmup round" to be somewhat troublesome.
Probably start investigate there.

Here i change something to make it even cooler and handsome.
Spoiler


EDIT: I got myself confused while reading what the awesome plugins do. Probably not what you want.
.

here's an older code, it doesn't really work. But I really need this.

Code:
#include <cstrike>
#include <sourcemod>

#include "include/logdebug.inc"
#include "include/pugsetup.inc"
#include "pugsetup/generic.sp"

#pragma semicolon 1
#pragma newdecls required

ConVar g_hBlockSpecJoins;
ConVar g_hKickTime;
ConVar g_hLockTeamsEnabled;

// clang-format off
public Plugin myinfo = {
    name = "CS:GO PugSetup: team locker",
    author = "splewis",
    description = "Blocks team join events to full teams",
    version = PLUGIN_VERSION,
    url = "https://github.com/splewis/csgo-pug-setup"
};
// clang-format on

public void OnPluginStart() {
  InitDebugLog(DEBUG_CVAR, "teamlock");

  g_hBlockSpecJoins = CreateConVar(
      "sm_pugsetup_block_spectate_joins", "1",
      "Whether players are blocked from joining spectator (admins excluded) during a live match.");
  g_hKickTime = CreateConVar(
      "sm_pugsetup_kick_time", "0",
      "If players don't join a team after this many seconds, they will be kicked. Use 0 to disable.");
  g_hLockTeamsEnabled = CreateConVar("sm_pugsetup_teamlocker_enabled", "1",
                                     "Whether teams are locked when matches are live.");

  AutoExecConfig(true, "pugsetup_teamlocker", "sourcemod/pugsetup");
  AddCommandListener(Command_JoinTeam, "jointeam");
  HookEvent("player_team", Event_OnPlayerTeam, EventHookMode_Pre);
}

public void OnClientPutInServer(int client) {
  if (PugSetup_GetGameState() == GameState_None) {
    return;
  }

  int kickTime = g_hKickTime.IntValue;
  if (kickTime != 0) {
    CreateTimer(float(kickTime), Timer_CheckIfSpectator, GetClientSerial(client));
  }
}

public Action Timer_CheckIfSpectator(Handle timer, int serial) {
  if (PugSetup_GetGameState() == GameState_None) {
    return Plugin_Handled;
  }

  int client = GetClientFromSerial(serial);
  if (IsPlayer(client) && !PugSetup_IsPugAdmin(client)) {
    int team = GetClientTeam(client);
    if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_NONE) {
      KickClient(client, "You did not join a team in time");
    }
  }

  return Plugin_Handled;
}

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

public Action Command_JoinTeam(int client, const char[] command, int argc) {
  if (!IsValidClient(client))
    return Plugin_Stop;

  if (g_hLockTeamsEnabled.IntValue == 0)
    return Plugin_Continue;

  // blocks changes during team-selection/lo3-process
  if (PugSetup_IsPendingStart())
    return Plugin_Stop;

  // don't do anything if not live/not in startup phase
  if (!PugSetup_IsMatchLive())
    return Plugin_Continue;

  char arg[4];
  GetCmdArg(1, arg, sizeof(arg));
  int team_to = StringToInt(arg);

  LogDebug("%L jointeam command, from %d to %d", client, GetClientTeam(client), team_to);

  // 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 && !PugSetup_IsPugAdmin(client) &&
      g_hBlockSpecJoins.IntValue != 0)
    return Plugin_Stop;

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

  LogDebug("playerCount on team %d = %d", team_to, playerCount);

  if (playerCount >= PugSetup_GetPugMaxPlayers() / 2) {
    LogDebug("blocking jointeam");
    return Plugin_Stop;
  } else {
    LogDebug("allowing jointeam");
    return Plugin_Continue;
  }
}
Rugal is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-09-2020 , 11:44   Re: [HELP] CS-GO Plugin
Reply With Quote #5

i cant find the right include. The one i found wont compile.
.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 12-09-2020 , 12:15   Re: [HELP] CS-GO Plugin
Reply With Quote #6

Quote:
Originally Posted by GsiX View Post
i cant find the right include. The one i found wont compile.
.

Okay, I tried to use the code you changed for me, but, I don't know how to make that code into a functional plugin, how do I do this?
Rugal is offline
NanoC
Veteran Member
Join Date: Jan 2016
Location: Argentina
Old 12-10-2020 , 14:35   Re: [HELP] CS-GO Plugin
Reply With Quote #7

I made this and it's working properly.

Code:
public Action ChangeTeam(int client, const char[] command, int args) {     int iTeamCountT = GetTeamClientCount(2);     int iTeamCountCT = GetTeamClientCount(3);     int iTeamTotal = iTeamCountT + iTeamCountCT;     if(GetClientTeam(client) == CS_TEAM_SPECTATOR)     {         if(iTeamTotal >= 10)         {             CPrintToChat(client, "{cyan}[AutoMix]{white} Match is live.");             CPrintToChat(client, "{cyan}[AutoMix]{white} Wait for someone to leave to join a team.");             return Plugin_Stop;         }     }     else     {         CPrintToChat(client, "{cyan}[AutoMix]{white} You can't switch teams.");         return Plugin_Stop;     }     return Plugin_Continue; }
__________________

Last edited by NanoC; 12-10-2020 at 14:39.
NanoC is offline
Send a message via Skype™ to NanoC
Rugal
Senior Member
Join Date: Jun 2020
Location: Brazil
Old 12-10-2020 , 16:15   Re: [HELP] CS-GO Plugin
Reply With Quote #8

Quote:
Originally Posted by NanoC View Post
I made this and it's working properly.

Code:
public Action ChangeTeam(int client, const char[] command, int args) {     int iTeamCountT = GetTeamClientCount(2);     int iTeamCountCT = GetTeamClientCount(3);     int iTeamTotal = iTeamCountT + iTeamCountCT;     if(GetClientTeam(client) == CS_TEAM_SPECTATOR)     {         if(iTeamTotal >= 10)         {             CPrintToChat(client, "{cyan}[AutoMix]{white} Match is live.");             CPrintToChat(client, "{cyan}[AutoMix]{white} Wait for someone to leave to join a team.");             return Plugin_Stop;         }     }     else     {         CPrintToChat(client, "{cyan}[AutoMix]{white} You can't switch teams.");         return Plugin_Stop;     }     return Plugin_Continue; }
I am getting this when trying to compile the code.
https://imgur.com/a/EILJGs8
Rugal is offline
NanoC
Veteran Member
Join Date: Jan 2016
Location: Argentina
Old 12-10-2020 , 16:37   Re: [HELP] CS-GO Plugin
Reply With Quote #9

Quote:
Originally Posted by Rugal View Post
I am getting this when trying to compile the code.
https://imgur.com/a/EILJGs8
Code:
#include <sourcemod> #include <cstrike> #include <sdktools> public void OnPluginStart() {     AddCommandListener(ChangeTeam, "jointeam"); } public Action ChangeTeam(int client, const char[] command, int args) {     int iTeamCountT = GetTeamClientCount(2);     int iTeamCountCT = GetTeamClientCount(3);     int iTeamTotal = iTeamCountT + iTeamCountCT;     if(GetClientTeam(client) == CS_TEAM_SPECTATOR)     {         if(iTeamTotal >= 10)         {             PrintToChat(client, "Match is live.");             PrintToChat(client, "Wait for someone to leave to join a team.");             return Plugin_Stop;         }     }     else     {         PrintToChat(client, "You can't switch teams.");         return Plugin_Stop;     }     return Plugin_Continue; }
Attached Files
File Type: smx Testing.smx (4.0 KB, 37 views)
__________________
NanoC is offline
Send a message via Skype™ to NanoC
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 06:00.


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