summaryrefslogtreecommitdiff
path: root/source/sourcemod/scripting/distbugfix/clientprefs.sp
diff options
context:
space:
mode:
authoraura <nw@moneybot.cc>2026-02-17 23:42:09 +0100
committeraura <nw@moneybot.cc>2026-02-17 23:42:09 +0100
commit5e2eb7d67ae933b7566f1944d0bb7744da03d586 (patch)
tree054acff1113270a9cd07933df760f3768c1b6853 /source/sourcemod/scripting/distbugfix/clientprefs.sp
parent341db13a008dc12bb22ceb50452d93d01476308c (diff)
move source stuff to its own folder
Diffstat (limited to 'source/sourcemod/scripting/distbugfix/clientprefs.sp')
-rw-r--r--source/sourcemod/scripting/distbugfix/clientprefs.sp51
1 files changed, 51 insertions, 0 deletions
diff --git a/source/sourcemod/scripting/distbugfix/clientprefs.sp b/source/sourcemod/scripting/distbugfix/clientprefs.sp
new file mode 100644
index 0000000..bee4681
--- /dev/null
+++ b/source/sourcemod/scripting/distbugfix/clientprefs.sp
@@ -0,0 +1,51 @@
+
+
+static Handle distbugCookie;
+static int settings[MAXPLAYERS + 1];
+
+void OnPluginStart_Clientprefs()
+{
+ distbugCookie = RegClientCookie("distbugfix_cookie_v2", "cookie for distbugfix", CookieAccess_Private);
+ if (distbugCookie == INVALID_HANDLE)
+ {
+ SetFailState("Couldn't create distbug cookie.");
+ }
+}
+
+void OnClientCookiesCached_Clientprefs(int client)
+{
+ char buffer[MAX_COOKIE_SIZE];
+ GetClientCookie(client, distbugCookie, buffer, sizeof(buffer));
+
+ settings[client] = StringToInt(buffer);
+}
+
+void SaveClientCookies(int client)
+{
+ if (!GCIsValidClient(client) || !AreClientCookiesCached(client))
+ {
+ return;
+ }
+
+ char buffer[MAX_COOKIE_SIZE];
+ IntToString(settings[client], buffer, sizeof(buffer));
+ SetClientCookie(client, distbugCookie, buffer);
+}
+
+bool IsSettingEnabled(int client, int setting)
+{
+ if (GCIsValidClient(client))
+ {
+ return !!(settings[client] & setting);
+ }
+ return false;
+}
+
+void ToggleSetting(int client, int setting)
+{
+ if (GCIsValidClient(client))
+ {
+ settings[client] ^= setting;
+ SaveClientCookies(client);
+ }
+} \ No newline at end of file