-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathshavit-ssj.sp
697 lines (563 loc) · 18.7 KB
/
shavit-ssj.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#include <sdktools>
#include <sdkhooks>
#include <clientprefs>
#undef REQUIRE_PLUGIN
#include <shavit>
#pragma semicolon 1
#pragma newdecls required
public Plugin myinfo =
{
name = "SSJ: Advanced",
author = "AlkATraZ",
description = "Strafe gains/efficiency etc. // Edited by Nairda to work with shavit's timer",
version = "0.1",
url = "https://forums.alliedmods.net/showthread.php?t=287039"
}
#define BHOP_FRAMES 10
Handle g_hCookieEnabled = null;
Handle g_hCookieUsageMode = null;
Handle g_hCookieUsageRepeat = null;
Handle g_hCookieCurrentSpeed = null;
Handle g_hCookieFirstJump = null;
Handle g_hCookieHeightDiff = null;
Handle g_hCookieGainStats = null;
Handle g_hCookieEfficiency = null;
Handle g_hCookieTime = null;
Handle g_hCookieDeltaTime = null;
Handle g_hCookieStrafeCount = null;
Handle g_hCookieStrafeSync = null;
Handle g_hCookieDefaultsSet = null;
bool g_bUsageRepeat[MAXPLAYERS + 1];
bool g_bEnabled[MAXPLAYERS + 1] = { true, ... };
bool g_bCurrentSpeed[MAXPLAYERS + 1] = { true, ... };
bool g_bFirstJump[MAXPLAYERS + 1] = { true, ... };
bool g_bHeightDiff[MAXPLAYERS + 1];
bool g_bGainStats[MAXPLAYERS + 1] = { true, ... };
bool g_bEfficiency[MAXPLAYERS + 1];
bool g_bTime[MAXPLAYERS + 1];
bool g_bStrafeSync[MAXPLAYERS + 1];
bool g_bTouchesWall[MAXPLAYERS + 1];
bool g_bStrafeCount[MAXPLAYERS + 1];
int g_iUsageMode[MAXPLAYERS + 1];
int g_iTicksOnGround[MAXPLAYERS + 1];
int g_iTouchTicks[MAXPLAYERS + 1];
int g_iStrafeTick[MAXPLAYERS + 1];
int g_iSyncedTick[MAXPLAYERS + 1];
int g_iJump[MAXPLAYERS + 1];
int g_iOldSSJTarget[MAXPLAYERS + 1];
int g_iButtonCache[MAXPLAYERS + 1];
int g_iStrafeCount[MAXPLAYERS + 1];
float g_fInitialHeight[MAXPLAYERS + 1];
float g_fOldHeight[MAXPLAYERS + 1];
float g_fOldSpeed[MAXPLAYERS + 1];
float g_fRawGain[MAXPLAYERS + 1];
float g_fTrajectory[MAXPLAYERS + 1];
float g_fTraveledDistance[MAXPLAYERS + 1][3];
float g_fSpeedLoss[MAXPLAYERS + 1];
float g_fOldVelocity[MAXPLAYERS + 1];
float g_fTickrate = 0.01;
// misc settings
bool g_bLate = false;
bool g_bShavit = false;
EngineVersion gEV_Type = Engine_Unknown;
chatstrings_t gS_ChatStrings;
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_bLate = late;
return APLRes_Success;
}
public void OnPluginStart()
{
RegConsoleCmd("sm_ssj", Command_SSJ, "Open the Speed @ Sixth Jump menu.");
g_hCookieEnabled = RegClientCookie("ssj_enabled", "ssj_enabled", CookieAccess_Public);
g_hCookieUsageMode = RegClientCookie("ssj_displaymode", "ssj_displaymode", CookieAccess_Public);
g_hCookieUsageRepeat = RegClientCookie("ssj_displayrepeat", "ssj_displayrepeat", CookieAccess_Public);
g_hCookieCurrentSpeed = RegClientCookie("ssj_currentspeed", "ssj_currentspeed", CookieAccess_Public);
g_hCookieFirstJump = RegClientCookie("ssj_firstjump", "ssj_firstjump", CookieAccess_Public);
g_hCookieHeightDiff = RegClientCookie("ssj_heightdiff", "ssj_heightdiff", CookieAccess_Public);
g_hCookieGainStats = RegClientCookie("ssj_gainstats", "ssj_gainstats", CookieAccess_Public);
g_hCookieEfficiency = RegClientCookie("ssj_efficiency", "ssj_efficiency", CookieAccess_Public);
g_hCookieTime = RegClientCookie("ssj_time", "ssj_time", CookieAccess_Public);
g_hCookieDeltaTime = RegClientCookie("ssj_deltatime", "ssj_deltatime", CookieAccess_Public);
g_hCookieStrafeCount = RegClientCookie("ssj_strafecount", "ssj_strafecount", CookieAccess_Public);
g_hCookieStrafeSync = RegClientCookie("ssj_strafesync", "ssj_strafesync", CookieAccess_Public);
g_hCookieDefaultsSet = RegClientCookie("ssj_defaults", "ssj_defaults", CookieAccess_Public);
HookEvent("player_jump", Player_Jump);
for (int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
{
OnClientPutInServer(i);
OnClientCookiesCached(i);
}
}
if(g_bLate)
{
Shavit_OnChatConfigLoaded();
}
g_bShavit = LibraryExists("shavit");
gEV_Type = GetEngineVersion();
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, "shavit"))
{
g_bShavit = true;
}
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, "shavit"))
{
g_bShavit = false;
}
}
public void OnMapStart()
{
g_fTickrate = GetTickInterval();
}
public void Shavit_OnChatConfigLoaded()
{
Shavit_GetChatStrings(sMessagePrefix, gS_ChatStrings.sPrefix, sizeof(chatstrings_t::sPrefix));
Shavit_GetChatStrings(sMessageText, gS_ChatStrings.sText, sizeof(chatstrings_t::sText));
Shavit_GetChatStrings(sMessageWarning, gS_ChatStrings.sWarning, sizeof(chatstrings_t::sWarning));
Shavit_GetChatStrings(sMessageVariable, gS_ChatStrings.sVariable, sizeof(chatstrings_t::sVariable));
Shavit_GetChatStrings(sMessageVariable2, gS_ChatStrings.sVariable2, sizeof(chatstrings_t::sVariable2));
Shavit_GetChatStrings(sMessageStyle, gS_ChatStrings.sStyle, sizeof(chatstrings_t::sStyle));
}
public void OnClientCookiesCached(int client)
{
char sCookie[8];
GetClientCookie(client, g_hCookieDefaultsSet, sCookie, 8);
if(StringToInt(sCookie) == 0)
{
SetCookie(client, g_hCookieEnabled, true);
SetCookie(client, g_hCookieUsageMode, 6);
SetCookie(client, g_hCookieUsageRepeat, false);
SetCookie(client, g_hCookieCurrentSpeed, true);
SetCookie(client, g_hCookieFirstJump, true);
SetCookie(client, g_hCookieHeightDiff, false);
SetCookie(client, g_hCookieGainStats, true);
SetCookie(client, g_hCookieEfficiency, false);
SetCookie(client, g_hCookieTime, false);
SetCookie(client, g_hCookieDeltaTime, false);
SetCookie(client, g_hCookieStrafeCount, false);
SetCookie(client, g_hCookieStrafeSync, false);
SetCookie(client, g_hCookieDefaultsSet, true);
}
GetClientCookie(client, g_hCookieEnabled, sCookie, 8);
g_bEnabled[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieUsageMode, sCookie, 8);
g_iUsageMode[client] = StringToInt(sCookie);
GetClientCookie(client, g_hCookieUsageRepeat, sCookie, 8);
g_bUsageRepeat[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieCurrentSpeed, sCookie, 8);
g_bCurrentSpeed[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieFirstJump, sCookie, 8);
g_bFirstJump[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieHeightDiff, sCookie, 8);
g_bHeightDiff[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieGainStats, sCookie, 8);
g_bGainStats[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieEfficiency, sCookie, 8);
g_bEfficiency[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieTime, sCookie, 8);
g_bTime[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieStrafeCount, sCookie, 8);
g_bStrafeCount[client] = view_as<bool>(StringToInt(sCookie));
GetClientCookie(client, g_hCookieStrafeSync, sCookie, 8);
g_bStrafeSync[client] = view_as<bool>(StringToInt(sCookie));
}
public void OnClientPutInServer(int client)
{
g_iJump[client] = 0;
g_iStrafeTick[client] = 0;
g_iSyncedTick[client] = 0;
g_fRawGain[client] = 0.0;
g_fOldHeight[client] = 0.0;
g_fOldSpeed[client] = 0.0;
g_fTrajectory[client] = 0.0;
g_fTraveledDistance[client] = NULL_VECTOR;
g_iTicksOnGround[client] = 0;
g_iStrafeCount[client] = 0;
g_iOldSSJTarget[client] = 0;
SDKHook(client, SDKHook_Touch, OnTouch);
}
public Action OnTouch(int client, int entity)
{
if ((GetEntProp(entity, Prop_Data, "m_usSolidFlags") & 12) == 0)
{
g_bTouchesWall[client] = true;
}
return Plugin_Handled;
}
int GetHUDTarget(int client)
{
int target = client;
if(IsValidClient(client))
{
int iObserverMode = GetEntProp(client, Prop_Send, "m_iObserverMode");
if(iObserverMode >= 3 && iObserverMode <= 5)
{
int iTarget = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
if(IsValidClient(iTarget))
{
target = iTarget;
}
}
}
return target;
}
void UpdateStats(int client)
{
int target = client; //GetHUDTarget(client);
float velocity[3];
GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", velocity);
velocity[2] = 0.0;
float origin[3];
GetClientAbsOrigin(target, origin);
g_fRawGain[client] = 0.0;
g_iStrafeTick[client] = 0;
g_iSyncedTick[client] = 0;
g_iStrafeCount[client] = 0;
g_fSpeedLoss[client] = 0.0;
g_fOldHeight[client] = origin[2];
g_fOldSpeed[client] = GetVectorLength(velocity);
g_fTrajectory[client] = 0.0;
g_fTraveledDistance[client] = NULL_VECTOR;
}
public void Player_Jump(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if(IsFakeClient(client) || (g_iJump[client] > 0 && g_iStrafeTick[client] == 0))
{
return;
}
if(Shavit_GetTimerStatus(client) != Timer_Running)
{
g_iJump[client]++;
}
else
{
g_iJump[client] = Shavit_GetClientJumps(client);
}
//bool shouldUpdateStats = false;
//bool printedStats = false;
for (int i = 1; i <= MaxClients; i++)
{
if(!g_bEnabled[i])
{
continue;
}
if(!IsValidClient(i))
{
continue;
}
if(GetHUDTarget(i) != client)
{
continue;
}
SSJ_PrintStats(i, client);
}
UpdateStats(client);
}
public Action Command_SSJ(int client, int args)
{
if(client == 0)
{
ReplyToCommand(client, "[SM] This command can only be used in-game.");
return Plugin_Handled;
}
return ShowSSJMenu(client);
}
Action ShowSSJMenu(int client, int item = 0)
{
Menu menu = new Menu(SSJ_MenuHandler);
menu.SetTitle("Speed @ Sixth Jump\n ");
menu.AddItem("usage", (g_bEnabled[client]) ? "[x] Enabled":"[ ] Enabled");
char sMenu[64];
FormatEx(sMenu, 64, "[%d] Jump", g_iUsageMode[client]);
menu.AddItem("mode", sMenu);
menu.AddItem("repeat", (g_bUsageRepeat[client]) ? "[x] Repeat":"[ ] Repeat");
menu.AddItem("curspeed", (g_bCurrentSpeed[client]) ? "[x] Current speed":"[ ] Current speed");
menu.AddItem("firstjump", (g_bFirstJump[client]) ? "[x] First jump":"[ ] First jump");
menu.AddItem("height", (g_bHeightDiff[client]) ? "[x] Height difference":"[ ] Height difference");
menu.AddItem("gain", (g_bGainStats[client]) ? "[x] Gain percentage":"[ ] Gain percentage");
menu.AddItem("efficiency", (g_bEfficiency[client]) ? "[x] Strafe efficiency":"[ ] Strafe efficiency");
menu.AddItem("time", (g_bTime[client]) ? "[x] Time counter":"[ ] Time counter");
menu.AddItem("strafe", (g_bStrafeCount[client]) ? "[x] Strafe":"[ ] Strafe");
menu.AddItem("sync", (g_bStrafeSync[client]) ? "[x] Synchronization":"[ ] Synchronization");
menu.ExitButton = true;
menu.DisplayAt(client, item, 0);
return Plugin_Handled;
}
public int SSJ_MenuHandler(Menu menu, MenuAction action, int param1, int param2)
{
if(action == MenuAction_Select)
{
switch (param2)
{
case 0:
{
g_bEnabled[param1] = !g_bEnabled[param1];
SetCookie(param1, g_hCookieEnabled, g_bEnabled[param1]);
}
case 1:
{
g_iUsageMode[param1] = (g_iUsageMode[param1] % 9) + 1;
SetCookie(param1, g_hCookieUsageMode, g_iUsageMode[param1]);
}
case 2:
{
g_bUsageRepeat[param1] = !g_bUsageRepeat[param1];
SetCookie(param1, g_hCookieUsageRepeat, g_bUsageRepeat[param1]);
}
case 3:
{
g_bCurrentSpeed[param1] = !g_bCurrentSpeed[param1];
SetCookie(param1, g_hCookieCurrentSpeed, g_bCurrentSpeed[param1]);
}
case 4:
{
g_bFirstJump[param1] = !g_bFirstJump[param1];
SetCookie(param1, g_hCookieFirstJump, g_bFirstJump[param1]);
}
case 5:
{
g_bHeightDiff[param1] = !g_bHeightDiff[param1];
SetCookie(param1, g_hCookieHeightDiff, g_bHeightDiff[param1]);
}
case 6:
{
g_bGainStats[param1] = !g_bGainStats[param1];
SetCookie(param1, g_hCookieGainStats, g_bGainStats[param1]);
}
case 7:
{
g_bEfficiency[param1] = !g_bEfficiency[param1];
SetCookie(param1, g_hCookieEfficiency, g_bEfficiency[param1]);
}
case 8:
{
g_bTime[param1] = !g_bTime[param1];
SetCookie(param1, g_hCookieTime, g_bTime[param1]);
}
case 9:
{
g_bStrafeCount[param1] = !g_bStrafeCount[param1];
SetCookie(param1, g_hCookieStrafeCount, g_bStrafeCount[param1]);
}
case 10:
{
g_bStrafeSync[param1] = !g_bStrafeSync[param1];
SetCookie(param1, g_hCookieStrafeSync, g_bStrafeSync[param1]);
}
}
ShowSSJMenu(param1, GetMenuSelectionPosition());
}
else if(action == MenuAction_End)
{
delete menu;
}
return 0;
}
void SSJ_GetStats(int client, float vel[3], float angles[3])
{
float velocity[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", velocity);
g_iStrafeTick[client]++;
float speedmulti = GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
g_fTraveledDistance[client][0] += velocity[0] * g_fTickrate * speedmulti;
g_fTraveledDistance[client][1] += velocity[1] * g_fTickrate * speedmulti;
velocity[2] = 0.0;
g_fTrajectory[client] += GetVectorLength(velocity) * g_fTickrate * speedmulti;
float fore[3];
float side[3];
GetAngleVectors(angles, fore, side, NULL_VECTOR);
fore[2] = 0.0;
NormalizeVector(fore, fore);
side[2] = 0.0;
NormalizeVector(side, side);
float wishvel[3];
float wishdir[3];
for (int i = 0; i < 2; i++)
{
wishvel[i] = fore[i] * vel[0] + side[i] * vel[1];
}
float wishspeed = NormalizeVector(wishvel, wishdir);
float maxspeed = GetEntPropFloat(client, Prop_Send, "m_flMaxspeed");
if(maxspeed != 0.0 && wishspeed > maxspeed)
{
wishspeed = maxspeed;
}
if(wishspeed > 0.0)
{
float wishspd = (wishspeed > 30.0) ? 30.0:wishspeed;
float currentgain = GetVectorDotProduct(velocity, wishdir);
float gaincoeff = 0.0;
if(currentgain < 30.0)
{
g_iSyncedTick[client]++;
gaincoeff = (wishspd - FloatAbs(currentgain)) / wishspd;
}
if(g_bTouchesWall[client] && g_iTouchTicks[client] && gaincoeff > 0.5)
{
gaincoeff -= 1.0;
gaincoeff = FloatAbs(gaincoeff);
}
g_fRawGain[client] += gaincoeff;
}
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3])
{
int flags = GetEntityFlags(client);
float speed = GetClientVelocity(client);
if(flags & FL_ONGROUND != FL_ONGROUND)
{
if ((g_iButtonCache[client] & IN_FORWARD) != IN_FORWARD && (buttons & IN_FORWARD) == IN_FORWARD)
{
g_iStrafeCount[client]++;
}
if ((g_iButtonCache[client] & IN_MOVELEFT) != IN_MOVELEFT && (buttons & IN_MOVELEFT) == IN_MOVELEFT)
{
g_iStrafeCount[client]++;
}
if ((g_iButtonCache[client] & IN_BACK) != IN_BACK && (buttons & IN_BACK) == IN_BACK)
{
g_iStrafeCount[client]++;
}
if ((g_iButtonCache[client] & IN_MOVERIGHT) != IN_MOVERIGHT && (buttons & IN_MOVERIGHT) == IN_MOVERIGHT)
{
g_iStrafeCount[client]++;
}
}
if(g_fOldVelocity[client] > speed)
{
g_fSpeedLoss[client] += (FloatAbs(speed - g_fOldVelocity[client]));
}
if(flags & FL_ONGROUND == FL_ONGROUND)
{
if(g_iTicksOnGround[client]++ > BHOP_FRAMES)
{
g_iJump[client] = 0;
g_iStrafeTick[client] = 0;
g_iSyncedTick[client] = 0;
g_fRawGain[client] = 0.0;
g_fTrajectory[client] = 0.0;
g_iStrafeCount[client] = 0;
g_fSpeedLoss[client] = 0.0;
g_fTraveledDistance[client] = NULL_VECTOR;
}
if ((buttons & IN_JUMP) > 0 && g_iTicksOnGround[client] == 1)
{
SSJ_GetStats(client, vel, angles);
g_iTicksOnGround[client] = 0;
}
}
else
{
MoveType movetype = GetEntityMoveType(client);
if(movetype != MOVETYPE_NONE && movetype != MOVETYPE_NOCLIP && movetype != MOVETYPE_LADDER && GetEntProp(client, Prop_Data, "m_nWaterLevel") < 2)
{
SSJ_GetStats(client, vel, angles);
}
g_iTicksOnGround[client] = 0;
}
if(g_bTouchesWall[client])
{
g_iTouchTicks[client]++;
g_bTouchesWall[client] = false;
}
else
{
g_iTouchTicks[client] = 0;
}
g_iButtonCache[client] = buttons;
g_fOldVelocity[client] = speed;
return Plugin_Continue;
}
bool SSJ_PrintStats(int client, int target)
{
if (g_iJump[target] == 1)
{
if (!g_bFirstJump[client] && g_iUsageMode[client] != 1)
return false;
}
else if (g_bUsageRepeat[client])
{
if (g_iJump[target] % g_iUsageMode[client] != 0)
return false;
}
else if (g_iJump[target] != g_iUsageMode[client])
return false;
float velocity[3];
GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", velocity);
velocity[2] = 0.0;
float origin[3];
GetClientAbsOrigin(target, origin);
float coeffsum = 0.0;
if (g_iStrafeTick[target] > 0)
coeffsum = g_fRawGain[target] / g_iStrafeTick[target] * 100.0;
float distance = GetVectorLength(g_fTraveledDistance[target]);
if (distance > g_fTrajectory[target])
distance = g_fTrajectory[target];
float efficiency = 0.0;
if (distance > 0.0 && g_fTrajectory[target] > 0.0)
efficiency = coeffsum * distance / g_fTrajectory[target];
coeffsum = RoundToFloor(coeffsum * 100.0 + 0.5) / 100.0;
efficiency = RoundToFloor(efficiency * 100.0 + 0.5) / 100.0;
char sMessage[192];
FormatEx(sMessage, sizeof(sMessage), "J: %s%i", gS_ChatStrings.sVariable, g_iJump[target]);
float time = Shavit_GetClientTime(target);
char sTime[32];
if (g_bCurrentSpeed[client])
Format(sMessage, sizeof(sMessage), "%s %s| Spd: %s%i", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, RoundToFloor(GetVectorLength(velocity)));
if (g_iJump[target] > 0)
{
if (g_bHeightDiff[client])
Format(sMessage, sizeof(sMessage), "%s %s| H Δ: %s%i", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, RoundToFloor(origin[2]) - RoundToFloor(g_fInitialHeight[target]));
if (g_bGainStats[client])
Format(sMessage, sizeof(sMessage), "%s %s| Gn: %s%.2f%%", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, coeffsum);
if (g_bStrafeSync[client])
Format(sMessage, sizeof(sMessage), "%s %s| Snc: %s%.2f%%", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, 100.0 * g_iSyncedTick[target] / g_iStrafeTick[target]);
if (g_bEfficiency[client])
Format(sMessage, sizeof(sMessage), "%s %s| Eff: %s%.2f%%", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, efficiency);
if (g_bStrafeCount[client])
Format(sMessage, sizeof(sMessage), "%s %s| Strf: %s%i", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, g_iStrafeCount[target]);
if (g_bTime[client])
{
FormatSeconds(time, sTime, sizeof(sTime), true);
Format(sMessage, sizeof(sMessage), "%s %s| T: %s%s", sMessage, gS_ChatStrings.sText, gS_ChatStrings.sVariable, sTime);
}
Format(sMessage, sizeof(sMessage), "%s %s| J: %i", sMessage, gS_ChatStrings.sText, g_iJump[target]);
}
PrintToClient(client, "%s", sMessage);
return true;
}
void PrintToClient(int client, const char[] message, any...)
{
char buffer[300];
VFormat(buffer, sizeof(buffer), message, 3);
if (g_bShavit)
{
Shavit_StopChatSound();
Shavit_PrintToChat(client, "%s", buffer); // Thank you, GAMMACASE
}
else
{
PrintToChat(client, "%s%s%s%s", (gEV_Type == Engine_CSGO) ? " " : "", gS_ChatStrings.sPrefix, gS_ChatStrings.sText, buffer);
}
}
void SetCookie(int client, Handle hCookie, int n)
{
char sCookie[8];
IntToString(n, sCookie, 8);
SetClientCookie(client, hCookie, sCookie);
}
float GetClientVelocity(int client)
{
float vVel[3];
vVel[0] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]");
vVel[1] = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]");
return GetVectorLength(vVel);
}