21
21
#include <sourcemod>
22
22
#include <clientprefs>
23
23
#include <sdktools>
24
+ #include <sdkhooks>
24
25
25
26
#undef REQUIRE_PLUGIN
26
27
#include <shavit>
27
28
28
- #define NOSLIDE_VERSION " 1.0 "
29
+ #define NOSLIDE_VERSION " 1.1 "
29
30
30
31
// Uncommenting will result in an unnecessary message per land.
31
32
// #define DEBUG
@@ -55,13 +56,19 @@ bool gB_Enabled = false;
55
56
#endif
56
57
57
58
// cache
59
+ ConVar sv_friction = null ;
60
+ float gF_DefaultFriction = 4.0 ;
61
+ char gS_DefaultFriction [16 ];
62
+
63
+ EngineVersion gEV_Type ;
58
64
bool gB_Shavit = false ;
59
65
bool gB_Late = false ;
60
66
float gF_Tickrate = 0.01 ; // 100 tickrate.
61
67
any gA_StyleSettings [STYLE_LIMIT ][STYLESETTINGS_SIZE ];
62
68
int gBS_Style [MAXPLAYERS +1 ];
63
69
bool gB_EnabledPlayers [MAXPLAYERS +1 ];
64
70
int gI_GroundTicks [MAXPLAYERS +1 ];
71
+ bool gB_StuckFriction [MAXPLAYERS +1 ];
65
72
66
73
public APLRes AskPluginLoad2 (Handle myself , bool late , char [] error , int err_max )
67
74
{
@@ -77,6 +84,8 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
77
84
78
85
public void OnPluginStart ()
79
86
{
87
+ gEV_Type = GetEngineVersion ();
88
+
80
89
gH_NoslideCookie = RegClientCookie (" noslide_enabled" , " Noslide settings" , CookieAccess_Protected );
81
90
82
91
gCV_Enabled = CreateConVar (" noslide_enabled" , " 0" , " Is noslide enabled?\n It's recommended to set to 0 as default,\n but use map-configs to enable it for specific maps.\n\n 0 - Disabled\n 1 - Enabled" , 0 , true , 0.0 , true , 2.0 );
@@ -88,7 +97,6 @@ public void OnPluginStart()
88
97
RegConsoleCmd (" sm_kz" , Command_Noslide , " Toggles noslide. Alias for sm_noslide." );
89
98
RegConsoleCmd (" sm_kzmode" , Command_Noslide , " Toggles noslide. Alias for sm_noslide." );
90
99
91
- gF_Tickrate = GetTickInterval ();
92
100
gB_Shavit = LibraryExists (" shavit" );
93
101
94
102
if (gB_Late )
@@ -107,6 +115,25 @@ public void OnPluginStart()
107
115
Shavit_OnStyleConfigLoaded (- 1 );
108
116
}
109
117
}
118
+
119
+ sv_friction = FindConVar (" sv_friction" );
120
+ sv_friction .Flags &= ~ (FCVAR_NOTIFY | FCVAR_REPLICATED );
121
+ sv_friction .GetString (gS_DefaultFriction , 16 );
122
+ gF_DefaultFriction = sv_friction .FloatValue ;
123
+ }
124
+
125
+ public void OnMapStart ()
126
+ {
127
+ gF_Tickrate = GetTickInterval ();
128
+ }
129
+
130
+ public void OnConfigsExecuted ()
131
+ {
132
+ if (sv_friction != null )
133
+ {
134
+ sv_friction .GetString (gS_DefaultFriction , 16 );
135
+ gF_DefaultFriction = sv_friction .FloatValue ;
136
+ }
110
137
}
111
138
112
139
public void OnConVarChanged (ConVar convar , const char [] oldValue , const char [] newValue )
@@ -133,11 +160,25 @@ public void OnLibraryRemoved(const char[] name)
133
160
public void OnClientPutInServer (int client )
134
161
{
135
162
gI_GroundTicks [client ] = 3 ;
163
+ gB_StuckFriction [client ] = false ;
136
164
137
165
if (! AreClientCookiesCached (client ))
138
166
{
139
167
gB_EnabledPlayers [client ] = false ;
140
168
}
169
+
170
+ if (gEV_Type == Engine_CSGO )
171
+ {
172
+ SDKHook (client , SDKHook_PreThinkPost , PreThinkPost );
173
+ }
174
+ }
175
+
176
+ public void PreThinkPost (int client )
177
+ {
178
+ if (IsPlayerAlive (client ))
179
+ {
180
+ sv_friction .FloatValue = (gB_StuckFriction [client ])? 50.0 : gF_DefaultFriction ;
181
+ }
141
182
}
142
183
143
184
public void OnClientCookiesCached (int client )
@@ -214,28 +255,41 @@ public Action OnPlayerRunCmd(int client, int &buttons)
214
255
return Plugin_Continue ;
215
256
}
216
257
217
- if (! gB_EnabledPlayers [client ] || (gB_Shavit && ! gA_StyleSettings [gBS_Style [client ]][bEasybhop ]))
258
+ if (! gB_EnabledPlayers [client ] || (gB_Shavit && ! gA_StyleSettings [gBS_Style [client ]][bEasybhop ]) || ( buttons & IN_JUMP ) > 0 )
218
259
{
219
260
return Plugin_Continue ;
220
261
}
221
262
222
263
float fStamina = GetEntPropFloat (client , Prop_Send , " m_flStamina" );
223
264
265
+ #if defined DEBUG
266
+ // PrintToChat(client, "m_flFriction: %f", GetEntPropFloat(client, Prop_Send, "m_flFriction"));
267
+ #endif
268
+
224
269
// Noslide when a jump is imperfect. Your jump is only perfect when you jump at the same tick you land!
225
- if (++ gI_GroundTicks [client ] == 2 && fStamina <= 350.0 ) // 350.0 is a sweetspoot for me.
270
+ if (++ gI_GroundTicks [client ] == (( gEV_Type == Engine_CSS ) ? 3 : 5 ) && ( gEV_Type != Engine_CSS || fStamina <= 350.0 ) ) // 350.0 is a sweetspoot for me.
226
271
{
227
- SetEntPropFloat (client , Prop_Send , " m_flStamina" , 1320.0 ); // 1320.0 is highest stamina in CS:S.
272
+ if (gEV_Type == Engine_CSS )
273
+ {
274
+ SetEntPropFloat (client , Prop_Send , " m_flStamina" , 1320.0 ); // 1320.0 is highest stamina in CS:S.
275
+ }
276
+
277
+ else
278
+ {
279
+ gB_StuckFriction [client ] = true ;
280
+ sv_friction .ReplicateToClient (client , " 50" );
281
+ }
228
282
229
283
DataPack pack = new DataPack ();
230
284
pack .WriteCell (GetClientSerial (client ));
231
285
pack .WriteFloat (fStamina );
232
286
233
- CreateTimer ((gF_Tickrate * 5 ), Timer_ApplyNewStamina , pack , TIMER_FLAG_NO_MAPCHANGE );
287
+ CreateTimer ((gEV_Type == Engine_CSS ) ? ( gF_Tickrate * 5 ): gF_Tickrate , Timer_ApplyNewStamina , pack , TIMER_FLAG_NO_MAPCHANGE );
234
288
235
289
#if defined DEBUG
236
290
if (gB_Shavit )
237
291
{
238
- Shavit_PrintToChat (client , " Applied new stamina. " );
292
+ Shavit_PrintToChat (client , " Applied new %s . " , ( gEV_Type == Engine_CSS ) ? " stamina " : " friction " );
239
293
}
240
294
#endif
241
295
}
@@ -254,7 +308,16 @@ public Action Timer_ApplyNewStamina(Handle timer, DataPack data)
254
308
255
309
if (client != 0 )
256
310
{
257
- SetEntPropFloat (client , Prop_Send , " m_flStamina" , fStamina );
311
+ if (gEV_Type == Engine_CSS )
312
+ {
313
+ SetEntPropFloat (client , Prop_Send , " m_flStamina" , fStamina );
314
+ }
315
+
316
+ else
317
+ {
318
+ sv_friction .ReplicateToClient (client , gS_DefaultFriction );
319
+ gB_StuckFriction [client ] = false ;
320
+ }
258
321
}
259
322
260
323
return Plugin_Stop ;
0 commit comments