3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is part of the SourceMod/SourcePawn SDK. This file may only be used
8 * or modified under the Terms and Conditions of its License Agreement, which is found
9 * in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins
10 * may change at any time. To view the latest information, see:
11 * http://www.sourcemod.net/license.php
16 #if defined _helpers_included
19 #define _helpers_included
22 * Formats a user's info as log text.
24 * @param client Client index.
25 * @param buffer Buffer for text.
26 * @param maxlength Maximum length of text.
28 stock FormatUserLogText(client, String:buffer[], maxlength)
33 new userid = GetClientUserId(client);
34 if (!GetClientAuthString(client, auth, sizeof(auth)))
36 StrCopy(auth, sizeof(auth), "UNKNOWN");
38 if (!GetClientName(client, name, sizeof(name)))
40 StrCopy(name, sizeof(name), "UNKNOWN");
43 /** Currently, no team stuff ... */
45 Format(buffer, maxlength, "\"%s<%d><%s><>\"", name, userid, auth);
49 * Returns plugin handle from plugin filename.
51 * @param filename Filename of the plugin to search for.
52 * @return Handle to plugin if found, INVALID_HANDLE otherwise.
54 stock Handle:FindPluginByFile(const String:filename[])
56 decl String:buffer[256];
58 new Handle:iter = GetPluginIterator();
61 while (MorePlugins(iter))
63 pl = ReadPlugin(iter);
65 GetPluginFilename(pl, buffer, sizeof(buffer));
66 if (StrCompare(buffer, filename) == 0)
74 return INVALID_HANDLE;
78 * Searches for clients that match an input string.
81 * 1) #<userid> or #<exact name>
82 * 2) <partial or full name>
84 * @param pattern Pattern to search for.
85 * @param clients Array to store matching clients in.
86 * @param maxClients Maximum clients in the array.
87 * @return Number of clients found.
89 stock SearchForClients(const String:pattern[], clients[], maxClients)
91 new maxclients = GetMaxClients();
99 if (pattern[0] == '#')
101 new input = StringToInt(pattern[1]);
105 for (new i=1; i<=maxclients; i++)
107 if (!IsClientInGame(i))
111 GetClientName(i, name, sizeof(name));
112 if (StrEqual(name, pattern, false))
119 new client = GetClientOfUserId(input);
129 for (new i=1; i<=maxclients; i++)
131 if (!IsClientInGame(i))
135 GetClientName(i, name, sizeof(name));
136 if (StrContains(name, pattern, false) != -1)
138 clients[total++] = i;
139 if (total >= maxClients)