From f214af99fceeb3de07d9e147fd6fd93dabfc87c8 Mon Sep 17 00:00:00 2001 From: mourningsickness Date: Tue, 6 Jan 2026 13:55:14 -0800 Subject: [PATCH 1/7] update forward to work with bhoptimer 4.0 --- addons/sourcemod/scripting/offstyledb.sp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index 83a5647..3eb0f9a 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -13,7 +13,7 @@ native float Shavit_GetWorldRecord(int style, int track); native bool Shavit_IsPracticeMode(int client); native bool Shavit_IsPaused(int client); -forward void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, bool iscopy, const char[] replaypath); +forward void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name); forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp); forward void OnTimerFinished_Post(int client, float Time, int Type, int Style, bool tas, bool NewTime, int OldPosition, int NewPosition); @@ -495,7 +495,7 @@ public Action Command_RefreshMapping(int client, int args) } // Handle WR submissions with replay files - fires after replay is saved -public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, bool iscopy, const char[] replaypath) +public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name) { if(client == 0) { return; @@ -524,7 +524,9 @@ public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, i int sDate = GetTime(); - SendRecord(sMap, sSteamID, sName, sDate, time, sync, strafes, jumps, style, true, replaypath); + char sReplayPath[128]; + replaypaths.GetString(0, sReplayPath, sizeof(sReplayPath)); + SendRecord(sMap, sSteamID, sName, sDate, time, sync, strafes, jumps, style, true, sReplayPath); } public void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp) From 0f71741333c1b4f143b363f3f2f2743413a4fd5d Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:12:38 -0600 Subject: [PATCH 2/7] use correct forward syntax (i think?) --- addons/sourcemod/scripting/offstyledb.sp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index 3eb0f9a..37e4689 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -3,9 +3,14 @@ #include #include #include +#include +#include +#include #define API_BASE_URL "https://offstyles.tommyy.dev/api" +#undef REQUIRE_PLUGIN + #pragma dynamic 104857600 #pragma newdecls required #pragma semicolon 1 @@ -87,6 +92,12 @@ public Plugin myinfo = public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) { MarkNativeAsOptional("Shavit_GetWorldRecord"); + MarkNativeAsOptional("Shavit_OnReplaySaved"); + MarkNativeAsOptional("OnTimerFinished_Post"); + MarkNativeAsOptional("Shavit_OnFinish"); + MarkNativeAsOptional("Shavit_IsPracticeMode"); + MarkNativeAsOptional("Shavit_IsPaused"); + return APLRes_Success; } From a12d9527a7127cac8f96b4f01ef1e9fc10f23c61 Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:13:08 -0600 Subject: [PATCH 3/7] Remove duplicate stock functions --- addons/sourcemod/scripting/offstyledb.sp | 48 ------------------------ 1 file changed, 48 deletions(-) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index 37e4689..12e92a3 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -986,54 +986,6 @@ JSONObject GetTimeJsonFromResult(DBResultSet results) return hJSON; } -// stocks from shavit.inc -// connects synchronously to the bhoptimer database -// calls errors if needed -Database GetTimerDatabaseHandle() -{ - Database db = null; - char sError[255]; - - if (SQL_CheckConfig("shavit")) - { - if ((db = SQL_Connect("shavit", true, sError, sizeof(sError))) == null) - { - SetFailState("[OSdb] OSdb plugin startup failed. Reason: %s", sError); - } - } - else - { - db = SQLite_UseDatabase("shavit", sError, sizeof(sError)); - } - - return db; -} - -// retrieves the table prefix defined in configs/shavit-prefix.txt -void GetTimerSQLPrefix(char[] buffer, int maxlen) -{ - char sFile[PLATFORM_MAX_PATH]; - BuildPath(Path_SM, sFile, sizeof(sFile), "configs/shavit-prefix.txt"); - - File fFile = OpenFile(sFile, "r"); - - if (fFile == null) - { - delete fFile; - SetFailState("[OSdb] Cannot open \"configs/shavit-prefix.txt\". Make sure this file exists and that the server has read permissions to it."); - } - - char sLine[PLATFORM_MAX_PATH * 2]; - - if (fFile.ReadLine(sLine, sizeof(sLine))) - { - TrimString(sLine); - strcopy(buffer, maxlen, sLine); - } - - delete fFile; -} - void AddHeaders(HTTPRequest req) { char sPublicIP[32]; From 5d47655f4a91826a5ea7d976c453c47e6b42a7de Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Thu, 8 Jan 2026 17:13:55 -0600 Subject: [PATCH 4/7] Add a quick check for bhoptimer version & bump osdb plugin version --- addons/sourcemod/scripting/offstyledb.sp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index 12e92a3..dd72335 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -15,13 +15,6 @@ #pragma newdecls required #pragma semicolon 1 -native float Shavit_GetWorldRecord(int style, int track); -native bool Shavit_IsPracticeMode(int client); -native bool Shavit_IsPaused(int client); -forward void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name); -forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp); -forward void OnTimerFinished_Post(int client, float Time, int Type, int Style, bool tas, bool NewTime, int OldPosition, int NewPosition); - enum { TimerVersion_Unknown, @@ -85,7 +78,7 @@ public Plugin myinfo = name = "Offstyle Database", author = "shavit (Modified by Jeft & Tommy)", description = "Provides Offstyles with a database of bhop records.", - version = "0.0.4", + version = "0.1.0", url = "" }; @@ -103,6 +96,15 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max public void OnPluginStart() { + if (SHAVIT_VERSION_MAJOR < 4) { + // DebugPrint("[OSdb] bhoptimer version <4 detected, use the v3 version here https://github.com/offstyles/offstyle-plugins/tree/v3"); + SetFailState("[OSdb] bhoptimer version <4 detected, use the v3 version here https://github.com/offstyles/offstyle-plugins/tree/v3"); + } else if (SHAVIT_VERSION_MAJOR >= 5) { + // probably needless but future proofing is nice ig + DebugPrint("[OSdb] bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); + // SetFailState("[OSdb] bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); + } + RegConsoleCmd("osdb_get_all_wrs", Command_SendAllWRs); RegConsoleCmd("osdb_viewmapping", Command_ViewStyleMap); RegConsoleCmd("osdb_batch_status", Command_BatchStatus); From e0ce529564dbac04095a0237fbd68577ffd7899e Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:07:20 -0600 Subject: [PATCH 5/7] Cant use #if defined here but clean it up a bit so its not requiring the shavit include --- addons/sourcemod/scripting/offstyledb.sp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index dd72335..ea75929 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -73,6 +73,21 @@ void DebugPrint(const char[] format, any ...) PrintToServer("[OSdb Debug] %s", buffer); } +int GetShavitMajorVersion() { + char sBuffer[128]; + + Handle hCvar = FindConVar("shavit_version"); + if (h != null) { + GetConVarString(hCvar, sBuffer, sizeof(sBuffer)); + int major = StringToInt(sBuffer[0]); + + return major; + } + + DebugPrint("shavit_version cvar not found (returned null?)"); + return -1; +} + public Plugin myinfo = { name = "Offstyle Database", @@ -96,10 +111,11 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max public void OnPluginStart() { - if (SHAVIT_VERSION_MAJOR < 4) { + int smv = GetShavitMajorVersion(); + if (smv < 4) { // DebugPrint("[OSdb] bhoptimer version <4 detected, use the v3 version here https://github.com/offstyles/offstyle-plugins/tree/v3"); SetFailState("[OSdb] bhoptimer version <4 detected, use the v3 version here https://github.com/offstyles/offstyle-plugins/tree/v3"); - } else if (SHAVIT_VERSION_MAJOR >= 5) { + } else if (smv >= 5) { // probably needless but future proofing is nice ig DebugPrint("[OSdb] bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); // SetFailState("[OSdb] bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); From 8dba867c3d342054efb334b5b121bdfc31f60580 Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:07:39 -0600 Subject: [PATCH 6/7] more the shavit include to the suggested spot --- addons/sourcemod/scripting/offstyledb.sp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index ea75929..adadfd4 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -10,6 +10,9 @@ #define API_BASE_URL "https://offstyles.tommyy.dev/api" #undef REQUIRE_PLUGIN +#include + +#define API_BASE_URL "https://offstyles.tommyy.dev/api" #pragma dynamic 104857600 #pragma newdecls required From b2c8f39056117a3a0fb2155f48de9b6ebc4d2e6d Mon Sep 17 00:00:00 2001 From: Jeft <67933106+Jeftaei@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:08:04 -0600 Subject: [PATCH 7/7] b --- addons/sourcemod/scripting/offstyledb.sp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/addons/sourcemod/scripting/offstyledb.sp b/addons/sourcemod/scripting/offstyledb.sp index adadfd4..c4b6363 100644 --- a/addons/sourcemod/scripting/offstyledb.sp +++ b/addons/sourcemod/scripting/offstyledb.sp @@ -3,11 +3,6 @@ #include #include #include -#include -#include -#include - -#define API_BASE_URL "https://offstyles.tommyy.dev/api" #undef REQUIRE_PLUGIN #include