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 * Provided by basecommands.sp when sm_ban is called.
24 * @param admin Admin client index (0 for server).
25 * @param client Client index which will be banned.
26 * @param time Minutes banned for (0 is permanent).
27 * @param reason Ban reason (may be empty if none exists).
29 forward OnClientBanned(admin, client, time, const String:reason[]);
32 * Provided by basecommands.sp when sm_addban or sm_banip is called.
34 * @param admin Admin client index (0 for server).
35 * @param info User info (either steamid or ip).
36 * @param time Minutes banned for (0 is permanent).
37 * @param reason Ban reason (may be empty if none exists).
39 forward OnBanAdded(admin, const String:info[], time, const String:reason[]);
42 * Provided by basecommands.sp when sm_unban or sm_unbanip is called.
44 * @param admin Admin client index (0 for server).
45 * @param info User info (either steamid or ip).
47 forward OnBanRemoved(admin, const String:info[]);
50 * Formats a user's info as log text.
52 * @param client Client index.
53 * @param buffer Buffer for text.
54 * @param maxlength Maximum length of text.
56 stock FormatUserLogText(client, String:buffer[], maxlength)
61 new userid = GetClientUserId(client);
62 if (!GetClientAuthString(client, auth, sizeof(auth)))
64 StrCopy(auth, sizeof(auth), "UNKNOWN");
66 if (!GetClientName(client, name, sizeof(name)))
68 StrCopy(name, sizeof(name), "UNKNOWN");
71 /** Currently, no team stuff ... */
73 Format(buffer, maxlength, "\"%s<%d><%s><>\"", name, userid, auth);
77 * Returns plugin handle from plugin filename.
79 * @param filename Filename of the plugin to search for.
80 * @return Handle to plugin if found, INVALID_HANDLE otherwise.
82 stock Handle:FindPluginByFile(const String:filename[])
84 decl String:buffer[256];
86 new Handle:iter = GetPluginIterator();
89 while (MorePlugins(iter))
91 pl = ReadPlugin(iter);
93 GetPluginFilename(pl, buffer, sizeof(buffer));
94 if (StrCompare(buffer, filename) == 0)
102 return INVALID_HANDLE;
106 * Searches for clients that match an input string.
109 * 1) #<userid> or #<exact name>
110 * 2) <partial or full name>
112 * @param pattern Pattern to search for.
113 * @param clients Array to store matching clients in.
114 * @param maxClients Maximum clients in the array.
115 * @return Number of clients found.
117 stock SearchForClients(const String:pattern[], clients[], maxClients)
119 new maxclients = GetMaxClients();
127 if (pattern[0] == '#')
129 new input = StringToInt(pattern[1]);
133 for (new i=1; i<=maxclients; i++)
135 if (!IsClientInGame(i))
139 GetClientName(i, name, sizeof(name));
140 if (StrEqual(name, pattern, false))
147 new client = GetClientOfUserId(input);
157 for (new i=1; i<=maxclients; i++)
159 if (!IsClientInGame(i))
163 GetClientName(i, name, sizeof(name));
164 if (StrContains(name, pattern, false) != -1)
166 clients[total++] = i;
167 if (total >= maxClients)