SourcePawn:ZMKnockback

From Devicenull's Code

Jump to: navigation, search

This enables/disables knockback based on the number of players in game.

#pragma semicolon 1
 
#include <sourcemod>
#include <usermessages>
#include <bitbuffer>
 
public Plugin:myinfo = 
{
	name = "ZM-Knockback",
	author = "devicenull",
	description = "Automatically changes knockback",
	version = "1.0.0.0",
	url = "http://www.lunixmonster.org/"
};
 
new Handle:knockback;
 
public OnClientPutInServer(client)
{
	CheckPlayerCount();
}
 
public OnClientDisconnect_Post(client)
{
	CheckPlayerCount();
}
 
CheckPlayerCount()
{
	if (!IsValidHandle(knockback))
	{
		knockback = FindConVar("zombie_knockback");
	}
	if (GetClientCount() >= 8 && GetConVarInt(knockback) == 3)
	{
		SetConVarInt(knockback,2);
 
		new Handle:msg = StartMessageAll("SayText",0);
		BfWriteByte(msg,0);
		BfWriteString(msg,"Knockback has been changed to 2");
		BfWriteByte(msg,1);
		EndMessage();
	}		
	else if (GetClientCount() < 8 && GetConVarInt(knockback) == 2)
	{
		SetConVarInt(knockback,3);
 
		new Handle:msg = StartMessageAll("SayText",0);
		BfWriteByte(msg,0);
		BfWriteString(msg,"Knockback has been changed to 3");
		BfWriteByte(msg,1);
		EndMessage();
	}
}