Skip to content

Commit 4a4b9ce

Browse files
authored
cookies: Align output with sm_help (#977)
* Update clientprefs.sp * Update clientprefs.sp * Update clientprefs.sp * Update clientprefs.sp * Update clientprefs.sp * Update clientprefs.sp * Create natives.sp * Delete natives.sp
1 parent 100f1e5 commit 4a4b9ce

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

plugins/clientprefs.sp

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,19 @@ public Action Command_Cookie(int client, int args)
6767
Handle iter = GetCookieIterator();
6868

6969
char name[30];
70-
name[0] = '\0';
7170
char description[255];
72-
description[0] = '\0';
7371

7472
PrintToConsole(client, "%t:", "Cookie List");
7573

7674
CookieAccess access;
7775

78-
while (ReadCookieIterator(iter,
79-
name,
80-
sizeof(name),
81-
access,
82-
description,
83-
sizeof(description)) != false)
76+
int count = 1;
77+
78+
while (ReadCookieIterator(iter, name, sizeof(name), access, description, sizeof(description)) != false)
8479
{
8580
if (access < CookieAccess_Private)
8681
{
87-
PrintToConsole(client, "%s - %s", name, description);
82+
PrintToConsole(client, "[%03d] %s - %s", count++, name, description);
8883
}
8984
}
9085

@@ -99,7 +94,7 @@ public Action Command_Cookie(int client, int args)
9994
}
10095

10196
char name[30];
102-
name[0] = '\0';
97+
10398
GetCmdArg(1, name, sizeof(name));
10499

105100
Handle cookie = FindClientCookie(name);
@@ -120,17 +115,33 @@ public Action Command_Cookie(int client, int args)
120115
}
121116

122117
char value[100];
123-
value[0] = '\0';
124118

125119
if (args == 1)
126120
{
121+
Handle iter = GetCookieIterator();
122+
127123
GetClientCookie(client, cookie, value, sizeof(value));
128124
ReplyToCommand(client, "[SM] %t", "Cookie Value", name, value);
129125

126+
char CookieName[30];
127+
char description[255];
128+
129+
while (ReadCookieIterator(iter, CookieName, sizeof(CookieName), access, description, sizeof(description)) != false) // We're allowed to re-use access since we're about to return anyways.
130+
{
131+
if (StrEqual(CookieName, name, true))
132+
{
133+
TrimString(description);
134+
if (description[0] != EOS)
135+
ReplyToCommand(client, "- %s", description);
136+
137+
break;
138+
}
139+
}
140+
141+
delete iter;
130142
delete cookie;
131143
return Plugin_Handled;
132144
}
133-
134145
if (access == CookieAccess_Protected)
135146
{
136147
ReplyToCommand(client, "[SM] %t", "Protected Cookie", name);

0 commit comments

Comments
 (0)