From 6fd8ef96db3269d671d803ac86a03c0a8cf59bf1 Mon Sep 17 00:00:00 2001 From: BotoX Date: Tue, 20 Dec 2016 00:42:28 +0100 Subject: [PATCH] New plugin: FixAngles --- FixAngles/scripting/FixAngles.sp | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 FixAngles/scripting/FixAngles.sp diff --git a/FixAngles/scripting/FixAngles.sp b/FixAngles/scripting/FixAngles.sp new file mode 100644 index 00000000..91e36d62 --- /dev/null +++ b/FixAngles/scripting/FixAngles.sp @@ -0,0 +1,47 @@ +#include +#include + +#pragma semicolon 1 +#pragma newdecls required + +public Plugin myinfo = +{ + name = "FixAngles", + author = "BotoX", + description = "", + version = "1.0", + url = "" +}; + +public void OnMapStart() +{ + CreateTimer(1.0, CheckAngles, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); +} + +public Action CheckAngles(Handle timer) +{ + int entity = INVALID_ENT_REFERENCE; + while((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE) + { + if(!HasEntProp(entity, Prop_Send, "m_angRotation")) + continue; + + static float aAngles[3]; + GetEntPropVector(entity, Prop_Send, "m_angRotation", aAngles); + + bool bChanged = false; + for(int i = 0; i < 3; i++) + { + if(aAngles[i] < -360 || aAngles[i] > 360) + { + aAngles[i] = float(RoundFloat(aAngles[i]) % 360); + bChanged = true; + } + } + + if(bChanged) + SetEntPropVector(entity, Prop_Send, "m_angRotation", aAngles); + } + + return Plugin_Continue; +}