blob: bee46813be53a5c78bb3753543109afba963b838 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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);
}
}
|