-
Notifications
You must be signed in to change notification settings - Fork 15
/
fix_angles 1.0.1.sp
84 lines (70 loc) · 2.09 KB
/
fix_angles 1.0.1.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#define PLUGIN_NAME "Fix angles"
#define PLUGIN_VERSION "1.0.1"
Handle AngTimer = INVALID_HANDLE;
ConVar hEnable;
bool bEnable;
ConVar hTime;
float fTime;
float ang[3];
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = "Grey83",
description = "Fixes error 'Bad SetLocalAngles' in server console",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=285750"
}
public void OnPluginStart()
{
CreateConVar("sm_fix_angles_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
hEnable = CreateConVar("sm_fix_angles_enable", "0", "Enables/disables the plugin", FCVAR_NOTIFY|FCVAR_DONTRECORD, true, 0.0, true, 1.0);
hTime = CreateConVar("sm_fix_angles_time", "30", "The time between inspections of entities angles", FCVAR_NOTIFY, true, 10.0, true, 120.0);
bEnable = GetConVarBool(hEnable);
fTime = GetConVarFloat(hTime);
HookConVarChange(hEnable, OnCVarChanged);
HookConVarChange(hTime, OnCVarChanged);
AutoExecConfig(true, "fix_angles");
}
public void OnCVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
if(convar == hEnable)
{
bEnable = view_as<bool>(StringToInt(newValue));
if(bEnable && AngTimer == null) AngTimer = CreateTimer(fTime, CheckAngles);
else if(!bEnable && AngTimer != null) KillAngTimer();
}
else if (convar == hTime)fTime = StringToFloat(newValue);
}
void KillAngTimer()
{
KillTimer(AngTimer);
AngTimer = null;
}
public void OnMapStart()
{
if(bEnable) AngTimer = CreateTimer(fTime, CheckAngles);
}
public Action CheckAngles(Handle timer)
{
if(bEnable)
{
for(int i = MaxClients +1; i <= 2048; i++)
{
if(IsValidEntity(i) && HasEntProp(i, Prop_Send, "m_angRotation"))
{
GetEntPropVector(i, Prop_Send, "m_angRotation", ang);
for(int j; j < 3; j++)
{
if(ang[j] < -360 || ang[j] > 360) ang[j] = float(RoundFloat(ang[j]) % 360);
}
SetEntPropVector(i, Prop_Send, "m_angRotation", ang);
}
}
AngTimer = CreateTimer(fTime, CheckAngles);
}
else KillAngTimer();
}