From 03c0c7f5cdbf1b920c884c5db15b22ef621b4201 Mon Sep 17 00:00:00 2001
From: BotoX <github@botox.bz>
Date: Mon, 23 Sep 2019 14:47:56 +0200
Subject: [PATCH] Add late load to UNLOZE_ForumIntegration and split secret

---
 .../scripting/UNLOZE_ForumIntegration.sp      | 30 +++++++++++++++----
 secrets                                       |  2 +-
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/UNLOZE_ForumIntegration/scripting/UNLOZE_ForumIntegration.sp b/UNLOZE_ForumIntegration/scripting/UNLOZE_ForumIntegration.sp
index 0a84b6ba..62e2cbf2 100644
--- a/UNLOZE_ForumIntegration/scripting/UNLOZE_ForumIntegration.sp
+++ b/UNLOZE_ForumIntegration/scripting/UNLOZE_ForumIntegration.sp
@@ -8,11 +8,10 @@
 #include <sourcemod>
 #include <SteamWorks>
 #include <unloze>
+#include <UNLOZE.secret> //#define UNLOZE_APIKEY here
 
 #pragma newdecls required
 
-#define APIKEY "k9Mk2lA3mF9Sk0FoaD"
-
 /* STRINGS */
 char G_sGroup[MAXPLAYERS+1][64];
 
@@ -29,9 +28,30 @@ public Plugin myinfo =
 	name         = "UNLOZE Forum Integration",
 	author       = ".George & zaCade (Original by Botox)",
 	description  = "Handles forum access ingame",
-	version      = "1.2"
+	version      = "1.2.1"
 };
 
+//----------------------------------------------------------------------------------------------------
+// Purpose: Late load
+//----------------------------------------------------------------------------------------------------
+public void OnPluginStart()
+{
+	/* Late load */
+	for(int client = 1; client <= MaxClients; client++)
+	{
+		if(IsClientConnected(client))
+			OnClientConnected(client);
+
+		if(IsClientAuthorized(client) && !IsFakeClient(client))
+		{
+			char sSteamID32[32];
+			if(GetClientAuthId(client, AuthId_Steam2, sSteamID32, sizeof(sSteamID32)))
+				OnClientAuthorized(client, sSteamID32);
+		}
+	}
+}
+
+
 //----------------------------------------------------------------------------------------------------
 // Purpose:
 //----------------------------------------------------------------------------------------------------
@@ -105,7 +125,7 @@ public void OnClientAuthorized(int client, const char[] sSteamID32)
 	int iSerial = GetClientSerial(client);
 
 	char sRequest[256];
-	FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", APIKEY, sSteamID64);
+	FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", UNLOZE_APIKEY, sSteamID64);
 
 	Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sRequest);
 	if (!hRequest ||
@@ -237,7 +257,7 @@ public int Native_HasSteamIDReservedSlot(Handle plugin, int numParams)
 	SteamID32toSteamID64(sSteamID32, sSteamID64, sizeof(sSteamID64));
 
 	char sRequest[256];
-	FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", APIKEY, sSteamID64);
+	FormatEx(sRequest, sizeof(sRequest), "https://unloze.com/api/private_api.php?api_key=%s&steam_id=%s", UNLOZE_APIKEY, sSteamID64);
 
 	DataPack hDataPack = new DataPack();
 	hDataPack.WriteString(sSteamID32);
diff --git a/secrets b/secrets
index 090534b1..9652845a 160000
--- a/secrets
+++ b/secrets
@@ -1 +1 @@
-Subproject commit 090534b1abe620d7219b965855d758fa09896cea
+Subproject commit 9652845af9651ea14931b71bf6bc74875a210c5b