Raised This Month: $ Target: $400
 0% 

Plugin request


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cixoT
Junior Member
Join Date: Mar 2020
Old 11-11-2021 , 20:50   Plugin request
Reply With Quote #1

Hello,

I'm looking for a plugin that sets the value of mp_autoteambalance when the number of players on the server crosses a set threshold. I'd like to have auto balance be disabled when the number of players on my server hits (for example) 26, but be re-enabled when it falls under that.

I can pay if necessary.
cixoT is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 11-12-2021 , 09:28   Re: Plugin request
Reply With Quote #2

try
Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo = {
	name = "mp_autoteambalance",
	author = "",
	description = "",
	version = "1.0.0",
	url = ""
};

int	g_iRoundStatus = 0,
	g_iSettingNow;


public void OnPluginStart() {
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
	HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
	HookConVarChange(FindConVar("mp_autoteambalance"), ConVarChanged);
}

public void OnMapStart() {
	g_iSettingNow = GetConVarInt(FindConVar("mp_autoteambalance"));
}

public void OnClientPostAdminCheck(int client) {
	checksetting();
}

public void OnClientDisconnect(int client) {
	checksetting();
}

public Action Event_RoundStart(Event event, char[] name, bool dontBroadcast) {
	g_iRoundStatus = 1;
	checksetting();
}

public Action Event_RoundEnd(Event event, char[] name, bool dontBroadcast) {
	g_iRoundStatus = 0;
}

void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
	g_iSettingNow = StringToInt(newValue);
}

void checksetting() {
	if (g_iRoundStatus) {
		if (countplayers() >= 26) {
			if (g_iSettingNow) {
				ServerCommand("mp_autoteambalance 0");
			}
		}
		else if (!g_iSettingNow) {
			ServerCommand("mp_autoteambalance 1");
		}
	}
}

int countplayers() {
	int count = 0;
	for (int i = 1; i <= MaxClients; i++) {
		if (IsClientInGame(i) && !IsFakeClient(i)) {
			count++;
		}
	}
	return count;
}

Last edited by `666; 11-12-2021 at 09:50.
`666 is offline
cixoT
Junior Member
Join Date: Mar 2020
Old 11-12-2021 , 16:08   Re: Plugin request
Reply With Quote #3

thanks!
cixoT 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 11:28.


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