summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/distbugfix/clientprefs.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/scripting/distbugfix/clientprefs.sp
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/distbugfix/clientprefs.sp')
-rw-r--r--sourcemod/scripting/distbugfix/clientprefs.sp51
1 files changed, 51 insertions, 0 deletions
diff --git a/sourcemod/scripting/distbugfix/clientprefs.sp b/sourcemod/scripting/distbugfix/clientprefs.sp
new file mode 100644
index 0000000..bee4681
--- /dev/null
+++ b/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