View Single Post
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-21-2016 , 05:13   Re: CS:GO Server Crash Exploit
Reply With Quote #10

untested plugin that *should* work

Code:
#include <sourcemod>
#include <sdktools>

// #define STOP // remove comment to block the usercmd instead of 'fixing' it

public Plugin myinfo =
{
	name = "fuck server crashers",
	author = "shavit",
	description = "should prevent viewangles crashes",
	version = "1.0",
	url = "http://github.com/shavitush"
}

public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3])
{
	if(IsBadAngle(angles[0]) || IsBadAngle(angles[1]) || IsBadAngle(angles[2]))
	{
		#if defined STOP
		return Plugin_Stop;
		#else
		angles[0] = NormalizeAngle(angles[0]);
		angles[1] = NormalizeAngle(angles[1]);
		angles[2] = NormalizeAngle(angles[2]);

		return Plugin_Changed;
		#endif
	}

	return Plugin_Continue;
}

public bool IsBadAngle(float angle)
{
    return angle > 180.0 || angle < -180.0;
}

public float NormalizeAngle(float angle)
{
	float temp = angle;

	while(temp <= -180.0)
	{
		temp += 360.0;
	}

	while(temp > 180.0)
	{
		temp -= 360.0;
	}

	return temp;
}
__________________
retired

Last edited by shavit; 06-21-2016 at 05:17.
shavit is offline