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).
28 * @return Pl_Handled to block output, Pl_Stop to block output and action.
30 forward Action:OnClientBanned(admin, client, time, const String:reason[]);
33 * Provided by basecommands.sp when sm_addban or sm_banip is called.
35 * @param admin Admin client index (0 for server).
36 * @param info User info (either steamid or ip).
37 * @param time Minutes banned for (0 is permanent).
38 * @param reason Ban reason (may be empty if none exists).
39 * @return Pl_Handled to block output, Pl_Stop to block output and action.
41 forward Action:OnBanAdded(admin, const String:info[], time, const String:reason[]);
44 * Provided by basecommands.sp when sm_unban or sm_unbanip is called.
46 * @param admin Admin client index (0 for server).
47 * @param info User info (either steamid or ip).
48 * @return Pl_Handled to block output, Pl_Stop to block output and action.
50 forward Action:OnBanRemoved(admin, const String:info[]);
53 * Formats a user's info as log text. This is usually not needed because
54 * %L can be used to auto-format client information into a string.
56 * @param client Client index.
57 * @param buffer Buffer for text.
58 * @param maxlength Maximum length of text.
60 stock FormatUserLogText(client, String:buffer[], maxlength)
65 new userid = GetClientUserId(client);
66 if (!GetClientAuthString(client, auth, sizeof(auth)))
68 StrCopy(auth, sizeof(auth), "UNKNOWN");
70 if (!GetClientName(client, name, sizeof(name)))
72 StrCopy(name, sizeof(name), "UNKNOWN");
75 /** Currently, no team stuff ... */
77 Format(buffer, maxlength, "\"%s<%d><%s><>\"", name, userid, auth);
81 * Returns plugin handle from plugin filename.
83 * @param filename Filename of the plugin to search for.
84 * @return Handle to plugin if found, INVALID_HANDLE otherwise.
86 stock Handle:FindPluginByFile(const String:filename[])
88 decl String:buffer[256];
90 new Handle:iter = GetPluginIterator();
93 while (MorePlugins(iter))
95 pl = ReadPlugin(iter);
97 GetPluginFilename(pl, buffer, sizeof(buffer));
98 if (StrCompare(buffer, filename) == 0)
107 return INVALID_HANDLE;
111 * Searches for clients that match an input string.
114 * 1) #<userid> or #<exact name>
115 * 2) <partial or full name>
117 * @param pattern Pattern to search for.
118 * @param clients Array to store matching clients in.
119 * @param maxClients Maximum clients in the array.
120 * @return Number of clients found.
122 stock SearchForClients(const String:pattern[], clients[], maxClients)
124 new maxclients = GetMaxClients();
132 if (pattern[0] == '#')
134 new input = StringToInt(pattern[1]);
138 for (new i=1; i<=maxclients; i++)
140 if (!IsClientInGame(i))
144 GetClientName(i, name, sizeof(name));
145 if (StrEqual(name, pattern, false))
152 new client = GetClientOfUserId(input);
162 for (new i=1; i<=maxclients; i++)
164 if (!IsClientInGame(i))
168 GetClientName(i, name, sizeof(name));
169 if (StrContains(name, pattern, false) != -1)
171 clients[total++] = i;
172 if (total >= maxClients)