Hello, I made this plugin so I could manage better the maxplayers without having to change the real maxplayers but for some reason it isn't working, could someone tell me what's wrong?
Code:
#pragma semicolon 1
#define DEBUG
#define PLUGIN_AUTHOR "GelaPT"
#define PLUGIN_VERSION "1.00"
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma newdecls required
ConVar g_MaxPlayers;
public Plugin myinfo = {
name = "Force Max Players",
author = PLUGIN_AUTHOR,
description = "Forces max players",
version = PLUGIN_VERSION,
url = "forum.punt.pt"
};
public void OnPluginStart() {
AddCommandListener(JoinTeam, "jointeam");
g_MaxPlayers = CreateConVar("sm_maxplayers", "10", "Max players", ADMFLAG_CONVARS, true, 1.0, true, 32.0);
AutoExecConfig(true, "sm_maxplayersforce", "sourcemod");
}
public Action JoinTeam(int client, const char[] command, int args) {
char chTeam[5];
GetCmdArgString(chTeam, sizeof(chTeam));
int iSelectedTeam = StringToInt(chTeam);
int iCurrentTeam = GetClientTeam(client);
if(iSelectedTeam == CS_TEAM_SPECTATOR) {
return Plugin_Continue;
}
if(iSelectedTeam == iCurrentTeam) {
return Plugin_Stop;
}
if(iSelectedTeam == CS_TEAM_CT || iSelectedTeam == CS_TEAM_T) {
if(GetTeamClientCount(2) + GetTeamClientCount(3) < g_MaxPlayers.IntValue) {
if(GetTeamClientCount(2) <= GetTeamClientCount(3)) {
CS_SwitchTeam(client, 2);
return Plugin_Stop;
} else if(GetTeamClientCount(3) <= GetTeamClientCount(2)) {
CS_SwitchTeam(client, 3);
return Plugin_Stop;
}
} else {
PrintToChat(client, "Servidor cheio.");
return Plugin_Stop;
}
}
return Plugin_Continue;
}
__________________