summaryrefslogtreecommitdiff
path: root/sourcemod-1.5-dev/scripting/ljstats.sp
diff options
context:
space:
mode:
authornavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
committernavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
commitaef0d1c1268ab7d4bc18996c9c6b4da16a40aadc (patch)
tree43e766b51704f4ab8b383583bdc1871eeeb9c698 /sourcemod-1.5-dev/scripting/ljstats.sp
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod-1.5-dev/scripting/ljstats.sp')
-rw-r--r--sourcemod-1.5-dev/scripting/ljstats.sp218
1 files changed, 203 insertions, 15 deletions
diff --git a/sourcemod-1.5-dev/scripting/ljstats.sp b/sourcemod-1.5-dev/scripting/ljstats.sp
index 8167430..f220d39 100644
--- a/sourcemod-1.5-dev/scripting/ljstats.sp
+++ b/sourcemod-1.5-dev/scripting/ljstats.sp
@@ -14,6 +14,7 @@
#define MAX(%0,%1) (%0 < %1 ? %1 : %0)
#define LJSTATS_VERSION "2.0.1"
+#define MAX_JUMP_TICKS 132 // 2 sec
#define LJTOP_DIR "configs/ljstats/"
#define LJTOP_FILE "ljtop.txt"
@@ -33,8 +34,8 @@
#define BJ_HEIGHT_DELTA_MAX 2.0
#define LAJ_HEIGHT_DELTA_MIN -6.0
#define LAJ_HEIGHT_DELTA_MAX 0.0
-#define JB_HEIGHT_DELTA_MIN -4.0
-#define JB_HEIGHT_DELTA_MAX 1.0
+#define JB_HEIGHT_DELTA_MIN -1.0
+#define JB_HEIGHT_DELTA_MAX 1.5
#define HUD_HINT_SIZE 256
#define STRAFE_TRAINER_TICKS 9
@@ -57,6 +58,7 @@ enum PlayerState
bool:bBeam,
bool:bDeadstrafe,
bool:bSound,
+ bool:bSyncStats,
bool:bBlockMode,
nVerbosity,
bool:bShowAllJumps,
@@ -110,6 +112,8 @@ enum PlayerState
Float:fStrafeSync[MAX_STRAFES],
nStrafeTicks[MAX_STRAFES],
nStrafeTicksSynced[MAX_STRAFES],
+ nMoveDir[MAX_JUMP_TICKS],
+ nMouseDir[MAX_JUMP_TICKS],
nTotalTicks,
Float:fTotalAngle,
Float:fSyncedAngle,
@@ -405,6 +409,7 @@ new Handle:g_hCookieShowPrestrafeHint = INVALID_HANDLE;
new Handle:g_hCookiePersonalBest = INVALID_HANDLE;
new Handle:g_hCookieStrafeTrainer = INVALID_HANDLE;
new Handle:g_hCookieSpeedometer = INVALID_HANDLE;
+new Handle:g_hCookieSyncStats = INVALID_HANDLE;
new g_ColorMin[3] = {0xAD, 0xD8, 0xE6}; // Lightblue!
new g_ColorMax[3] = {0x00, 0x00, 0xFF};
@@ -528,6 +533,7 @@ public OnPluginStart()
RegConsoleCmd("sm_ljsound", Command_LJSound);
RegConsoleCmd("sm_ljver", Command_LJVersion);
RegConsoleCmd("sm_ljversion", Command_LJVersion);
+ RegConsoleCmd("sm_syncstats", Command_SyncStats);
RegConsoleCmd("sm_ljtop", Command_LJTop);
#if defined LJSERV
RegConsoleCmd("sm_wr", Command_LJTop);
@@ -564,7 +570,8 @@ public OnPluginStart()
g_hCookiePersonalBest = RegClientCookie("ljstats_personalbest", "ljstats_personalbest", CookieAccess_Private);
g_hCookieStrafeTrainer = RegClientCookie("ljstats_strafetrainer", "ljstats_strafetrainer", CookieAccess_Private);
g_hCookieSpeedometer = RegClientCookie("ljstats_speedometer", "ljstats_speedometer", CookieAccess_Private);
-
+ g_hCookieSyncStats = RegClientCookie("ljstats_syncstats", "ljstats_syncstats", CookieAccess_Private);
+
for(new i = 1; i < MaxClients; i++)
{
if(IsClientInGame(i))
@@ -1053,6 +1060,19 @@ public Action:Command_Delete(client, args)
return Plugin_Handled;
}
+public Action:Command_SyncStats( client, args ) {
+ if ( g_PlayerStates[client][bSyncStats] ) {
+ g_PlayerStates[client][bSyncStats] = false;
+ PrintToChat( client, "\x04Sync stats are now : DISABLED" );
+ } else {
+ g_PlayerStates[client][bSyncStats] = true;
+ PrintToChat( client, "\x04Sync stats are now : ENABLED" );
+ }
+
+ SetCookie( client, g_hCookieSyncStats, g_PlayerStates[client][bSyncStats] );
+ return Plugin_Handled;
+}
+
public Action:Command_LJHelp(client, args)
{
new Handle:hHelpPanel = CreatePanel();
@@ -1166,6 +1186,9 @@ public OnClientCookiesCached(client)
GetClientCookie(client, g_hCookieStrafeTrainer, strCookie, sizeof(strCookie));
g_PlayerStates[client][bStrafeTrainer] = bool:StringToInt(strCookie);
+
+ GetClientCookie(client, g_hCookieSyncStats, strCookie, sizeof(strCookie));
+ g_PlayerStates[client][bSyncStats] = bool:StringToInt(strCookie);
GetClientCookie(client, g_hCookieBeam, strCookie, sizeof(strCookie));
g_PlayerStates[client][bBeam] = bool:StringToInt(strCookie);
@@ -1253,6 +1276,9 @@ ShowSettingsPanel(client)
Format(buf, sizeof(buf), "Strafe trainer: %s", g_PlayerStates[client][bStrafeTrainer] ? "On" : "Off");
AddMenuItem(hMenu, "strafetrainer", buf);
+
+ Format(buf, sizeof(buf), "Sync stats: %s", g_PlayerStates[client][bSyncStats] ? "On" : "Off");
+ AddMenuItem(hMenu, "syncstats", buf);
DisplayMenu(hMenu, client, 0);
}
@@ -1356,6 +1382,9 @@ public SettingsMenuHandler(Handle:hMenu, MenuAction:ma, client, nItem)
PrintToChat( client, "Strafe trainer is now %s", g_PlayerStates[client][bStrafeTrainer] ? "ENABLED" : "DISABLED" );
ShowSettingsPanel(client);
}
+ else if(!strcmp(strInfo, "syncstats")) {
+ Command_SyncStats( client, 0 );
+ }
}
case MenuAction_End:
@@ -2473,13 +2502,8 @@ StrafeTrainer( client, bool: onGround, Float:angles[3], Float:velocity[3] ) {
b = 0;
}
- new Handle:hText = CreateHudSynchronizer();
- if(hText != INVALID_HANDLE)
- {
- SetHudTextParams(-1.0, 0.2, GetTickInterval() * (STRAFE_TRAINER_TICKS+1), r, g, b, 255, 0, 0.0, 0.0, 0.1);
- ShowSyncHudText(client, hText, msg);
- CloseHandle(hText);
- }
+ SetHudTextParams(-1.0, 0.2, GetTickInterval() * (STRAFE_TRAINER_TICKS+1), r, g, b, 255, 0, 0.0, 0.0, 0.1);
+ ShowHudText(client, 0, msg);
g_PlayerStates[client][nTrainerTicks] = 0;
}
@@ -2538,12 +2562,12 @@ Speedometer( client, bool: bJump, bool: bGround, bool: bIsDucking, Float:velocit
switch( g_PlayerStates[client][nSpeedometer] ) {
case 1: {
- SetHudTextParams(-1.0, 0.325, 0.05, r, g, b, 255, 0, 0.0, 0.0, 0.0);
+ SetHudTextParams(-1.0, 0.325, 0.1, r, g, b, 255, 0, 0.0, 0.0, 0.0);
ShowHudText(client, 1, sBuffer);
}
case 2: {
- SetHudTextParams(-1.0, 0.85, 0.05, r, g, b, 255, 0, 0.0, 0.0, 0.0);
+ SetHudTextParams(-1.0, 0.85, 0.1, r, g, b, 255, 0, 0.0, 0.0, 0.0);
ShowHudText(client, 1, sBuffer);
}
}
@@ -2723,6 +2747,11 @@ PlayerJump(client, JUMP_TYPE:JumpType2 = JT_LONGJUMP)
g_PlayerStates[client][nStrafeTicks][i] = 0;
g_PlayerStates[client][nStrafeTicksSynced][i] = 0;
}
+
+ for( new i = 0; i < MAX_JUMP_TICKS; ++i ) {
+ g_PlayerStates[client][nMouseDir][i] = 0;
+ g_PlayerStates[client][nMoveDir][i] = 0;
+ }
// Reset stuff
g_PlayerStates[client][JumpDir] = JD_NONE;
@@ -2812,7 +2841,9 @@ PlayerJump(client, JUMP_TYPE:JumpType2 = JT_LONGJUMP)
new Float:vVel[3];
GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
- vOrigin[2] += vVel[2] * GetTickInterval();
+ // ducking lowers u by 8.5 units
+ if( GetEntProp(client, Prop_Send, "m_bDucking", 1) )
+ vOrigin[2] -= 8.5;
}
Array_Copy(vOrigin, g_PlayerStates[client][vJumpOrigin], 3);
@@ -3358,11 +3389,11 @@ _OnPlayerRunCmd(client, buttons, const Float:vOrigin[3], const Float:vAngles[3],
new Float:fVelDelta = GetSpeed(client) - GetVSpeed(v);
new Float:fAngleDelta = fmod((FloatAbs(vAngles[1] - v2[1]) + 180.0), 360.0) - 180.0;
-
g_PlayerStates[client][nStrafeTicks][g_PlayerStates[client][nStrafes] - 1]++;
g_PlayerStates[client][fTotalAngle] += fAngleDelta;
+ new tick = g_PlayerStates[client][nTotalTicks];
if(fVelDelta > 0.0)
{
g_PlayerStates[client][fStrafeGain][g_PlayerStates[client][nStrafes] - 1] += fVelDelta;
@@ -3371,11 +3402,44 @@ _OnPlayerRunCmd(client, buttons, const Float:vOrigin[3], const Float:vAngles[3],
g_PlayerStates[client][nStrafeTicksSynced][g_PlayerStates[client][nStrafes] - 1]++;
g_PlayerStates[client][fSyncedAngle] += fAngleDelta;
+ new Float:delta = vAngles[1] - v2[1];
+ while(delta < -180.0)
+ delta += 360.0;
+ while(delta > 180.0)
+ delta -= 360.0;
+
+ if( tick < MAX_JUMP_TICKS )
+ g_PlayerStates[client][nMouseDir][tick] = delta > 0.0 ? -1 : 1;
}
else
{
g_PlayerStates[client][fStrafeLoss][g_PlayerStates[client][nStrafes] - 1] -= fVelDelta;
g_PlayerStates[client][fLoss] -= fVelDelta;
+ if( tick < MAX_JUMP_TICKS )
+ g_PlayerStates[client][nMouseDir][tick] = 0;
+ }
+
+ if( tick < MAX_JUMP_TICKS ) {
+ if( g_PlayerStates[client][JumpDir] == JD_SIDEWAYS ) {
+ if( !nButtonCount )
+ g_PlayerStates[client][nMoveDir][tick] = 0;
+ else if( g_PlayerStates[client][CurStrafeDir] == SD_W )
+ g_PlayerStates[client][nMoveDir][tick] = -1;
+ else if( g_PlayerStates[client][CurStrafeDir] == SD_S )
+ g_PlayerStates[client][nMoveDir][tick] = 1;
+ else
+ g_PlayerStates[client][nMoveDir][tick] = 0;
+ }
+ else {
+ if( !nButtonCount )
+ g_PlayerStates[client][nMoveDir][tick] = 0;
+ else if( g_PlayerStates[client][CurStrafeDir] == SD_A )
+ g_PlayerStates[client][nMoveDir][tick] = -1;
+ else if( g_PlayerStates[client][CurStrafeDir] == SD_D )
+ g_PlayerStates[client][nMoveDir][tick] = 1;
+ else
+ g_PlayerStates[client][nMoveDir][tick] = 0;
+ }
}
}
@@ -3454,6 +3518,130 @@ PrintPrestrafeHint(client)
PrintHintText(client, strHint);
}
+public PrintSyncStats(client) {
+ new String:strLeft[256];
+ new String:strRight[256];
+ new String:strMouseLeft[256];
+ new String:strMouseRight[256];
+
+ new String:strFull[1024];
+
+ if( g_PlayerStates[client][nStrafes] == 0 )
+ return;
+ if( g_PlayerStates[client][nTotalTicks] < 10 )
+ return;
+
+ Format( strLeft, sizeof( strLeft ), "[ " );
+ Format( strRight, sizeof( strRight ), "[ " );
+ Format( strMouseLeft, sizeof( strMouseLeft ), "[ " );
+ Format( strMouseRight, sizeof( strMouseRight ), "[ " );
+
+ for( new i = 0; i < g_PlayerStates[client][nTotalTicks]; ++i ) {
+ if( g_PlayerStates[client][nMouseDir][i] == -1 ) {
+ Append( strMouseLeft, sizeof( strMouseLeft ), "|" );
+ Append( strMouseRight, sizeof( strMouseRight ), " " );
+ }
+ else if( g_PlayerStates[client][nMouseDir][i] == 1 ) {
+ Append( strMouseLeft, sizeof( strMouseLeft ), " " );
+ Append( strMouseRight, sizeof( strMouseRight ), "|" );
+ }
+ else {
+ Append( strMouseLeft, sizeof( strMouseLeft ), " " );
+ Append( strMouseRight, sizeof( strMouseRight ), " " );
+ }
+
+ if( g_PlayerStates[client][nMoveDir][i] == -1 ) {
+ Append( strLeft, sizeof( strLeft ), "|" );
+ Append( strRight, sizeof( strRight ), " " );
+ }
+ else if( g_PlayerStates[client][nMoveDir][i] == 1 ) {
+ Append( strLeft, sizeof( strLeft ), " " );
+ Append( strRight, sizeof( strRight ), "|" );
+ }
+ else {
+ Append( strLeft, sizeof( strLeft ), " " );
+ Append( strRight, sizeof( strRight ), " " );
+ }
+ }
+
+ Format( strLeft, sizeof( strLeft ), "%s ]", strLeft );
+ Format( strRight, sizeof( strRight ), "%s ]", strRight );
+ Format( strMouseLeft, sizeof( strMouseLeft ), "%s ]", strMouseLeft );
+ Format( strMouseRight, sizeof( strMouseRight ), "%s ]", strMouseRight );
+
+ if( g_PlayerStates[client][JumpDir] == JD_SIDEWAYS ) {
+ Format( strFull, sizeof( strFull ), "W: %s\nS: %s\nL: %s\nR: %s", strLeft, strRight, strMouseLeft, strMouseRight );
+ }
+ else {
+ Format( strFull, sizeof( strFull ), "A: %s\nD: %s\nL: %s\nR: %s", strLeft, strRight, strMouseLeft, strMouseRight );
+ }
+
+ PrintToConsole( client, strFull );
+
+ if( g_PlayerStates[client][bSyncStats] ) {
+ Format( strLeft, sizeof( strLeft ), "[ " );
+ Format( strRight, sizeof( strRight ), "[ " );
+ Format( strMouseLeft, sizeof( strMouseLeft ), "[ " );
+ Format( strMouseRight, sizeof( strMouseRight ), "[ " );
+
+ new String:char1[] = "|";
+ new String:char2[] = "_";
+ new String:strFull2[1024];
+
+ for( new i = 0; i < g_PlayerStates[client][nTotalTicks]; ++i ) {
+ if( g_PlayerStates[client][nMouseDir][i] == -1 ) {
+ Append( strMouseLeft, sizeof( strMouseLeft ), char1 );
+ Append( strMouseRight, sizeof( strMouseRight ), char2 );
+ }
+ else if( g_PlayerStates[client][nMouseDir][i] == 1 ) {
+ Append( strMouseLeft, sizeof( strMouseLeft ), char2 );
+ Append( strMouseRight, sizeof( strMouseRight ), char1 );
+ }
+ else {
+ Append( strMouseLeft, sizeof( strMouseLeft ), char2 );
+ Append( strMouseRight, sizeof( strMouseRight ), char2 );
+ }
+
+ if( g_PlayerStates[client][nMoveDir][i] == -1 ) {
+ Append( strLeft, sizeof( strLeft ), char1 );
+ Append( strRight, sizeof( strRight ), char2 );
+ }
+ else if( g_PlayerStates[client][nMoveDir][i] == 1 ) {
+ Append( strLeft, sizeof( strLeft ), char2 );
+ Append( strRight, sizeof( strRight ), char1 );
+ }
+ else {
+ Append( strLeft, sizeof( strLeft ), char2 );
+ Append( strRight, sizeof( strRight ), char2 );
+ }
+ }
+
+ Format( strLeft, sizeof( strLeft ), "%s ]", strLeft );
+ Format( strRight, sizeof( strRight ), "%s ]", strRight );
+ Format( strMouseLeft, sizeof( strMouseLeft ), "%s ]", strMouseLeft );
+ Format( strMouseRight, sizeof( strMouseRight ), "%s ]", strMouseRight );
+
+ if( g_PlayerStates[client][JumpDir] == JD_SIDEWAYS ) {
+ Format( strFull, sizeof( strFull ), "W: %s\nS: %s\n", strLeft, strRight );
+ }
+ else {
+ Format( strFull, sizeof( strFull ), "A: %s\nD: %s\n", strLeft, strRight );
+ }
+
+ Format( strFull2, sizeof( strFull2 ), "L: %s\nR: %s", strMouseLeft, strMouseRight );
+
+ new Handle:hText = CreateHudSynchronizer();
+ if(hText != INVALID_HANDLE)
+ {
+ SetHudTextParams(-1.0, 0.06, 3.0, 255, 255, 255, 255, 0, 0.0, 0.15, 0.5);
+ ShowHudText(client, 2, strFull);
+ SetHudTextParams(-1.0, 0.14, 3.0, 180, 180, 255, 255, 0, 0.0, 0.15, 0.5);
+ ShowHudText(client, 3, strFull2);
+ CloseHandle(hText);
+ }
+ }
+}
+
PlayerLand(client)
{
g_PlayerStates[client][bOnGround] = true;
@@ -3463,7 +3651,7 @@ PlayerLand(client)
if(!g_PlayerStates[client][bLJEnabled] && !g_PlayerStates[client][nSpectators] || !g_PlayerStates[client][bShowBhopStats] && g_PlayerStates[client][nBhops] > 1)
return;
-
+ PrintSyncStats( client );
// Final CheckValidJump
//CheckValidJump(client);