-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkid-changes.sp
154 lines (124 loc) · 3.31 KB
/
kid-changes.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// includes
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#include <clientprefs>
#undef REQUIRE_PLUGIN
#include <shavit>
bool gB_Noclipped[MAXPLAYERS+1];
bool gB_RestartBonus[MAXPLAYERS+1];
int gI_Style[MAXPLAYERS+1];
//convars
ConVar gCV_PrespeedLimit = null;
// in OnPluginStart()
public void OnPluginStart()
{
gCV_PrespeedLimit = CreateConVar("shavit_misc_prespeedlimit", "276.00", "Prespeed limitation in startzone.", 0, true, 10.0, false);
AddCommandListener(CommandListener_Restart, "sm_r");
AddCommandListener(CommandListener_Restart, "sm_restart");
LoadTranslations("shavit-core.phrases");
LoadTranslations("shavit-misc.phrases");
}
public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
{
if(reason == CSRoundEnd_GameStart)
{
return Plugin_Handled;
}
return Plugin_Continue;
}
public void OnClientConnected(int client)
{
gB_Noclipped[client] = false;
gB_RestartBonus[client] = false;
}
public void Shavit_OnStyleChanged(int client, int oldstyle, int newstyle)
{
gI_Style[client] = newstyle;
gB_Noclipped[client] = false;
}
public void Shavit_OnRestart(int client, int track)
{
gB_Noclipped[client] = false;
}
public Action Shavit_OnStart(int client, int track)
{
if (gB_Noclipped[client])
{
gB_Noclipped[client] = false;
Shavit_RestartTimer(client, track);
}
}
public void Shavit_OnLeaveZone(int client, int type, int track, int id, int entity)
{
if(type == Zone_Start)
{
gB_RestartBonus[client] = (track >= 1);
if (gB_Noclipped[client])
{
Shavit_RestartTimer(client, track);
}
}
}
public Action Shavit_OnUserCmdPre(int client, int &buttons, int &impulse, float vel[3], float angles[3], TimerStatus status, int track, int style, stylesettings_t stylesettings, int mouse[2])
{
gB_Noclipped[client] = (view_as<MoveType>(GetEntProp(client, Prop_Data, "m_MoveType")) == MOVETYPE_NOCLIP);
int flags = GetEntityFlags(client);
if(gB_Noclipped[client] && stylesettings.bPrespeed)
{
SetEntityMoveType(client, MOVETYPE_WALK);
}
if(Shavit_InsideZone(client, Zone_Start, track))
{
SetEntityMoveType(client, MOVETYPE_WALK);
}
// prespeed
if(!gB_Noclipped[client] && !stylesettings.bPrespeed && Shavit_InsideZone(client, Zone_Start, track))
{
float speed[3];
float speed2;
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", speed);
float speed_New = (SquareRoot(Pow(speed[0], 2.0) + Pow(speed[1], 2.0)));
if(speed_New < (260.0 + 50.0) || (flags & FL_ONGROUND == FL_ONGROUND))
{
float fScale = (gCV_PrespeedLimit.FloatValue / speed_New);
speed2 = speed[2];
speed[2] = 0.0;
if(fScale < 1.0)
{
ScaleVector(speed, fScale);
}
speed[2] = speed2;
if(gB_Noclipped[client])
{
speed[2] = 0.0;
}
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, speed);
}
}
return Plugin_Continue;
}
public Action CommandListener_Restart(int client, const char[] command, int args)
{
if(!IsValidClient(client, true))
{
return Plugin_Handled;
}
if(gB_RestartBonus[client])
{
Shavit_RestartTimer(client, Track_Bonus);
return Plugin_Stop;
}
return Plugin_Handled;
}
public Action Shavit_OnSave(int client)
{
stylesettings_t stylesettings;
Shavit_GetStyleSettings(gI_Style[client], stylesettings);
if (stylesettings.bPrespeed)
{
return Plugin_Handled;
}
return Plugin_Continue;
}