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

Forcing maxplayers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
andrept4
Senior Member
Join Date: Dec 2012
Location: Portugal
Old 03-21-2020 , 15:33   Forcing maxplayers
Reply With Quote #1

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;
}
__________________

Last edited by andrept4; 03-21-2020 at 15:54.
andrept4 is offline
Reply


Thread Tools
Display Modes

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 19:36.


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