· 8 years ago · Mar 15, 2018, 02:46 AM
1#pragma semicolon 1
2#include <sourcemod>
3#include <sdktools>
4#include <extendedcomm>
5#include <dbi>
6#include <basecomm>
7#undef REQUIRE_PLUGIN
8#include <adminmenu>
9
10#define PLUGIN_VERSION "3.0.8b"
11
12#define PLUGIN_UPDATE 2
13
14#define COMM_TABLE "extendedcomm"
15#define COMM_TABLE_VERSION "extendedcomm_version"
16#define COMM_TABLE_PREVIOUS "extendedcomm"
17
18#define COMM_MUTE 1
19#define COMM_GAG 2
20#define COMM_SILENCE 3
21#define COMM_MUTED 4
22#define COMM_GAGGED 5
23#define COMM_SILENCED 6
24
25#define COMM_MUTE_TIME 1
26#define COMM_MUTE_PERM 2
27#define COMM_GAG_TIME 1
28#define COMM_GAG_PERM 2
29#define COMM_MUTE_TEMP 1
30#define COMM_GAG_TEMP 2
31
32#define MAX_COMM_TIMES 32
33new g_iNumTimes, g_iTimeSeconds[MAX_COMM_TIMES], g_iTimeFlags[MAX_COMM_TIMES];
34new String:g_sTimeDisplays[MAX_COMM_TIMES][64];
35
36#define MAX_COMM_REASONS 32
37new g_iNumReasons, g_iReasonFlags[MAX_COMM_TIMES];
38new String:g_sReasonDisplays[MAX_COMM_REASONS][64], String:g_sReasonReasons[MAX_COMM_REASONS][192];
39
40new String:g_sSQL_VersionPrune[] = { "SELECT last_prune FROM %s" };
41new String:g_sSQL_VersionPruneUpdate[] = { "UPDATE %s SET last_prune = %d" };
42
43new String:g_sSQL_VersionCreate[] = { "CREATE TABLE IF NOT EXISTS %s (primary_key int(4) PRIMARY KEY default 0, current_version varchar(8) NOT NULL default '', current_update int(4) NOT NULL default 0, current_database varchar(32) NOT NULL default '', last_prune int(12) NOT NULL default 0)" };
44new String:g_sSQL_VersionUpdate[] = { "REPLACE INTO %s (current_version, current_update, current_database) VALUES ('%s', %d, '%s')" };
45new String:g_sSQL_VersionSelect[] = { "SELECT current_update, current_database FROM %s" };
46new String:g_sSQL_VersionExisting[] = { "SELECT steam_id FROM %s" };
47
48new String:g_sSQL_CreateTable[] = { "CREATE TABLE IF NOT EXISTS %s (steam_id varchar(32) PRIMARY KEY default '', mute_type int(4) NOT NULL default 0, mute_length int(12) NOT NULL default 0, mute_admin varchar(64) NOT NULL default '', mute_time int(12) NOT NULL default 0, mute_reason varchar(256) NOT NULL default '', mute_level int(12) NOT NULL default 0, gag_type int(4) NOT NULL default 0, gag_length int(12) NOT NULL default 0, gag_admin varchar(64) NOT NULL default '', gag_time int(12) NOT NULL default 0, gag_reason varchar(256) NOT NULL default '', gag_level int(12) NOT NULL default 0)" };
49new String:g_sSQL_PruneSelect[] = { "SELECT steam_id, mute_type, mute_length, mute_time, gag_type, gag_length, gag_time FROM %s" };
50new String:g_sSQL_PruneUpdate[] = { "UPDATE %s SET mute_type = %d, mute_length = %d, mute_time = %d, gag_type = %d, gag_length = %d, gag_time = %d WHERE steam_id = '%s'" };
51new String:g_sSQL_PruneDelete[] = { "DELETE FROM %s WHERE steam_id = '%s'" };
52new String:g_sSQL_SaveClient[] = { "REPLACE INTO %s (steam_id, mute_type, mute_length, mute_time, mute_admin, mute_reason, mute_level, gag_type, gag_length, gag_time, gag_admin, gag_reason, gag_level) VALUES ('%s', %d, %d, %d, '%s', '%s', %d, %d, %d, %d, '%s', '%s', %d)" };
53new String:g_sSQL_LoadClient[] = { "SELECT mute_type, mute_length, mute_time, mute_admin, mute_reason, mute_level, gag_type, gag_length, gag_time, gag_admin, gag_reason, gag_level FROM %s WHERE steam_id = '%s'" };
54new String:g_sSQL_DeleteClient[] = { "DELETE FROM %s WHERE steam_id = '%s'" };
55
56new String:g_sSQL_UpdateTables_3_0_0[4][] = { "ALTER TABLE %s ADD COLUMN mute_reason varchar(128) default ''", "ALTER TABLE %s ADD COLUMN mute_level int(12) default 0", "ALTER TABLE %s ADD COLUMN gag_reason varchar(128) default ''", "ALTER TABLE %s ADD COLUMN gag_level int(12) default 0" };
57new String:g_sSQL_SelectPlayerPre_3_0_0[] = { "SELECT steam_id, mute_type, mute_length, gag_type, gag_length FROM %s" };
58new String:g_sSQL_UpdatePlayerPre_3_0_0[] = { "UPDATE %s SET mute_type = %d, mute_length = %d, gag_type = %d, gag_length = %d WHERE steam_id = '%s'" };
59new String:g_sSQL_PrunePlayerPre_3_0_0[] = { "DELETE FROM %s WHERE steam_id = '%s'" };
60
61new String:g_sSQL_UpdateVersions_3_0_6[] = { "ALTER TABLE %s ADD COLUMN last_prune int(12) NOT NULL default 0" };
62
63new Handle:g_hDatabase = INVALID_HANDLE;
64new Handle:g_hTopMenu = INVALID_HANDLE;
65new Handle:g_hTrie_Temporary = INVALID_HANDLE;
66new Handle:g_hConnection = INVALID_HANDLE;
67new Handle:g_hTemporary = INVALID_HANDLE;
68new Handle:g_hDelayQueries = INVALID_HANDLE;
69new Handle:g_hObeyImmunity = INVALID_HANDLE;
70new Handle:g_hLogActions = INVALID_HANDLE;
71new Handle:g_hLogNotices = INVALID_HANDLE;
72new Handle:g_hTimeFormat = INVALID_HANDLE;
73new Handle:g_hPruneInterval = INVALID_HANDLE;
74
75enum PeskyPanels
76{
77 curTarget,
78 curIndex,
79 viewingMute,
80 viewingGag,
81 viewingList
82}
83
84new AdminId:g_AdminId[MAXPLAYERS + 1];
85new g_Immunity[MAXPLAYERS + 1];
86new bool:g_bCommSave[MAXPLAYERS + 1];
87new bool:g_bTempMuted[MAXPLAYERS + 1];
88new String:g_sTempMuted[MAXPLAYERS + 1][32];
89new bool:g_bTempGagged[MAXPLAYERS + 1];
90new String:g_sTempGagged[MAXPLAYERS + 1][32];
91new String:g_sName[MAXPLAYERS + 1][32];
92new String:g_sSteam[MAXPLAYERS + 1][32];
93new g_iMuteType[MAXPLAYERS + 1];
94new g_iMuteLength[MAXPLAYERS + 1];
95new g_iMuteTime[MAXPLAYERS + 1];
96new g_iMuteLevel[MAXPLAYERS + 1];
97new String:g_sMuteAdmin[MAXPLAYERS + 1][32];
98new String:g_sMuteReason[MAXPLAYERS + 1][256];
99new g_iGagType[MAXPLAYERS + 1];
100new g_iGagLength[MAXPLAYERS + 1];
101new g_iGagTime[MAXPLAYERS + 1];
102new g_iGagLevel[MAXPLAYERS + 1];
103new String:g_sGagAdmin[MAXPLAYERS + 1][32];
104new String:g_sGagReason[MAXPLAYERS + 1][256];
105new Handle:g_hTimer_GagExpire[MAXPLAYERS + 1] = { INVALID_HANDLE, ... };
106new Handle:g_hTimer_MuteExpire[MAXPLAYERS + 1] = { INVALID_HANDLE, ... };
107new g_iPeskyPanels[MAXPLAYERS + 1][PeskyPanels];
108
109new g_iUpdateSteps, g_iPruneInterval;
110new bool:g_bLateLoad, bool:g_bLateQuery, bool:g_bTemporary, bool:g_bLogActions, bool:g_bLogNotices, bool:g_bNullTime, bool:g_bDelayQueries, bool:g_bObeyImmunity;
111new String:g_sLogActions[256], String:g_sLogNotices[256], String:g_sTimeFormat[192], String:g_sConnection[192], String:g_sPrefixConsole[192], String:g_sPrefixChat[192];
112
113public Plugin:myinfo =
114{
115 name = "ExtendedComm",
116 author = "Twisted|Panda",
117 description = "Extends the functionality provided by basecomm.smx, providing extended and permanent punishments, as well as methods to view current punishments.",
118 version = PLUGIN_VERSION,
119 url = "http://ominousgaming.com"
120};
121
122public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
123{
124 CreateNative("ExtendedComm_GetMuteType", Native_GetMuteType);
125 CreateNative("ExtendedComm_GetMuteLength", Native_GetMuteLength);
126 CreateNative("ExtendedComm_GetMuteStart", Native_GetMuteStart);
127 CreateNative("ExtendedComm_GetMuteExpire", Native_GetMuteExpire);
128 CreateNative("ExtendedComm_GetGagType", Native_GetGagType);
129 CreateNative("ExtendedComm_GetGagLength", Native_GetGagLength);
130 CreateNative("ExtendedComm_GetGagStart", Native_GetGagStart);
131 CreateNative("ExtendedComm_GetGagExpire", Native_GetGagExpire);
132 RegPluginLibrary("extendedcomm");
133
134 g_bLateLoad = g_bLateQuery = late;
135 return APLRes_Success;
136}
137
138public OnPluginStart()
139{
140 LoadTranslations("common.phrases");
141 LoadTranslations("extendedcomm.phrases");
142
143 new Handle:_hTemp = INVALID_HANDLE;
144 if(LibraryExists("adminmenu") && ((_hTemp = GetAdminTopMenu()) != INVALID_HANDLE))
145 OnAdminMenuReady(_hTemp);
146
147 CreateConVar("sm_extendedcomm_version", PLUGIN_VERSION, "ExtendedComm: Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
148 g_hConnection = CreateConVar("extendedcomm_database", "", "The database configuration for ExtendedComm. Use \"\" to connect to a local sqlite database.", FCVAR_NONE);
149 HookConVarChange(g_hConnection, OnSettingsChange);
150 g_hTemporary = CreateConVar("extendedcomm_save_temporary", "1", "If enabled, temporary punishments issued by ExtendedComm will remain until the map changes (as opposed to disappearing on reconnecting). (0 = Disabled, 1 = Enabled)", FCVAR_NONE, true, 0.0, true, 1.0);
151 HookConVarChange(g_hTemporary, OnSettingsChange);
152 g_hDelayQueries = CreateConVar("extendedcomm_delay_queries", "1", "If enabled, save queries will be delayed until the client disconnects, otherwise the save queries are executed upon issuing the punishment. (0 = Disabled, 1 = Enabled)", FCVAR_NONE, true, 0.0, true, 1.0);
153 HookConVarChange(g_hDelayQueries, OnSettingsChange);
154 g_hObeyImmunity = CreateConVar("extendedcomm_obey_immunity", "1", "If enabled, an admin's immunity is used when assigning a punishment and admins with lower immunity are inable to modify the existing punishment. (0 = Disabled, 1 = Enabled)", FCVAR_NONE, true, 0.0, true, 1.0);
155 HookConVarChange(g_hObeyImmunity, OnSettingsChange);
156
157 g_hLogActions = CreateConVar("extendedcomm_action_log", "/logs/ExtendedComm.txt", "The path for logging punishments related to ExtendedComm.", FCVAR_NONE);
158 HookConVarChange(g_hLogActions, OnSettingsChange);
159 g_hLogNotices = CreateConVar("extendedcomm_notice_log", "/logs/ExtendedComm.txt", "The path for logging errors related to ExtendedComm.", FCVAR_NONE);
160 HookConVarChange(g_hLogNotices, OnSettingsChange);
161 g_hTimeFormat = CreateConVar("extendedcomm_time_format", "", "Determines the formatting for time and date display. Using \"\" will default to sm_datetime_format (/cfg/sourcemod.cfg)", FCVAR_NONE);
162 HookConVarChange(g_hTimeFormat, OnSettingsChange);
163 g_hPruneInterval = CreateConVar("extendedcomm_prune_interval", "604800", "The number of seconds between each automatic pruning, a feature that removes expired punishments from the database. (0 = Disabled)", FCVAR_NONE, true, 0.0);
164 HookConVarChange(g_hPruneInterval, OnSettingsChange);
165 AutoExecConfig(true, "extendedcomm");
166
167 AddCommandListener(Command_IssueMute, "sm_mute");
168 AddCommandListener(Command_RemoveMute, "sm_unmute");
169 AddCommandListener(Command_IssueGag, "sm_gag");
170 AddCommandListener(Command_RemoveGag, "sm_ungag");
171 AddCommandListener(Command_IssueSilence, "sm_silence");
172 AddCommandListener(Command_RemoveSilence, "sm_unsilence");
173 RegConsoleCmd("sm_mutelist", Command_List, "Extended Comm: Provides functionality for viewing current comm punishments.");
174 RegAdminCmd("sm_commprune", Command_Prune, ADMFLAG_ROOT, "Extended Comm: Provides functionality for automatically pruning the table for expired punishments.");
175 HookEvent("player_changename", Event_OnPlayerName, EventHookMode_Post);
176
177 Void_SetDefaults();
178 Void_LoadTimes();
179 Void_LoadReasons();
180
181 g_iMuteLevel[0] = g_iGagLevel[0] = 2147483647;
182}
183
184public OnLibraryRemoved(const String:name[])
185{
186 if(StrEqual(name, "adminmenu"))
187 g_hTopMenu = INVALID_HANDLE;
188}
189
190public OnAdminMenuReady(Handle:topmenu)
191{
192 if(topmenu == g_hTopMenu)
193 return;
194
195 g_hTopMenu = topmenu;
196 new TopMenuObject:MenuObject = AddToTopMenu(g_hTopMenu, "excomm_cmds", TopMenuObject_Category, Handle_Commands, INVALID_TOPMENUOBJECT);
197 if(MenuObject == INVALID_TOPMENUOBJECT)
198 return;
199
200 AddToTopMenu(g_hTopMenu, "excomm_list", TopMenuObject_Item, Handle_MenuList, MenuObject, "sm_mutelist");
201 AddToTopMenu(g_hTopMenu, "excomm_gag", TopMenuObject_Item, Handle_MenuGag, MenuObject, "sm_gag", ADMFLAG_CHAT);
202 AddToTopMenu(g_hTopMenu, "excomm_ungag", TopMenuObject_Item, Handle_MenuGagged, MenuObject, "sm_ungag", ADMFLAG_CHAT);
203 AddToTopMenu(g_hTopMenu, "excomm_mute", TopMenuObject_Item, Handle_MenuMute, MenuObject, "sm_mute", ADMFLAG_CHAT);
204 AddToTopMenu(g_hTopMenu, "excomm_unmute", TopMenuObject_Item, Handle_MenuMuted, MenuObject, "sm_unmute", ADMFLAG_CHAT);
205 AddToTopMenu(g_hTopMenu, "excomm_silence", TopMenuObject_Item, Handle_MenuSilence, MenuObject, "sm_silence", ADMFLAG_CHAT);
206 AddToTopMenu(g_hTopMenu, "excomm_unsilence", TopMenuObject_Item, Handle_MenuSilenced, MenuObject, "sm_unsilence", ADMFLAG_CHAT);
207}
208
209public OnConfigsExecuted()
210{
211 Format(g_sPrefixChat, sizeof(g_sPrefixChat), "%T", "Prefix_Chat", LANG_SERVER);
212 Format(g_sPrefixConsole, sizeof(g_sPrefixConsole), "%T", "Prefix_Console", LANG_SERVER);
213
214 if(g_hTrie_Temporary == INVALID_HANDLE)
215 g_hTrie_Temporary = CreateTrie();
216 else if(g_bTemporary)
217 ClearTrie(g_hTrie_Temporary);
218
219 if(g_hDatabase == INVALID_HANDLE)
220 SQL_TConnect(SQL_ConnectCall, StrEqual(g_sConnection, "") ? "storage-local" : g_sConnection, _);
221
222 if(g_bLateLoad)
223 {
224 for(new i = 1; i <= MaxClients; i++)
225 {
226 if(IsClientInGame(i))
227 {
228 g_AdminId[i] = GetUserAdmin(i);
229 GetClientAuthString(i, g_sSteam[i], 32);
230 GetClientName(i, g_sName[i], sizeof(g_sName[]));
231 g_Immunity[i] = (g_AdminId[i] == INVALID_ADMIN_ID) ? 0 : GetAdminImmunityLevel(g_AdminId[i]);
232 }
233 }
234
235 g_bLateLoad = false;
236 }
237}
238
239public OnClientConnected(client)
240{
241 if(client > 0 && !IsFakeClient(client))
242 {
243 g_AdminId[client] = INVALID_ADMIN_ID;
244 g_Immunity[client] = g_iMuteType[client] = g_iMuteLength[client] = g_iMuteTime[client] = g_iMuteLevel[client] = g_iGagType[client] = g_iGagLength[client] = g_iGagTime[client] = g_iGagLevel[client] = 0;
245 g_sName[client][0] = g_sSteam[client][0] = g_sMuteAdmin[client][0] = g_sMuteReason[client][0] = g_sGagAdmin[client][0] = g_sGagReason[client][0] = '\0';
246 }
247}
248
249public OnClientPostAdminCheck(client)
250{
251 if(client > 0 && !IsFakeClient(client))
252 {
253 g_AdminId[client] = GetUserAdmin(client);
254 GetClientName(client, g_sName[client], sizeof(g_sName[]));
255 GetClientAuthString(client, g_sSteam[client], sizeof(g_sSteam[]));
256 g_Immunity[client] = (g_AdminId[client] == INVALID_ADMIN_ID) ? 0 : GetAdminImmunityLevel(g_AdminId[client]);
257
258 if(g_bTemporary)
259 {
260 new _iState;
261 if(GetTrieValue(g_hTrie_Temporary, g_sSteam[client], _iState))
262 {
263 if(_iState & COMM_GAG_TEMP)
264 BaseComm_SetClientGag(client, true);
265 if(_iState & COMM_MUTE_TEMP)
266 BaseComm_SetClientMute(client, true);
267 }
268 }
269
270 if(g_hDatabase != INVALID_HANDLE)
271 {
272 decl String:_sQuery[512];
273 Format(_sQuery, sizeof(_sQuery), g_sSQL_LoadClient, COMM_TABLE, g_sSteam[client]);
274 SQL_TQuery(g_hDatabase, SQL_LoadPlayerCall, _sQuery, GetClientUserId(client));
275 }
276 }
277}
278
279public OnClientDisconnect(client)
280{
281 if(client > 0 && !IsFakeClient(client))
282 {
283 if(g_hTimer_MuteExpire[client] != INVALID_HANDLE && CloseHandle(g_hTimer_MuteExpire[client]))
284 g_hTimer_MuteExpire[client] = INVALID_HANDLE;
285
286 if(g_hTimer_GagExpire[client] != INVALID_HANDLE && CloseHandle(g_hTimer_GagExpire[client]))
287 g_hTimer_GagExpire[client] = INVALID_HANDLE;
288
289 if(g_bTemporary)
290 {
291 new _iState;
292 if(g_bTempMuted[client])
293 _iState |= COMM_MUTE_TEMP;
294 if(g_bTempGagged[client])
295 _iState |= COMM_GAG_TEMP;
296
297 if(_iState)
298 SetTrieValue(g_hTrie_Temporary, g_sSteam[client], _iState);
299 }
300
301 g_bTempMuted[client] = g_bTempGagged[client] = false;
302 if(g_bDelayQueries && g_bCommSave[client])
303 {
304 Void_SaveClient(client);
305 g_bCommSave[client] = false;
306 }
307 }
308}
309
310public Action:Event_OnPlayerName(Handle:event, const String:name[], bool:dontBroadcast)
311{
312 new client = GetClientOfUserId(GetEventInt(event, "userid"));
313 if(client > 0 && IsClientInGame(client))
314 GetEventString(event, "newname", g_sName[client], sizeof(g_sName[]));
315}
316
317Void_SaveClient(client)
318{
319 if(g_hDatabase != INVALID_HANDLE)
320 {
321 decl String:_sQuery[512];
322 if(!g_iMuteType[client] && !g_iGagType[client])
323 {
324 Format(_sQuery, sizeof(_sQuery), g_sSQL_DeleteClient, COMM_TABLE, g_sSteam[client]);
325 SQL_TQuery(g_hDatabase, SQL_DeletePlayerCall, _sQuery, GetClientUserId(client));
326 }
327 else
328 {
329 Format(_sQuery, sizeof(_sQuery), g_sSQL_SaveClient, COMM_TABLE, g_sSteam[client], g_iMuteType[client], g_iMuteLength[client], g_iMuteTime[client], g_sMuteAdmin[client], g_sMuteReason[client], g_iMuteLevel[client], g_iGagType[client], g_iGagLength[client], g_iGagTime[client], g_sGagAdmin[client], g_sGagReason[client], g_iGagLevel[client]);
330 SQL_TQuery(g_hDatabase, SQL_SavePlayerCall, _sQuery, GetClientUserId(client));
331 }
332 }
333}
334
335PerformMuteCommand(client, target, length, String:reason[], String:admin[])
336{
337 if(length < 0)
338 {
339 g_bTempMuted[target] = true;
340 strcopy(g_sTempMuted[target], sizeof(g_sTempMuted[]), admin);
341
342 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Issue_Temp", target);
343 LogCommAction(client, target, "%T", "Log_Mute_Issue_Temp", LANG_SERVER, client, target);
344 }
345 else
346 {
347 if(g_bObeyImmunity && g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
348 {
349 if(client)
350 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Mute_Issue_Immunity", target);
351 else
352 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Mute_Issue_Immunity", target);
353
354 return;
355 }
356
357 if(!length)
358 {
359 if(!(g_iMuteType[target] & COMM_MUTE_PERM))
360 g_iMuteType[target] |= COMM_MUTE_PERM;
361
362 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Issue_Perm", target);
363 new String:szFile[256];
364 new String:date[50];
365 new String:time[50];
366 FormatTime(date, 50, "%m/%d/%Y");
367 FormatTime(time, 50, "%H:%M:%S");
368 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
369 new Handle:hFile = OpenFile(szFile, "at");
370 WriteFileLine(hFile, "L %s - %s: %N kiadott egy végleges beszéd tiltást, neki: %N. Ok: %s",date,time,client, target, reason[target]);
371 CloseHandle(hFile);
372 //LogCommAction(client, target, "%T", "Log_Mute_Issue_Perm", LANG_SERVER, client, target,reason[target]);
373 }
374 else
375 {
376 if(!(g_iMuteType[target] & COMM_MUTE_TIME))
377 g_iMuteType[target] |= COMM_MUTE_TIME;
378
379 if(g_hTimer_MuteExpire[target] != INVALID_HANDLE)
380 CloseHandle(g_hTimer_MuteExpire[target]);
381 g_hTimer_MuteExpire[target] = CreateTimer(float(length), Timer_MuteExpire, target, TIMER_FLAG_NO_MAPCHANGE);
382
383 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Issue_Time", target, length / 60);
384 new String:szFile[256];
385 new String:date[50];
386 new String:time[50];
387 FormatTime(date, 50, "%m/%d/%Y");
388 FormatTime(time, 50, "%H:%M:%S");
389 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
390 new Handle:hFile = OpenFile(szFile, "at");
391 WriteFileLine(hFile, "L %s - %s: %N kiadott egy hoszabb beszéd tiltást, neki: %N, %d. Ok: %s",date,time,client, target,length / 60, reason[target]);
392 CloseHandle(hFile);
393 //LogCommAction(client, target, "%T", "Log_Mute_Issue_Time", LANG_SERVER, client, target, length / 60,reason[target] );
394 }
395
396 g_iMuteLength[target] = length;
397 g_iMuteTime[target] = GetTime();
398 strcopy(g_sMuteAdmin[target], sizeof(g_sMuteAdmin[]), admin);
399 SQL_EscapeString(g_hDatabase, reason, g_sMuteReason[target], sizeof(g_sMuteReason[]));
400
401 if(g_bObeyImmunity)
402 g_iMuteLevel[target] = g_Immunity[client];
403
404 if(g_bDelayQueries)
405 g_bCommSave[target] = true;
406 else
407 Void_SaveClient(target);
408 }
409
410 if(!BaseComm_IsClientMuted(target))
411 BaseComm_SetClientMute(target, true);
412}
413
414PerformMutedCommand(client, target, bool:remove)
415{
416 if(g_bTempMuted[target])
417 {
418 g_bTempMuted[target] = false;
419 g_sTempMuted[target][0] = '\0';
420 if(!g_bTempGagged[target])
421 RemoveFromTrie(g_hTrie_Temporary, g_sSteam[target]);
422 else
423 SetTrieValue(g_hTrie_Temporary, g_sSteam[target], COMM_GAG_TEMP);
424
425 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Remove_Temp", target);
426 LogCommAction(client, target, "%T", "Log_Mute_Remove_Temp", LANG_SERVER, client, target);
427 }
428
429 if(remove)
430 {
431 if(g_bObeyImmunity && g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
432 {
433 if(client)
434 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Mute_Remove_Immunity", target);
435 else
436 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Mute_Remove_Immunity", target);
437
438 return;
439 }
440
441 if(g_iMuteType[target] & COMM_MUTE_PERM)
442 {
443 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Remove_Perm", target);
444 LogCommAction(client, target, "%T", "Log_Mute_Remove_Perm", LANG_SERVER, client, target);
445 }
446 else if(g_iMuteType[target] & COMM_MUTE_TIME)
447 {
448 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Mute_Remove_Time", target, g_iMuteLength[target] / 60);
449 LogCommAction(client, target, "%T", "Log_Mute_Remove_Time", LANG_SERVER, client, target, g_iMuteLength[target] / 60);
450 }
451
452 g_iMuteType[target] &= ~COMM_MUTE_PERM;
453 if(g_iMuteType[target] & COMM_MUTE_TIME)
454 {
455 g_iMuteType[target] &= ~COMM_MUTE_TIME;
456 if(g_hTimer_MuteExpire[target] != INVALID_HANDLE && CloseHandle(g_hTimer_MuteExpire[target]))
457 g_hTimer_MuteExpire[target] = INVALID_HANDLE;
458 }
459
460 g_iMuteLength[target] = 0;
461 g_iMuteTime[target] = 0;
462 g_sMuteAdmin[target][0] = '\0';
463 g_sMuteReason[target][0] = '\0';
464 g_iMuteLevel[target] = 0;
465
466 if(g_bDelayQueries)
467 g_bCommSave[target] = true;
468 else
469 Void_SaveClient(target);
470 }
471
472 if(!g_iMuteType[target] && BaseComm_IsClientMuted(target))
473 BaseComm_SetClientMute(target, false);
474}
475
476PerformGagCommand(client, target, length, String:reason[], String:admin[])
477{
478 if(length < 0)
479 {
480 g_bTempGagged[target] = true;
481 strcopy(g_sTempGagged[target], sizeof(g_sTempGagged[]), admin);
482
483 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Issue_Temp", target);
484 LogCommAction(client, target, "%T", "Log_Gag_Issue_Temp", LANG_SERVER, client, target);
485 }
486 else
487 {
488 if(g_bObeyImmunity && g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target])
489 {
490 if(client)
491 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Gag_Issue_Immunity", target);
492 else
493 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Gag_Issue_Immunity", target);
494
495 return;
496 }
497
498 if(!length)
499 {
500 if(!(g_iGagType[target] & COMM_GAG_PERM))
501 g_iGagType[target] |= COMM_GAG_PERM;
502
503 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Issue_Perm", target);
504 new String:szFile[256];
505 new String:date[50];
506 new String:time[50];
507 FormatTime(date, 50, "%m/%d/%Y");
508 FormatTime(time, 50, "%H:%M:%S");
509 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
510 new Handle:hFile = OpenFile(szFile, "at");
511 WriteFileLine(hFile, "L %s - %s: %N kiadott egy végleges Ãrás tiltást %N. Ok: %s",date,time,client, target, reason[target]);
512 CloseHandle(hFile);
513 //LogCommAction(client, target, "%T", "Log_Gag_Issue_Perm", LANG_SERVER, client, target,reason[target]);
514 }
515 else
516 {
517 if(!(g_iGagType[target] & COMM_GAG_TIME))
518 g_iGagType[target] |= COMM_GAG_TIME;
519
520 if(g_hTimer_GagExpire[target] != INVALID_HANDLE)
521 CloseHandle(g_hTimer_GagExpire[target]);
522 g_hTimer_GagExpire[target] = CreateTimer(float(length), Timer_GagExpire, target, TIMER_FLAG_NO_MAPCHANGE);
523
524 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Issue_Time", target, length / 60);
525 new String:szFile[256];
526 new String:date[50];
527 new String:time[50];
528 FormatTime(date, 50, "%m/%d/%Y");
529 FormatTime(time, 50, "%H:%M:%S");
530 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
531 new Handle:hFile = OpenFile(szFile, "at");
532 WriteFileLine(hFile, "L %s - %s: %N kiadott egy hosszabb Ãrás tiltást, neki: %N, %d percre. Ok: %s",date,time,client, target, length / 60,reason[target]);
533 CloseHandle(hFile);
534 //LogCommAction(client, target, "%T", "Log_Gag_Issue_Time", LANG_SERVER, client, target, length / 60,reason[target] );
535 }
536
537 g_iGagLength[target] = length;
538 g_iGagTime[target] = GetTime();
539 strcopy(g_sGagAdmin[target], sizeof(g_sGagAdmin[]), admin);
540 SQL_EscapeString(g_hDatabase, reason, g_sGagReason[target], sizeof(g_sGagReason[]));
541 if(g_bObeyImmunity)
542 g_iGagLevel[target] = g_Immunity[client];
543
544 if(g_bDelayQueries)
545 g_bCommSave[target] = true;
546 else
547 Void_SaveClient(target);
548 }
549
550 if(!BaseComm_IsClientGagged(target))
551 BaseComm_SetClientGag(target, true);
552}
553
554PerformGaggedCommand(client, target, bool:remove)
555{
556 if(g_bTempGagged[target])
557 {
558 g_bTempGagged[target] = false;
559 g_sTempGagged[target][0] = '\0';
560 if(!g_bTempMuted[target])
561 RemoveFromTrie(g_hTrie_Temporary, g_sSteam[target]);
562 else
563 SetTrieValue(g_hTrie_Temporary, g_sSteam[target], COMM_MUTE_TEMP);
564
565 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Remove_Temp", target);
566 LogCommAction(client, target, "%T", "Log_Gag_Remove_Temp", LANG_SERVER, client, target);
567 }
568
569 if(remove)
570 {
571 if(g_bObeyImmunity && g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target])
572 {
573 if(client)
574 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Gag_Remove_Immunity", target);
575 else
576 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Gag_Remove_Immunity", target);
577
578 return;
579 }
580
581 if(g_iGagType[target] & COMM_GAG_PERM)
582 {
583 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Remove_Perm", target);
584 LogCommAction(client, target, "%T", "Log_Gag_Remove_Perm", LANG_SERVER, client, target);
585 }
586 else if(g_iGagType[target] & COMM_GAG_TIME)
587 {
588 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Gag_Remove_Time", target, g_iGagLength[target] / 60);
589 LogCommAction(client, target, "%T", "Log_Gag_Remove_Time", LANG_SERVER, client, target, g_iGagLength[target] / 60);
590 }
591
592 g_iGagType[target] &= ~COMM_GAG_PERM;
593 if(g_iGagType[target] & COMM_GAG_TIME)
594 {
595 g_iGagType[target] &= ~COMM_GAG_TIME;
596 if(g_hTimer_GagExpire[target] != INVALID_HANDLE && CloseHandle(g_hTimer_GagExpire[target]))
597 g_hTimer_GagExpire[target] = INVALID_HANDLE;
598 }
599
600 g_iGagLength[target] = 0;
601 g_iGagTime[target] = 0;
602 g_sGagAdmin[target][0] = '\0';
603 g_sGagReason[target][0] = '\0';
604 g_iGagLevel[target] = 0;
605
606 if(g_bDelayQueries)
607 g_bCommSave[target] = true;
608 else
609 Void_SaveClient(target);
610 }
611
612 if(!g_iGagType[target] && BaseComm_IsClientGagged(target))
613 BaseComm_SetClientGag(target, false);
614}
615
616PerformSilenceCommand(client, target, length, String:reason[], String:admin[])
617{
618 new _iReturn;
619 if(length < 0)
620 {
621 g_bTempMuted[target] = true;
622 g_bTempGagged[target] = true;
623 strcopy(g_sTempMuted[target], sizeof(g_sTempMuted[]), admin);
624 strcopy(g_sTempGagged[target], sizeof(g_sTempGagged[]), admin);
625
626 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Issue_Temp", target);
627 LogCommAction(client, target, "%T", "Log_Silence_Issue_Temp", LANG_SERVER, client, target);
628 }
629 else
630 {
631 if(g_bObeyImmunity)
632 {
633 if(g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target] && g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
634 {
635 _iReturn += (COMM_GAG_TEMP + COMM_MUTE_TEMP);
636 if(client)
637 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Issue_Immunity", target);
638 else
639 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Issue_Immunity", target);
640 }
641 else
642 {
643 if(g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target])
644 {
645 _iReturn |= COMM_GAG_TEMP;
646 if(client)
647 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Issue_Immunity_Gag", target);
648 else
649 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Issue_Immunity_Gag", target,reason[target]);
650 }
651
652 if(g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
653 {
654 _iReturn |= COMM_MUTE_TEMP;
655 if(client)
656 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Issue_Immunity_Mute", target);
657 else
658 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Issue_Immunity_Mute", target);
659 }
660 }
661
662 if((_iReturn & COMM_GAG_TEMP) && (_iReturn & COMM_MUTE_TEMP))
663 return;
664 }
665
666 if(!length)
667 {
668 if(!g_bObeyImmunity || !(_iReturn & COMM_MUTE_TEMP))
669 if(!(g_iMuteType[target] & COMM_MUTE_PERM))
670 g_iMuteType[target] |= COMM_MUTE_PERM;
671
672 if(!g_bObeyImmunity || !(_iReturn & COMM_GAG_TEMP))
673 if(!(g_iGagType[target] & COMM_GAG_PERM))
674 g_iGagType[target] |= COMM_GAG_PERM;
675
676 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Issue_Perm", target);
677 new String:szFile[256];
678 new String:date[50];
679 new String:time[50];
680 FormatTime(date, 50, "%m/%d/%Y");
681 FormatTime(time, 50, "%H:%M:%S");
682 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
683 new Handle:hFile = OpenFile(szFile, "at");
684 WriteFileLine(hFile, "L %s - %s: %N kiadott egy végleges beszéd/Ãrás tiltást %N. Ok: %s",date,time,client, target, reason[target]);
685 CloseHandle(hFile);
686 //LogCommAction(client, target, "%T", "Log_Silence_Issue_Perm", LANG_SERVER, client, target,reason[target]);
687 }
688 else
689 {
690 if(!g_bObeyImmunity || !(_iReturn & COMM_MUTE_TEMP))
691 {
692 if(!(g_iMuteType[target] & COMM_MUTE_TIME))
693 g_iMuteType[target] |= COMM_MUTE_TIME;
694 if(g_hTimer_MuteExpire[target] != INVALID_HANDLE)
695 CloseHandle(g_hTimer_MuteExpire[target]);
696 g_hTimer_MuteExpire[target] = CreateTimer(float(length), Timer_MuteExpire, target, TIMER_FLAG_NO_MAPCHANGE);
697 }
698
699 if(!g_bObeyImmunity || !(_iReturn & COMM_GAG_TEMP))
700 {
701 if(!(g_iGagType[target] & COMM_GAG_TIME))
702 g_iGagType[target] |= COMM_GAG_TIME;
703 if(g_hTimer_GagExpire[target] != INVALID_HANDLE)
704 CloseHandle(g_hTimer_GagExpire[target]);
705 g_hTimer_GagExpire[target] = CreateTimer(float(length), Timer_GagExpire, target, TIMER_FLAG_NO_MAPCHANGE);
706 }
707
708 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Issue_Time", target, length / 60);
709 new String:szFile[256];
710 new String:date[50];
711 new String:time[50];
712 FormatTime(date, 50, "%m/%d/%Y");
713 FormatTime(time, 50, "%H:%M:%S");
714 BuildPath(Path_SM, szFile, sizeof(szFile), "logs/ExtendedComm.txt");
715 new Handle:hFile = OpenFile(szFile, "at");
716 WriteFileLine(hFile, "L %s - %s: %N kiadott egy hoszabb beszéd/Ãrás tiltást, neki: %N, %d. Ok: %s",date,time,client, target,length / 60, reason[target]);
717 CloseHandle(hFile);
718 //LogCommAction(client, target, "%T", "Log_Silence_Issue_Time", LANG_SERVER, client, target, length / 60,reason[target]);
719 }
720
721 if(!g_bObeyImmunity || !(_iReturn & COMM_GAG_TEMP))
722 {
723 g_iGagLength[target] = length;
724 g_iGagTime[target] = GetTime();
725 strcopy(g_sGagAdmin[target], sizeof(g_sGagAdmin[]), admin);
726 SQL_EscapeString(g_hDatabase, reason, g_sGagReason[target], sizeof(g_sGagReason[]));
727 if(g_bObeyImmunity)
728 g_iGagLevel[target] = g_Immunity[client];
729 }
730
731 if(!g_bObeyImmunity || !(_iReturn & COMM_MUTE_TEMP))
732 {
733 g_iMuteLength[target] = length;
734 g_iMuteTime[target] = GetTime();
735 strcopy(g_sMuteAdmin[target], sizeof(g_sMuteAdmin[]), admin);
736 SQL_EscapeString(g_hDatabase, reason, g_sMuteReason[target], sizeof(g_sMuteReason[]));
737 if(g_bObeyImmunity)
738 g_iMuteLevel[target] = g_Immunity[client];
739 }
740
741 if(g_bDelayQueries)
742 g_bCommSave[target] = true;
743 else
744 Void_SaveClient(target);
745 }
746
747 if((!_iReturn || !(_iReturn & COMM_MUTE_TEMP)) && !BaseComm_IsClientMuted(target))
748 BaseComm_SetClientMute(target, true);
749
750 if((!_iReturn || !(_iReturn & COMM_GAG_TEMP)) && !BaseComm_IsClientGagged(target))
751 BaseComm_SetClientGag(target, true);
752}
753
754PerformSilencedCommand(client, target, bool:remove)
755{
756 if(g_bTempMuted[target] || g_bTempGagged[target])
757 {
758 g_bTempMuted[target] = false;
759 g_bTempGagged[target] = false;
760 g_sTempMuted[target][0] = '\0';
761 g_sTempGagged[target][0] = '\0';
762
763 RemoveFromTrie(g_hTrie_Temporary, g_sSteam[target]);
764 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Remove_Temp", target);
765 LogCommAction(client, target, "%T", "Log_Silence_Remove_Temp", LANG_SERVER, client, target);
766 }
767
768 if(remove)
769 {
770 if(g_bObeyImmunity)
771 {
772 new _iReturn;
773 if(g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target] && g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
774 {
775 _iReturn += (COMM_GAG_TEMP + COMM_MUTE_TEMP);
776 if(client)
777 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Remove_Immunity", target);
778 else
779 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Remove_Immunity", target);
780 }
781 else
782 {
783 if(g_iGagType[target] && g_Immunity[client] < g_iGagLevel[target])
784 {
785 _iReturn |= COMM_GAG_TEMP;
786 if(client)
787 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Remove_Immunity_Gag", target);
788 else
789 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Remove_Immunity_Gag", target);
790 }
791
792 if(g_iMuteType[target] && g_Immunity[client] < g_iMuteLevel[target])
793 {
794 _iReturn |= COMM_MUTE_TEMP;
795 if(client)
796 PrintToChat(client, "%s%t", g_sPrefixChat, "Command_Silence_Remove_Immunity_Mute", target);
797 else
798 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Silence_Remove_Immunity_Mute", target);
799 }
800 }
801
802 if((_iReturn & COMM_GAG_TEMP) && (_iReturn & COMM_MUTE_TEMP))
803 return;
804 }
805
806 if(g_iGagType[target] & COMM_GAG_PERM && g_iMuteType[target] & COMM_MUTE_PERM)
807 {
808 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Remove_Perm", target);
809 LogCommAction(client, target, "%T", "Log_Silence_Remove_Perm", LANG_SERVER, client, target);
810 }
811 else if(g_iMuteType[target] & COMM_MUTE_TIME && g_iGagType[target] & COMM_GAG_TIME)
812 {
813 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Remove_Time", target);
814 LogCommAction(client, target, "%T", "Log_Silence_Remove_Time", LANG_SERVER, client, target);
815 }
816 else
817 {
818 ShowActivity2(client, g_sPrefixChat, "%t", "Show_Activity_Silence_Remove_Misc", target);
819 LogCommAction(client, target, "%T", "Log_Silence_Remove_Misc", LANG_SERVER, client, target);
820 }
821
822 g_iMuteType[target] &= ~COMM_MUTE_PERM;
823 if(g_iMuteType[target] & COMM_MUTE_TIME)
824 {
825 g_iMuteType[target] &= ~COMM_MUTE_TIME;
826 if(g_hTimer_MuteExpire[target] != INVALID_HANDLE && CloseHandle(g_hTimer_MuteExpire[target]))
827 g_hTimer_MuteExpire[target] = INVALID_HANDLE;
828 }
829
830 g_iGagType[target] &= ~COMM_GAG_PERM;
831 if(g_iGagType[target] & COMM_GAG_TIME)
832 {
833 g_iGagType[target] &= ~COMM_GAG_TIME;
834 if(g_hTimer_GagExpire[target] != INVALID_HANDLE && CloseHandle(g_hTimer_GagExpire[target]))
835 g_hTimer_GagExpire[target] = INVALID_HANDLE;
836 }
837
838 g_iGagLength[target] = g_iMuteLength[target] = 0;
839 g_iGagTime[target] = g_iMuteTime[target] = 0;
840 g_sMuteAdmin[target][0] = g_sGagAdmin[target][0] = '\0';
841 g_sMuteReason[target][0] = g_sGagReason[target][0] = '\0';
842 g_iMuteLevel[target] = g_iGagLevel[target] = 0;
843
844 if(g_bDelayQueries)
845 g_bCommSave[target] = true;
846 else
847 Void_SaveClient(target);
848 }
849
850 if(!g_iGagType[target] && BaseComm_IsClientGagged(target))
851 BaseComm_SetClientGag(target, false);
852 if(!g_iMuteType[target] && BaseComm_IsClientMuted(target))
853 BaseComm_SetClientMute(target, false);
854}
855
856public Action:Command_IssueMute(client, const String:command[], args)
857{
858 if(client && !CheckCommandAccess(client, "sm_mute", ADMFLAG_CHAT))
859 return Plugin_Continue;
860
861 decl String:_sTemp[192], String:_sReason[192];
862 if(args < 1)
863 {
864 Format(_sTemp, sizeof(_sTemp), "%T", "Command_Issue_Mute_Usage", client);
865
866 ReplyToCommand(client, _sTemp);
867 return Plugin_Stop;
868 }
869
870 new bool:_bAccess, _iLength = -1;
871 GetCmdArg(1, _sTemp, sizeof(_sTemp));
872 if(g_iNumTimes && args > 1 && g_hDatabase != INVALID_HANDLE)
873 {
874 decl String:_sTime[64];
875 GetCmdArg(2, _sTime, sizeof(_sTime));
876
877 _iLength = StringToInt(_sTime);
878 if(_iLength < 0)
879 _iLength = -1;
880 else
881 {
882 new _iLast, _iFlag = client ? GetUserFlagBits(client) : 0;
883 for(new i = g_iNumTimes; i >= 0; i--)
884 {
885 if((_iLength <= 0 && _iLength == g_iTimeSeconds[i]) || (g_iTimeSeconds[i] > 0 && _iLength <= g_iTimeSeconds[i]))
886 {
887 if(!g_iTimeFlags[i] || _iFlag & g_iTimeFlags[i])
888 {
889 _bAccess = true;
890 break;
891 }
892 }
893 else
894 _iLast = i;
895 }
896
897 if(!_bAccess)
898 {
899 decl String:_sBuffer[192];
900 if(!_iLength)
901 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Mute_Permission_Perm", client);
902 else
903 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Mute_Permission_Time", client, g_iTimeSeconds[_iLast]);
904
905 ReplyToCommand(client, _sBuffer);
906 return Plugin_Stop;
907 }
908 }
909
910 if(args >= 3)
911 GetCmdArg(3, _sReason, sizeof(_sReason));
912 else
913 _sReason[0] = '\0';
914 }
915 else
916 _sReason[0] = '\0';
917
918 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
919 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, sizeof(_iTargets), COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
920 return Plugin_Continue;
921
922 GetIssuerName(client, _sTemp, sizeof(_sTemp));
923 for (new i = 0; i < _iCount; i++)
924 if(IsClientInGame(_iTargets[i]) && CanUserTarget(client, _iTargets[i]))
925 PerformMuteCommand(client, _iTargets[i], _iLength * 60, _sReason, _sTemp);
926
927 return Plugin_Stop;
928}
929
930public Action:Command_IssueGag(client, const String:command[], args)
931{
932 if(client && !CheckCommandAccess(client, "sm_gag", ADMFLAG_CHAT))
933 return Plugin_Continue;
934
935 decl String:_sTemp[192], String:_sReason[192];
936 if(args < 1)
937 {
938 Format(_sTemp, sizeof(_sTemp), "%s%T", g_sPrefixConsole, "Command_Issue_Gag_Usage", client);
939
940 ReplyToCommand(client, _sTemp);
941 return Plugin_Stop;
942 }
943
944 new bool:_bAccess, _iLength = -1;
945 GetCmdArg(1, _sTemp, sizeof(_sTemp));
946 if(g_iNumTimes && args > 1 && g_hDatabase != INVALID_HANDLE)
947 {
948 decl String:_sTime[64];
949 GetCmdArg(2, _sTime, sizeof(_sTime));
950
951 _iLength = StringToInt(_sTime);
952 if(_iLength < 0)
953 _iLength = -1;
954 else
955 {
956 new _iLast, _iFlag = client ? GetUserFlagBits(client) : 0;
957 for(new i = g_iNumTimes; i >= 0; i--)
958 {
959 if((_iLength <= 0 && _iLength == g_iTimeSeconds[i]) || (g_iTimeSeconds[i] > 0 && _iLength <= g_iTimeSeconds[i]))
960 {
961 if(!g_iTimeFlags[i] || _iFlag & g_iTimeFlags[i])
962 {
963 _bAccess = true;
964 break;
965 }
966 }
967 else
968 _iLast = i;
969 }
970
971 if(!_bAccess)
972 {
973 decl String:_sBuffer[192];
974 if(!_iLength)
975 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Gag_Permission_Perm", client);
976 else
977 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Gag_Permission_Time", client, g_iTimeSeconds[_iLast]);
978
979 ReplyToCommand(client, _sBuffer);
980 return Plugin_Stop;
981 }
982 }
983
984 if(args >= 3)
985 GetCmdArg(3, _sReason, sizeof(_sReason));
986 else
987 _sReason[0] = '\0';
988 }
989 else
990 _sReason[0] = '\0';
991
992 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
993 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, sizeof(_iTargets), COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
994 return Plugin_Continue;
995
996 GetIssuerName(client, _sTemp, sizeof(_sTemp));
997 for (new i = 0; i < _iCount; i++)
998 if(IsClientInGame(_iTargets[i]) && CanUserTarget(client, _iTargets[i]))
999 PerformGagCommand(client, _iTargets[i], _iLength * 60, _sReason, _sTemp);
1000
1001 return Plugin_Stop;
1002}
1003
1004
1005public Action:Command_IssueSilence(client, const String:command[], args)
1006{
1007 if(client && !CheckCommandAccess(client, "sm_silence", ADMFLAG_CHAT))
1008 return Plugin_Continue;
1009
1010 decl String:_sTemp[192], String:_sReason[192];
1011 if(args < 1)
1012 {
1013 Format(_sTemp, sizeof(_sTemp), "%s%T", g_sPrefixConsole, "Command_Issue_Silence_Usage", client);
1014
1015 ReplyToCommand(client, _sTemp);
1016 return Plugin_Stop;
1017 }
1018
1019 new bool:_bAccess, _iLength = -1;
1020 GetCmdArg(1, _sTemp, sizeof(_sTemp));
1021 if(g_iNumTimes && args > 1 && g_hDatabase != INVALID_HANDLE)
1022 {
1023 decl String:_sTime[64];
1024 GetCmdArg(2, _sTime, sizeof(_sTime));
1025
1026 _iLength = StringToInt(_sTime);
1027 if(_iLength < 0)
1028 _iLength = -1;
1029 else
1030 {
1031 new _iLast, _iFlag = client ? GetUserFlagBits(client) : 0;
1032 for(new i = g_iNumTimes; i >= 0; i--)
1033 {
1034 if((_iLength <= 0 && _iLength == g_iTimeSeconds[i]) || (g_iTimeSeconds[i] > 0 && _iLength <= g_iTimeSeconds[i]))
1035 {
1036 if(!g_iTimeFlags[i] || _iFlag & g_iTimeFlags[i])
1037 {
1038 _bAccess = true;
1039 break;
1040 }
1041 }
1042 else
1043 _iLast = i;
1044 }
1045
1046 if(!_bAccess)
1047 {
1048 decl String:_sBuffer[192];
1049 if(!_iLength)
1050 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Silence_Permission_Perm", client);
1051 else
1052 Format(_sBuffer, sizeof(_sBuffer), "%s%T", g_sPrefixConsole, "Command_Issue_Silence_Permission_Time", client, g_iTimeSeconds[_iLast]);
1053
1054 ReplyToCommand(client, _sBuffer);
1055 return Plugin_Stop;
1056 }
1057 }
1058
1059 if(args >= 3)
1060 GetCmdArg(3, _sReason, sizeof(_sReason));
1061 else
1062 _sReason[0] = '\0';
1063 }
1064 else
1065 _sReason[0] = '\0';
1066
1067 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
1068 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, sizeof(_iTargets), COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
1069 return Plugin_Continue;
1070
1071 GetIssuerName(client, _sTemp, sizeof(_sTemp));
1072 for (new i = 0; i < _iCount; i++)
1073 if(IsClientInGame(_iTargets[i]) && CanUserTarget(client, _iTargets[i]))
1074 PerformSilenceCommand(client, _iTargets[i], _iLength * 60, _sReason, _sTemp);
1075
1076 return Plugin_Stop;
1077}
1078
1079public Action:Command_RemoveMute(client, const String:command[], args)
1080{
1081 if(client && !CheckCommandAccess(client, "sm_unmute", ADMFLAG_CHAT))
1082 return Plugin_Continue;
1083
1084 decl String:_sTemp[192], String:_sRemove[64];
1085 if(args < 1)
1086 {
1087 Format(_sTemp, sizeof(_sTemp), "%T", "Command_Remove_Mute_Usage", client);
1088
1089 ReplyToCommand(client, _sTemp);
1090 return Plugin_Stop;
1091 }
1092
1093 new bool:_bRemove;
1094 GetCmdArg(1, _sTemp, sizeof(_sTemp));
1095 if(args >= 2 && g_hDatabase != INVALID_HANDLE)
1096 {
1097 GetCmdArg(2, _sRemove, sizeof(_sRemove));
1098 _bRemove = StringToInt(_sRemove) ? true : false;
1099 }
1100 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
1101 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
1102 return Plugin_Continue;
1103
1104 for (new i = 0; i < _iCount; i++)
1105 if(IsClientInGame(_iTargets[i]))
1106 PerformMutedCommand(client, _iTargets[i], _bRemove);
1107
1108 return Plugin_Stop;
1109}
1110
1111public Action:Command_RemoveGag(client, const String:command[], args)
1112{
1113 if(client && !CheckCommandAccess(client, "sm_ungag", ADMFLAG_CHAT))
1114 return Plugin_Continue;
1115
1116 decl String:_sTemp[192], String:_sRemove[64];
1117 if(args < 1)
1118 {
1119 Format(_sTemp, sizeof(_sTemp), "%T", "Command_Remove_Gag_Usage", client);
1120
1121 ReplyToCommand(client, _sTemp);
1122 return Plugin_Stop;
1123 }
1124
1125 new bool:_bRemove;
1126 GetCmdArg(1, _sTemp, sizeof(_sTemp));
1127 if(args >= 2 && g_hDatabase != INVALID_HANDLE)
1128 {
1129 GetCmdArg(2, _sRemove, sizeof(_sRemove));
1130 _bRemove = StringToInt(_sRemove) ? true : false;
1131 }
1132 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
1133 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
1134 return Plugin_Continue;
1135
1136 for (new i = 0; i < _iCount; i++)
1137 if(IsClientInGame(_iTargets[i]))
1138 PerformGaggedCommand(client, _iTargets[i], _bRemove);
1139
1140 return Plugin_Stop;
1141}
1142
1143public Action:Command_RemoveSilence(client, const String:command[], args)
1144{
1145 if(client && !CheckCommandAccess(client, "sm_unsilence", ADMFLAG_CHAT))
1146 return Plugin_Continue;
1147
1148 decl String:_sTemp[192], String:_sRemove[64];
1149 if(args < 1)
1150 {
1151 Format(_sTemp, sizeof(_sTemp), "%T", "Command_Remove_Silence_Usage", client);
1152
1153 ReplyToCommand(client, _sTemp);
1154 return Plugin_Stop;
1155 }
1156
1157 new bool:_bRemove;
1158 GetCmdArg(1, _sTemp, sizeof(_sTemp));
1159 if(args >= 2 && g_hDatabase != INVALID_HANDLE)
1160 {
1161 GetCmdArg(2, _sRemove, sizeof(_sRemove));
1162 _bRemove = StringToInt(_sRemove) ? true : false;
1163 }
1164 decl String:_sName[MAX_TARGET_LENGTH], _iTargets[MAXPLAYERS], _iCount, bool:_bTemp;
1165 if((_iCount = ProcessTargetString(_sTemp, client, _iTargets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED, _sName, sizeof(_sName), _bTemp)) <= COMMAND_TARGET_NONE)
1166 return Plugin_Continue;
1167
1168 for (new i = 0; i < _iCount; i++)
1169 if(IsClientInGame(_iTargets[i]))
1170 PerformSilencedCommand(client, _iTargets[i], _bRemove);
1171
1172 return Plugin_Stop;
1173}
1174
1175public Action:Command_List(client, args)
1176{
1177 if(g_hDatabase == INVALID_HANDLE)
1178 {
1179 if(client)
1180 PrintToChat(client, "%s%t", g_sPrefixConsole, "Command_Database_Invalid");
1181 else
1182 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Database_Invalid");
1183 }
1184 else
1185 {
1186 if(!client)
1187 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_List_Game_Only");
1188 else
1189 {
1190 g_iPeskyPanels[client][viewingList] = true;
1191 AdminMenu_List(client, 0);
1192 }
1193 }
1194
1195 return Plugin_Handled;
1196}
1197
1198public Action:Command_Prune(client, args)
1199{
1200 if(g_hDatabase == INVALID_HANDLE)
1201 {
1202 if(client)
1203 PrintToChat(client, "%s%t", g_sPrefixConsole, "Command_Database_Invalid");
1204 else
1205 ReplyToCommand(client, "%s%t", g_sPrefixConsole, "Command_Database_Invalid");
1206 }
1207 else
1208 {
1209 decl String:_sQuery[512];
1210 Format(_sQuery, sizeof(_sQuery), g_sSQL_PruneSelect, COMM_TABLE);
1211 SQL_TQuery(g_hDatabase, SQL_AutoPrune, _sQuery, client ? GetClientUserId(client) : client);
1212 }
1213
1214 return Plugin_Handled;
1215}
1216
1217public SQL_ConnectCall(Handle:owner, Handle:hndl, const String:error[], any:data)
1218{
1219 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1220 {
1221 LogCommError("Error: ExtendedComm was unable to establish a database connection!");
1222 decl String:_sError[512];
1223 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1224 LogCommError("- SQL_ConnectCall: %s", _sError);
1225 else
1226 LogCommError("- SQL_ConnectCall: %s", error);
1227 }
1228 else
1229 {
1230 decl String:_sQuery[1024];
1231 SQL_LockDatabase(hndl);
1232 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionCreate, COMM_TABLE_VERSION);
1233 if(!SQL_FastQuery(hndl, _sQuery))
1234 {
1235 LogCommError("Error: The query \"g_sSQL_VersionCreate\" could not be executed!");
1236 decl String:_sError[512];
1237 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1238 LogCommError("- SQL_ConnectCall: %s", _sError);
1239 CloseHandle(hndl);
1240 return;
1241 }
1242
1243 Format(_sQuery, sizeof(_sQuery), g_sSQL_CreateTable, COMM_TABLE);
1244 if(!SQL_FastQuery(hndl, _sQuery))
1245 {
1246 LogCommError("Error: The query \"g_sSQL_CreateTable\" could not be executed!");
1247 decl String:_sError[512];
1248 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1249 LogCommError("- SQL_ConnectCall: %s", _sError);
1250
1251 CloseHandle(hndl);
1252 return;
1253 }
1254 SQL_UnlockDatabase(hndl);
1255 g_hDatabase = hndl;
1256
1257 g_iUpdateSteps = 0;
1258 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionSelect, COMM_TABLE_VERSION);
1259 SQL_TQuery(g_hDatabase, SQL_VersionCheck, _sQuery, data);
1260 }
1261}
1262
1263public SQL_PerformUpdateQuery(Handle:owner, Handle:hndl, const String:error[], any:data)
1264{
1265 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1266 {
1267 LogCommNotice("Error: An update query failed to execute! This failure may be harmless!");
1268 decl String:_sError[512];
1269 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1270 LogCommNotice("- SQL_PerformUpdateQuery: %s", _sError);
1271 else
1272 LogCommNotice("- SQL_PerformUpdateQuery: %s", error);
1273 }
1274}
1275
1276public SQL_UpdateQuery3_0_0(Handle:owner, Handle:hndl, const String:error[], any:data)
1277{
1278 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1279 {
1280 LogCommNotice("Error: An update query failed to execute! This failure may be harmless!");
1281 decl String:_sError[512];
1282 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1283 LogCommNotice("- SQL_UpdateQuery3_0_0: %s", _sError);
1284 else
1285 LogCommNotice("- SQL_UpdateQuery3_0_0: %s", error);
1286 }
1287 else if(SQL_GetRowCount(hndl))
1288 {
1289 decl String:_sBuffer[32], String:_sQuery[512];
1290 while(SQL_FetchRow(hndl))
1291 {
1292 SQL_FetchString(hndl, 0, _sBuffer, 32);
1293
1294 new _iMuteType = SQL_FetchInt(hndl, 1);
1295 new _iMuteLength = SQL_FetchInt(hndl, 2);
1296 if(_iMuteType > 1)
1297 {
1298 if(!_iMuteLength)
1299 _iMuteType = COMM_MUTE_PERM;
1300 else
1301 _iMuteType = COMM_MUTE_TIME;
1302 }
1303 else
1304 _iMuteType = _iMuteLength = 0;
1305
1306 new _iGagType = SQL_FetchInt(hndl, 3);
1307 new _iGagLength = SQL_FetchInt(hndl, 4);
1308 if(_iGagType > 1)
1309 {
1310 if(!_iGagLength)
1311 _iGagType = COMM_GAG_PERM;
1312 else
1313 _iGagType = COMM_GAG_TIME;
1314 }
1315 else
1316 _iGagType = _iGagLength = 0;
1317
1318 if(!_iMuteType && !_iGagType)
1319 {
1320 Format(_sQuery, sizeof(_sQuery), g_sSQL_PrunePlayerPre_3_0_0, COMM_TABLE, _sBuffer);
1321 SQL_TQuery(g_hDatabase, SQL_PerformUpdateQuery, _sQuery, data);
1322 }
1323 else
1324 {
1325 Format(_sQuery, sizeof(_sQuery), g_sSQL_UpdatePlayerPre_3_0_0, COMM_TABLE, _iMuteType, _iMuteLength, _iGagType, _iGagLength, _sBuffer);
1326 SQL_TQuery(g_hDatabase, SQL_PerformUpdateQuery, _sQuery, data);
1327 }
1328 }
1329 }
1330}
1331
1332public SQL_UpdateQuery3_0_6(Handle:owner, Handle:hndl, const String:error[], any:data)
1333{
1334 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1335 {
1336 LogCommNotice("Error: An update query failed to execute! This failure may be harmless!");
1337 decl String:_sError[512];
1338 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1339 LogCommNotice("- SQL_UpdateQuery3_0_6: %s", _sError);
1340 else
1341 LogCommNotice("- SQL_UpdateQuery3_0_6: %s", error);
1342 }
1343}
1344
1345public SQL_VersionPrune(Handle:owner, Handle:hndl, const String:error[], any:data)
1346{
1347 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1348 {
1349 LogCommError("Error: The query \"g_sSQL_VersionPruneUpdate\" could not be executed!");
1350 decl String:_sError[512];
1351 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1352 LogCommError("- SQL_VersionPrune: %s", _sError);
1353 else
1354 LogCommError("- SQL_VersionPrune: %s", error);
1355 }
1356}
1357
1358public SQL_VersionUpdate(Handle:owner, Handle:hndl, const String:error[], any:data)
1359{
1360 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1361 {
1362 LogCommError("Error: The query \"g_sSQL_VersionUpdate\" could not be executed!");
1363 decl String:_sError[512];
1364 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1365 LogCommError("- SQL_VersionUpdate: %s", _sError);
1366 else
1367 LogCommError("- SQL_VersionUpdate: %s", error);
1368 }
1369 else
1370 {
1371 g_iUpdateSteps = 0;
1372
1373 decl String:_sQuery[512];
1374 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionSelect, COMM_TABLE_VERSION);
1375 SQL_TQuery(g_hDatabase, SQL_VersionCheck, _sQuery, data, DBPrio_High);
1376 }
1377}
1378
1379public SQL_VersionCheck(Handle:owner, Handle:hndl, const String:error[], any:data)
1380{
1381 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1382 {
1383 LogCommError("Error: The query \"g_sSQL_VersionSelect\" could not be executed!");
1384 decl String:_sError[512];
1385 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1386 LogCommError("- SQL_VersionCheck: %s", _sError);
1387 else
1388 LogCommError("- SQL_VersionCheck: %s", error);
1389 }
1390 else if(SQL_HasResultSet(hndl))
1391 {
1392 decl String:_sQuery[512];
1393 if(!SQL_GetRowCount(hndl))
1394 {
1395 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionExisting, COMM_TABLE);
1396 SQL_TQuery(g_hDatabase, SQL_VersionExisting, _sQuery, data);
1397
1398 return;
1399 }
1400
1401 if(SQL_FetchRow(hndl))
1402 {
1403 new _iCurrent = SQL_FetchInt(hndl, 0);
1404 if(_iCurrent == PLUGIN_UPDATE)
1405 {
1406 decl String:_sBuffer[32];
1407 SQL_FetchString(hndl, 1, _sBuffer, 32);
1408 if(!StrEqual(_sBuffer, g_sConnection, false))
1409 {
1410 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionUpdate, COMM_TABLE_VERSION, "0.0.0", "0", g_sConnection);
1411 SQL_TQuery(g_hDatabase, SQL_VersionUpdate, _sQuery, data, DBPrio_High);
1412
1413 return;
1414 }
1415
1416 if(g_bLateQuery)
1417 {
1418 for(new i = 1; i <= MaxClients; i++)
1419 {
1420 if(IsClientInGame(i))
1421 {
1422 Format(_sQuery, sizeof(_sQuery), g_sSQL_LoadClient, COMM_TABLE, g_sSteam[i]);
1423 SQL_TQuery(g_hDatabase, SQL_LoadPlayerCall, _sQuery, GetClientUserId(i));
1424 }
1425 }
1426
1427 g_bLateQuery = false;
1428 }
1429
1430 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionPrune, COMM_TABLE_VERSION);
1431 SQL_TQuery(g_hDatabase, SQL_QueryPrune, _sQuery, data, DBPrio_Low);
1432 return;
1433 }
1434
1435 switch(_iCurrent)
1436 {
1437 case 0:
1438 {
1439 //Version 2.X.X to 3.0.0
1440 switch(g_iUpdateSteps)
1441 {
1442 case 0:
1443 {
1444 for(new i = 0; i <= 3; i++)
1445 {
1446 Format(_sQuery, sizeof(_sQuery), g_sSQL_UpdateTables_3_0_0[i], COMM_TABLE);
1447 SQL_TQuery(g_hDatabase, SQL_PerformUpdateQuery, _sQuery, data, DBPrio_High);
1448 }
1449
1450 g_iUpdateSteps++;
1451 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionSelect, COMM_TABLE_VERSION);
1452 SQL_TQuery(g_hDatabase, SQL_VersionCheck, _sQuery, data);
1453 }
1454 case 1:
1455 {
1456 Format(_sQuery, sizeof(_sQuery), g_sSQL_SelectPlayerPre_3_0_0, COMM_TABLE_PREVIOUS);
1457 SQL_TQuery(g_hDatabase, SQL_UpdateQuery3_0_0, _sQuery, data, DBPrio_High);
1458
1459 g_iUpdateSteps++;
1460 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionSelect, COMM_TABLE_VERSION);
1461 SQL_TQuery(g_hDatabase, SQL_VersionCheck, _sQuery, data);
1462 }
1463 case 2:
1464 {
1465 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionUpdate, COMM_TABLE_VERSION, "3.0.0", "1", g_sConnection);
1466 SQL_TQuery(g_hDatabase, SQL_VersionUpdate, _sQuery, data, DBPrio_High);
1467 }
1468 }
1469 }
1470 case 1:
1471 {
1472 //Version 3.0.0 to 3.0.6
1473 switch(g_iUpdateSteps)
1474 {
1475 case 0:
1476 {
1477 Format(_sQuery, sizeof(_sQuery), g_sSQL_UpdateVersions_3_0_6, COMM_TABLE_VERSION);
1478 SQL_TQuery(g_hDatabase, SQL_PerformUpdateQuery, _sQuery, data, DBPrio_High);
1479
1480 g_iUpdateSteps++;
1481 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionSelect, COMM_TABLE_VERSION);
1482 SQL_TQuery(g_hDatabase, SQL_VersionCheck, _sQuery, data);
1483 }
1484 case 1:
1485 {
1486 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionUpdate, COMM_TABLE_VERSION, "3.0.6", "2", g_sConnection);
1487 SQL_TQuery(g_hDatabase, SQL_VersionUpdate, _sQuery, data, DBPrio_High);
1488 }
1489 }
1490 }
1491 }
1492 }
1493 }
1494}
1495
1496public SQL_VersionExisting(Handle:owner, Handle:hndl, const String:error[], any:data)
1497{
1498 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1499 {
1500 LogCommError("Error: The query \"g_sSQL_VersionExisting\" could not be executed!");
1501 decl String:_sError[512];
1502 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1503 LogCommError("- SQL_VersionExisting: %s", _sError);
1504 else
1505 LogCommError("- SQL_VersionExisting: %s", error);
1506 }
1507 else
1508 {
1509 decl String:_sQuery[512];
1510 if(!SQL_GetRowCount(hndl))
1511 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionUpdate, COMM_TABLE_VERSION, PLUGIN_VERSION, PLUGIN_UPDATE, g_sConnection);
1512 else
1513 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionUpdate, COMM_TABLE_VERSION, "0.0.0", 0, "-1");
1514 SQL_TQuery(g_hDatabase, SQL_VersionUpdate, _sQuery, data);
1515 }
1516}
1517
1518public SQL_LoadPlayerCall(Handle:owner, Handle:hndl, const String:error[], any:userid)
1519{
1520 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1521 {
1522 LogCommError("Error: The query \"g_sSQL_LoadClient\" could not be executed!");
1523 decl String:_sError[512];
1524 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1525 LogCommError("- SQL_LoadPlayerCall: %s", _sError);
1526 else
1527 LogCommError("- SQL_LoadPlayerCall: %s", error);
1528 }
1529 else
1530 {
1531 new client = GetClientOfUserId(userid);
1532 if(client > 0 && IsClientInGame(client))
1533 {
1534 if(SQL_HasResultSet(hndl))
1535 {
1536 if(SQL_FetchRow(hndl))
1537 {
1538 new _iEnding, _iTime = GetTime(), bool:_bSave = false;
1539 GetMapTimeLeft(_iEnding);
1540 _iEnding += _iTime;
1541
1542 g_iMuteType[client] = SQL_FetchInt(hndl, 0);
1543 g_iMuteLength[client] = SQL_FetchInt(hndl, 1);
1544 g_iMuteTime[client] = SQL_FetchInt(hndl, 2);
1545 SQL_FetchString(hndl, 3, g_sMuteAdmin[client], sizeof(g_sMuteAdmin[]));
1546 SQL_FetchString(hndl, 4, g_sMuteReason[client], sizeof(g_sMuteReason[]));
1547 g_iMuteLevel[client] = SQL_FetchInt(hndl, 5);
1548 if(g_iMuteType[client] & COMM_MUTE_TIME)
1549 {
1550 if((g_iMuteLength[client] + g_iMuteTime[client]) <= _iTime)
1551 {
1552 g_bCommSave[client] = true;
1553 g_iMuteType[client] &= ~COMM_MUTE_TIME;
1554 if(!(g_iMuteType[client] & COMM_MUTE_PERM))
1555 {
1556 _bSave = true;
1557 g_iMuteLength[client] = g_iMuteTime[client] = 0;
1558 g_sMuteAdmin[client][0] = g_sMuteReason[client][0] = '\0';
1559 }
1560 }
1561 else
1562 {
1563 BaseComm_SetClientMute(client, true);
1564 if(_iEnding > (g_iMuteLength[client] + g_iMuteTime[client]))
1565 {
1566 new _iRemaining = (_iEnding - (g_iMuteLength[client] + g_iMuteTime[client]));
1567 g_hTimer_MuteExpire[client] = CreateTimer(float(_iRemaining), Timer_MuteExpire, client, TIMER_FLAG_NO_MAPCHANGE);
1568 }
1569 }
1570 }
1571 else if(g_iMuteType[client] & COMM_MUTE_PERM)
1572 BaseComm_SetClientMute(client, true);
1573
1574 g_iGagType[client] = SQL_FetchInt(hndl, 6);
1575 g_iGagLength[client] = SQL_FetchInt(hndl, 7);
1576 g_iGagTime[client] = SQL_FetchInt(hndl, 8);
1577 SQL_FetchString(hndl, 9, g_sGagAdmin[client], sizeof(g_sGagAdmin[]));
1578 SQL_FetchString(hndl, 10, g_sGagReason[client], sizeof(g_sGagReason[]));
1579 g_iGagLevel[client] = SQL_FetchInt(hndl, 11);
1580 if(g_iGagType[client] & COMM_GAG_TIME)
1581 {
1582 if((g_iGagLength[client] + g_iGagTime[client]) <= _iTime)
1583 {
1584 g_bCommSave[client] = true;
1585 g_iGagType[client] &= ~COMM_GAG_TIME;
1586 if(!(g_iGagType[client] & COMM_GAG_PERM))
1587 {
1588 _bSave = true;
1589 g_iGagLength[client] = g_iGagTime[client] = 0;
1590 g_sGagAdmin[client][0] = g_sGagReason[client][0] = '\0';
1591 }
1592 }
1593 else
1594 {
1595 BaseComm_SetClientGag(client, true);
1596 if(_iEnding > (g_iGagLength[client] + g_iGagTime[client]))
1597 {
1598 new _iRemaining = (_iEnding - (g_iMuteLength[client] + g_iMuteTime[client]));
1599 g_hTimer_GagExpire[client] = CreateTimer(float(_iRemaining), Timer_GagExpire, client, TIMER_FLAG_NO_MAPCHANGE);
1600 }
1601 }
1602 }
1603 else if(g_iGagType[client] & COMM_GAG_PERM)
1604 BaseComm_SetClientGag(client, true);
1605
1606 if(_bSave)
1607 {
1608 if(g_bDelayQueries)
1609 g_bCommSave[client] = true;
1610 else
1611 Void_SaveClient(client);
1612 }
1613 }
1614 else
1615 {
1616 g_iMuteLevel[client] = g_iMuteType[client] = g_iMuteLength[client] = g_iMuteTime[client] = 0;
1617 g_sMuteAdmin[client][0] = g_sMuteReason[client][0] = '\0';
1618 g_iGagLevel[client] = g_iGagType[client] = g_iGagLength[client] = g_iGagTime[client] = 0;
1619 g_sGagAdmin[client][0] = g_sGagReason[client][0] = '\0';
1620 }
1621 }
1622 }
1623 }
1624}
1625
1626public SQL_DeletePlayerCall(Handle:owner, Handle:hndl, const String:error[], any:userid)
1627{
1628 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1629 {
1630 LogCommError("Error: The query \"g_sSQL_DeleteClient\" could not be executed!");
1631 decl String:_sError[512];
1632 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1633 LogCommError("- SQL_DeletePlayerCall: %s", _sError);
1634 else
1635 LogCommError("- SQL_DeletePlayerCall: %s", error);
1636 }
1637}
1638
1639public SQL_SavePlayerCall(Handle:owner, Handle:hndl, const String:error[], any:userid)
1640{
1641 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1642 {
1643 LogCommError("Error: The query \"g_sSQL_SaveClient\" could not be executed!");
1644 decl String:_sError[512];
1645 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1646 LogCommError("- SQL_SavePlayerCall: %s", _sError);
1647 else
1648 LogCommError("- SQL_SavePlayerCall: %s", error);
1649 }
1650}
1651
1652public SQL_PruneUpdate(Handle:owner, Handle:hndl, const String:error[], any:data)
1653{
1654 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1655 {
1656 LogCommError("Error: The query \"g_sSQL_PruneUpdate\" could not be executed!");
1657 decl String:_sError[512];
1658 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1659 LogCommError("- SQL_PruneUpdate: %s", _sError);
1660 else
1661 LogCommError("- SQL_PruneUpdate: %s", error);
1662 }
1663}
1664
1665public SQL_PruneDelete(Handle:owner, Handle:hndl, const String:error[], any:data)
1666{
1667 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1668 {
1669 LogCommError("Error: The query \"g_sSQL_PruneDelete\" could not be executed!");
1670 decl String:_sError[512];
1671 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1672 LogCommError("- SQL_PruneDelete: %s", _sError);
1673 else
1674 LogCommError("- SQL_PruneDelete: %s", error);
1675 }
1676}
1677
1678public SQL_QueryPrune(Handle:owner, Handle:hndl, const String:error[], any:userid)
1679{
1680 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1681 {
1682 LogCommError("Error: The automatic prune query could not be executed!");
1683 decl String:_sError[512];
1684 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1685 LogCommError("- SQL_QueryPrune: %s", _sError);
1686 else
1687 LogCommError("- SQL_QueryPrune: %s", error);
1688 }
1689 else
1690 {
1691 if(SQL_FetchRow(hndl))
1692 {
1693 if(GetTime() >= (SQL_FetchInt(hndl, 0) + g_iPruneInterval))
1694 {
1695 decl String:_sQuery[512];
1696 Format(_sQuery, sizeof(_sQuery), g_sSQL_PruneSelect, COMM_TABLE);
1697 SQL_TQuery(g_hDatabase, SQL_AutoPrune, _sQuery, -1, DBPrio_Low);
1698 }
1699 }
1700 }
1701}
1702
1703public SQL_AutoPrune(Handle:owner, Handle:hndl, const String:error[], any:userid)
1704{
1705 if(hndl == INVALID_HANDLE || strlen(error) > 0)
1706 {
1707 LogCommError("Error: The automatic prune query could not be executed!");
1708 decl String:_sError[512];
1709 if(hndl != INVALID_HANDLE && SQL_GetError(hndl, _sError, 512))
1710 LogCommError("- SQL_AutoPrune: %s", _sError);
1711 else
1712 LogCommError("- SQL_AutoPrune: %s", error);
1713 }
1714 else
1715 {
1716 new _iCurrent = GetTime(), _iRemove, _iUpdate;
1717 decl String:_sBuffer[32], String:_sQuery[512];
1718 decl _iMuteState, _iMuteTime, _iMuteLength, _iGagState, _iGagTime, _iGagLength;
1719 while (SQL_FetchRow(hndl))
1720 {
1721 SQL_FetchString(hndl, 0, _sBuffer, 32);
1722
1723 _iMuteState = SQL_FetchInt(hndl, 1);
1724 if(_iMuteState & COMM_MUTE_TIME)
1725 {
1726 _iMuteLength = SQL_FetchInt(hndl, 2);
1727 _iMuteTime = SQL_FetchInt(hndl, 3);
1728 if((_iMuteLength + _iMuteTime) <= _iCurrent)
1729 {
1730 _iMuteState &= ~COMM_MUTE_TIME;
1731 _iMuteLength = _iMuteTime = 0;
1732 }
1733 }
1734
1735 _iGagState = SQL_FetchInt(hndl, 4);
1736 if(_iGagState & COMM_GAG_TIME)
1737 {
1738 _iGagLength = SQL_FetchInt(hndl, 5);
1739 _iGagTime = SQL_FetchInt(hndl, 6);
1740 if((_iGagLength + _iGagTime) <= _iCurrent)
1741 {
1742 _iGagState &= ~COMM_GAG_TIME;
1743 _iGagLength = _iGagTime = 0;
1744 }
1745 }
1746
1747 if(!_iMuteState && !_iGagState)
1748 {
1749 _iRemove++;
1750 Format(_sQuery, 256, g_sSQL_PruneDelete, COMM_TABLE, _sBuffer);
1751 SQL_TQuery(g_hDatabase, SQL_PruneDelete, _sQuery, userid);
1752 }
1753 else
1754 {
1755 _iUpdate++;
1756 Format(_sQuery, 256, g_sSQL_PruneUpdate, COMM_TABLE, _iMuteState, _iMuteLength, _iMuteTime, _iGagState, _iGagLength, _iGagTime, _sBuffer);
1757 SQL_TQuery(g_hDatabase, SQL_PruneUpdate, _sQuery, userid);
1758 }
1759 }
1760
1761 if(!userid)
1762 ReplyToCommand(userid, "%s%t", g_sPrefixConsole, "Commande_Prune_Complete", _iRemove, _iUpdate);
1763 else if(userid > 0)
1764 {
1765 new client = GetClientOfUserId(userid);
1766 if(client > 0 && IsClientInGame(client))
1767 PrintToChat(client, "%s%t", g_sPrefixConsole, "Commande_Prune_Complete", _iRemove, _iUpdate);
1768 }
1769
1770 Format(_sQuery, sizeof(_sQuery), g_sSQL_VersionPruneUpdate, COMM_TABLE_VERSION, GetTime());
1771 SQL_TQuery(g_hDatabase, SQL_VersionPrune, _sQuery, -1, DBPrio_High);
1772 }
1773}
1774
1775public Action:Timer_MuteExpire(Handle:timer, any:client)
1776{
1777 if(IsClientInGame(client))
1778 {
1779 g_iMuteType[client] &= ~COMM_MUTE_TIME;
1780 if(!(g_iMuteType[client] & COMM_MUTE_PERM))
1781 {
1782 g_iMuteLength[client] = g_iMuteTime[client] = 0;
1783 if(!g_bTempMuted[client])
1784 BaseComm_SetClientMute(client, false);
1785 }
1786
1787 if(g_bDelayQueries)
1788 g_bCommSave[client] = true;
1789 else
1790 Void_SaveClient(client);
1791 }
1792
1793 g_hTimer_MuteExpire[client] = INVALID_HANDLE;
1794}
1795
1796public Action:Timer_GagExpire(Handle:timer, any:client)
1797{
1798 if(IsClientInGame(client))
1799 {
1800 g_bCommSave[client] = true;
1801 g_iGagType[client] &= ~COMM_GAG_TIME;
1802 if(!(g_iGagType[client] & COMM_GAG_PERM))
1803 {
1804 g_iGagLength[client] = g_iGagTime[client] = 0;
1805 if(!g_bTempGagged[client])
1806 BaseComm_SetClientGag(client, false);
1807 }
1808
1809 if(g_bDelayQueries)
1810 g_bCommSave[client] = true;
1811 else
1812 Void_SaveClient(client);
1813 }
1814
1815 g_hTimer_GagExpire[client] = INVALID_HANDLE;
1816}
1817
1818Void_LoadTimes()
1819{
1820 g_iNumTimes = 0;
1821 decl String:_sPath[PLATFORM_MAX_PATH], String:_sBuffer[MAX_COMM_TIMES][32];
1822 new _iBuffer[2][MAX_COMM_TIMES], _iHighest, _iIndex;
1823
1824 new Handle:_hKV = CreateKeyValues("ExtendedComm_Times");
1825 BuildPath(Path_SM, _sPath, PLATFORM_MAX_PATH, "configs/extendedcomm/extendedcomm_times.ini");
1826 if(FileToKeyValues(_hKV, _sPath))
1827 {
1828 decl String:_sTemp[32];
1829 KvGotoFirstSubKey(_hKV);
1830 do
1831 {
1832 KvGetSectionName(_hKV, _sBuffer[g_iNumTimes], 32);
1833 _iBuffer[0][g_iNumTimes] = KvGetNum(_hKV, "seconds", 0);
1834 KvGetString(_hKV, "flags", _sTemp, sizeof(_sTemp));
1835 _iBuffer[1][g_iNumTimes] = StrEqual(_sTemp, "") ? 0 : ReadFlagString(_sTemp);
1836
1837 //Lazy Patch: Permanent should be last!
1838 if(!_iBuffer[0][g_iNumTimes])
1839 _iBuffer[0][g_iNumTimes] = 2147483647;
1840
1841 g_iNumTimes++;
1842 }
1843 while (KvGotoNextKey(_hKV));
1844 }
1845 CloseHandle(_hKV);
1846 if(g_iNumTimes)
1847 g_iNumTimes--;
1848
1849 new _iSorted = 0;
1850 for(new i = 0; i <= g_iNumTimes; i++)
1851 {
1852 _iIndex = 0;
1853 _iHighest = -2147483647;
1854 for(new j = 0; j <= g_iNumTimes; j++)
1855 {
1856 if(_iBuffer[0][j] > _iHighest)
1857 {
1858 _iIndex = j;
1859 _iHighest = _iBuffer[0][j];
1860 }
1861 }
1862
1863 strcopy(g_sTimeDisplays[_iSorted], sizeof(g_sTimeDisplays[]), _sBuffer[_iIndex]);
1864 g_iTimeSeconds[_iSorted] = _iBuffer[0][_iIndex];
1865 g_iTimeFlags[_iSorted] = _iBuffer[1][_iIndex];
1866 _iBuffer[0][_iIndex] = 2147483648;
1867 _iSorted++;
1868 }
1869
1870 //Lazy Patch: Permanent should be last!
1871 for(new i = g_iNumTimes; i >= 0; i--)
1872 {
1873 if(g_iTimeSeconds[i] == 2147483647)
1874 {
1875 g_iTimeSeconds[i] = 0;
1876 break;
1877 }
1878 }
1879}
1880
1881Void_LoadReasons()
1882{
1883 g_iNumReasons = 0;
1884 decl String:_sPath[PLATFORM_MAX_PATH];
1885 new Handle:_hKV = CreateKeyValues("ExtendedComm_Reasons");
1886 BuildPath(Path_SM, _sPath, PLATFORM_MAX_PATH, "configs/extendedcomm/extendedcomm_reasons.ini");
1887 if(FileToKeyValues(_hKV, _sPath))
1888 {
1889 decl String:_sTemp[32];
1890 KvGotoFirstSubKey(_hKV);
1891 do
1892 {
1893 KvGetSectionName(_hKV, g_sReasonDisplays[g_iNumReasons], sizeof(g_sReasonDisplays[]));
1894 KvGetString(_hKV, "flags", _sTemp, sizeof(_sTemp));
1895 KvGetString(_hKV, "reason", g_sReasonReasons[g_iNumReasons], sizeof(g_sReasonReasons[]));
1896 g_iReasonFlags[g_iNumReasons] = StrEqual(_sTemp, "") ? 0 : ReadFlagString(_sTemp);
1897 g_iNumReasons++;
1898 }
1899 while (KvGotoNextKey(_hKV));
1900 }
1901 CloseHandle(_hKV);
1902 if(g_iNumReasons)
1903 g_iNumReasons--;
1904}
1905
1906Void_SetDefaults()
1907{
1908 g_bTemporary = GetConVarInt(g_hTemporary) ? true : false;
1909 g_bDelayQueries = GetConVarInt(g_hDelayQueries) ? true : false;
1910 g_bObeyImmunity = GetConVarInt(g_hObeyImmunity) ? true : false;
1911 g_iPruneInterval = GetConVarInt(g_hPruneInterval);
1912 GetConVarString(g_hConnection, g_sConnection, sizeof(g_sConnection));
1913 GetConVarString(g_hTimeFormat, g_sTimeFormat, sizeof(g_sTimeFormat));
1914 g_bNullTime = StrEqual(g_sTimeFormat, "", false) ? true : false;
1915
1916 decl String:_sBuffer[PLATFORM_MAX_PATH];
1917 GetConVarString(g_hLogActions, _sBuffer, sizeof(_sBuffer));
1918 g_bLogActions = StrEqual(_sBuffer, "") ? false : true;
1919 if(g_bLogActions)
1920 BuildPath(Path_SM, g_sLogActions, sizeof(g_sLogActions), _sBuffer);
1921
1922 GetConVarString(g_hLogNotices, _sBuffer, sizeof(_sBuffer));
1923 g_bLogNotices = StrEqual(_sBuffer, "") ? false : true;
1924 if(g_bLogNotices)
1925 BuildPath(Path_SM, g_sLogNotices, sizeof(g_sLogNotices), _sBuffer);
1926}
1927
1928public OnSettingsChange(Handle:convar, const String:oldvalue[], const String:newvalue[])
1929{
1930 if(convar == g_hConnection)
1931 {
1932 Format(g_sConnection, sizeof(g_sConnection), "%s", newvalue);
1933 if(g_hDatabase != INVALID_HANDLE)
1934 CloseHandle(g_hDatabase);
1935
1936 SQL_TConnect(SQL_ConnectCall, StrEqual(newvalue, "") ? "storage-local" : newvalue, _);
1937 }
1938 else if(convar == g_hTemporary)
1939 {
1940 g_bTemporary = StringToInt(newvalue) ? true : false;
1941 }
1942 else if(convar == g_hDelayQueries)
1943 {
1944 g_bDelayQueries = StringToInt(newvalue) ? true : false;
1945 }
1946 else if(convar == g_hObeyImmunity)
1947 {
1948 g_bObeyImmunity = StringToInt(newvalue) ? true : false;
1949 }
1950 else if(convar == g_hLogActions)
1951 {
1952 g_bLogActions = StrEqual(newvalue, "") ? false : true;
1953 if(g_bLogActions)
1954 BuildPath(Path_SM, g_sLogActions, sizeof(g_sLogActions), newvalue);
1955 }
1956 else if(convar == g_hLogNotices)
1957 {
1958 g_bLogNotices = StrEqual(newvalue, "") ? false : true;
1959 if(g_bLogNotices)
1960 BuildPath(Path_SM, g_sLogNotices, sizeof(g_sLogNotices), newvalue);
1961 }
1962 else if(convar == g_hTimeFormat)
1963 {
1964 g_bNullTime = StrEqual(newvalue, "", false) ? true : false;
1965 Format(g_sTimeFormat, sizeof(g_sTimeFormat), "%s", newvalue);
1966 }
1967 else if(convar == g_hPruneInterval)
1968 {
1969 g_iPruneInterval = StringToInt(newvalue);
1970 }
1971}
1972
1973LogCommAction(client, target, const String:format[], any:...)
1974{
1975 decl String:_sBuffer[192];
1976 VFormat(_sBuffer, sizeof(_sBuffer), format, 4);
1977
1978 LogAction(client, target, "%s", _sBuffer);
1979 if(g_bLogActions)
1980 LogToFileEx(g_sLogActions, "%s", _sBuffer);
1981}
1982
1983LogCommError(const String:format[], any:...)
1984{
1985 decl String:_sBuffer[192];
1986 VFormat(_sBuffer, sizeof(_sBuffer), format, 2);
1987
1988 LogError("%s", _sBuffer);
1989 if(g_bLogNotices)
1990 LogToFileEx(g_sLogNotices, "%s", _sBuffer);
1991}
1992
1993LogCommNotice(const String:format[], any:...)
1994{
1995 decl String:_sBuffer[192];
1996 VFormat(_sBuffer, sizeof(_sBuffer), format, 2);
1997
1998 LogMessage("%s", _sBuffer);
1999 if(g_bLogNotices)
2000 LogToFileEx(g_sLogActions, "%s", _sBuffer);
2001}
2002
2003public Native_GetMuteType(Handle:plugin, numParams)
2004{
2005 if(g_hDatabase != INVALID_HANDLE)
2006 {
2007 new client = GetNativeCell(1);
2008 if(client > 0 && IsClientInGame(client))
2009 {
2010 if(g_iMuteType[client] & COMM_MUTE_PERM)
2011 return 3;
2012 else if(g_iMuteType[client] & COMM_MUTE_TIME)
2013 return 2;
2014 else if(g_bTempMuted[client])
2015 return 1;
2016 }
2017 }
2018 else
2019 return -2;
2020
2021 return -1;
2022}
2023
2024public Native_GetMuteLength(Handle:plugin, numParams)
2025{
2026 if(g_hDatabase != INVALID_HANDLE)
2027 {
2028 new client = GetNativeCell(1);
2029 if(client > 0 && IsClientInGame(client))
2030 if(g_iMuteType[client] & COMM_MUTE_TIME)
2031 return g_iMuteLength[client];
2032 }
2033 else
2034 return -2;
2035
2036 return -1;
2037}
2038
2039public Native_GetMuteStart(Handle:plugin, numParams)
2040{
2041 if(g_hDatabase != INVALID_HANDLE)
2042 {
2043 new client = GetNativeCell(1);
2044 if(client > 0 && IsClientInGame(client))
2045 if(g_iMuteType[client])
2046 return g_iMuteTime[client];
2047 }
2048 else
2049 return -2;
2050
2051 return -1;
2052}
2053
2054public Native_GetMuteExpire(Handle:plugin, numParams)
2055{
2056 if(g_hDatabase != INVALID_HANDLE)
2057 {
2058 new client = GetNativeCell(1);
2059 if(client > 0 && IsClientInGame(client))
2060 if(g_iMuteType[client] & COMM_MUTE_TIME)
2061 return (g_iMuteTime[client] + g_iMuteLength[client]);
2062 }
2063 else
2064 return -2;
2065
2066 return -1;
2067}
2068
2069public Native_GetGagType(Handle:plugin, numParams)
2070{
2071 if(g_hDatabase != INVALID_HANDLE)
2072 {
2073 new client = GetNativeCell(1);
2074 if(client > 0 && IsClientInGame(client))
2075 {
2076 if(g_iGagType[client] & COMM_GAG_PERM)
2077 return 3;
2078 else if(g_iGagType[client] & COMM_GAG_TIME)
2079 return 2;
2080 else if(g_bTempGagged[client])
2081 return 1;
2082 }
2083 }
2084 else
2085 return -2;
2086
2087 return -1;
2088}
2089
2090public Native_GetGagLength(Handle:plugin, numParams)
2091{
2092 if(g_hDatabase != INVALID_HANDLE)
2093 {
2094 new client = GetNativeCell(1);
2095 if(client > 0 && IsClientInGame(client))
2096 if(g_iGagType[client] & COMM_GAG_TIME)
2097 return g_iGagLength[client];
2098 }
2099 else
2100 return -2;
2101
2102 return -1;
2103}
2104
2105public Native_GetGagStart(Handle:plugin, numParams)
2106{
2107 if(g_hDatabase != INVALID_HANDLE)
2108 {
2109 new client = GetNativeCell(1);
2110 if(client > 0 && IsClientInGame(client))
2111 if(g_iGagType[client])
2112 return g_iGagTime[client];
2113 }
2114 else
2115 return -2;
2116
2117 return -1;
2118}
2119
2120public Native_GetGagExpire(Handle:plugin, numParams)
2121{
2122 if(g_hDatabase != INVALID_HANDLE)
2123 {
2124 new client = GetNativeCell(1);
2125 if(client > 0 && IsClientInGame(client))
2126 if(g_iGagType[client] & COMM_GAG_TIME)
2127 return (g_iGagTime[client] + g_iGagLength[client]);
2128 }
2129 else
2130 return -2;
2131
2132 return -1;
2133}
2134
2135Bool_ValidMenuTarget(client, target, bool:checkImmunity = true)
2136{
2137 if(target <= 0)
2138 {
2139 decl String:_sBuffer[192];
2140 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Not_Available", client);
2141 if(client)
2142 PrintToChat(client, "%s%s", g_sPrefixChat, _sBuffer);
2143 else
2144 ReplyToCommand(client, "%s%s", g_sPrefixConsole, _sBuffer);
2145
2146 return false;
2147 }
2148 else if(checkImmunity && !CanUserTarget(client, target))
2149 {
2150 decl String:_sBuffer[192];
2151 Format(_sBuffer, sizeof(_sBuffer), "%T", "Command_Target_Not_Targetable", client);
2152 if(client)
2153 PrintToChat(client, "%s%s", g_sPrefixChat, _sBuffer);
2154 else
2155 ReplyToCommand(client, "%s%s", g_sPrefixConsole, _sBuffer);
2156
2157 return false;
2158 }
2159
2160 return true;
2161}
2162
2163AdminMenu_GetPunishPhrase(client, target, String:name[], length)
2164{
2165 decl String:_sBuffer[192];
2166 if((g_bTempMuted[target] || g_iMuteType[target]) && (g_bTempGagged[target] || g_iGagType[target]))
2167 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Display_Silenced", client, name);
2168 else if(g_bTempMuted[target] || g_iMuteType[target])
2169 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Display_Muted", client, name);
2170 else if(g_bTempGagged[target] || g_iGagType[target])
2171 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Display_Gagged", client, name);
2172 else
2173 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Display_None", client, name);
2174
2175 strcopy(name, length, _sBuffer);
2176}
2177
2178GetIssuerName(client, String:name[], length)
2179{
2180 decl String:_sBuffer[192];
2181 if(!client)
2182 Format(_sBuffer, sizeof(_sBuffer), "Console");
2183 else
2184 {
2185 if(g_AdminId[client] == INVALID_ADMIN_ID)
2186 strcopy(_sBuffer, sizeof(_sBuffer), g_sSteam[client]);
2187 else
2188 {
2189 decl String:_sTemp[32];
2190 if(GetAdminUsername(g_AdminId[client], _sTemp, sizeof(_sTemp)))
2191 strcopy(_sBuffer, sizeof(_sBuffer), _sTemp);
2192 else
2193 strcopy(_sBuffer, sizeof(_sBuffer), g_sSteam[client]);
2194 }
2195 }
2196 strcopy(name, length, _sBuffer);
2197}
2198
2199public Handle_Commands(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2200{
2201 switch(action)
2202 {
2203 case TopMenuAction_DisplayOption:
2204 Format(buffer, maxlength, "%T", "AdminMenu_Main", param1);
2205 case TopMenuAction_DisplayTitle:
2206 Format(buffer, maxlength, "%T", "AdminMenu_Select_Main", param1);
2207 }
2208}
2209
2210public Handle_MenuList(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2211{
2212 if(action == TopMenuAction_DisplayOption)
2213 Format(buffer, maxlength, "%T", "AdminMenu_List", param1);
2214 else if(action == TopMenuAction_SelectOption)
2215 {
2216 g_iPeskyPanels[param1][viewingList] = false;
2217 AdminMenu_List(param1, 0);
2218 }
2219}
2220
2221public Handle_MenuGag(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2222{
2223 if(action == TopMenuAction_DisplayOption)
2224 Format(buffer, maxlength, "%T", "AdminMenu_Gag", param1);
2225 else if(action == TopMenuAction_SelectOption)
2226 AdminMenu_Target(param1, COMM_GAG);
2227}
2228
2229public Handle_MenuMute(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2230{
2231 if(action == TopMenuAction_DisplayOption)
2232 Format(buffer, maxlength, "%T", "AdminMenu_Mute", param1);
2233 else if(action == TopMenuAction_SelectOption)
2234 AdminMenu_Target(param1, COMM_MUTE);
2235}
2236
2237public Handle_MenuSilence(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2238{
2239 if(action == TopMenuAction_DisplayOption)
2240 Format(buffer, maxlength, "%T", "AdminMenu_Silence", param1);
2241 else if(action == TopMenuAction_SelectOption)
2242 AdminMenu_Target(param1, COMM_SILENCE);
2243}
2244
2245public Handle_MenuGagged(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2246{
2247 if(action == TopMenuAction_DisplayOption)
2248 Format(buffer, maxlength, "%T", "AdminMenu_Gagged", param1);
2249 else if(action == TopMenuAction_SelectOption)
2250 AdminMenu_Target(param1, COMM_GAGGED);
2251}
2252
2253public Handle_MenuMuted(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2254{
2255 if(action == TopMenuAction_DisplayOption)
2256 Format(buffer, maxlength, "%T", "AdminMenu_Muted", param1);
2257 else if(action == TopMenuAction_SelectOption)
2258 AdminMenu_Target(param1, COMM_MUTED);
2259}
2260
2261public Handle_MenuSilenced(Handle:menu, TopMenuAction:action, TopMenuObject:object_id, param1, String:buffer[], maxlength)
2262{
2263 if(action == TopMenuAction_DisplayOption)
2264 Format(buffer, maxlength, "%T", "AdminMenu_Silenced", param1);
2265 else if(action == TopMenuAction_SelectOption)
2266 AdminMenu_Target(param1, COMM_SILENCED);
2267}
2268
2269AdminMenu_Target(client, type)
2270{
2271 decl String:_sTitle[192], String:_sOption[32];
2272 switch(type)
2273 {
2274 case COMM_GAG:
2275 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Gag", client);
2276 case COMM_MUTE:
2277 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Mute", client);
2278 case COMM_SILENCE:
2279 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Silence", client);
2280 case COMM_GAGGED:
2281 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Gagged", client);
2282 case COMM_MUTED:
2283 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Muted", client);
2284 case COMM_SILENCED:
2285 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_Silenced", client);
2286 }
2287 new Handle:_hMenu = CreateMenu(MenuHandler_MenuTarget);
2288 SetMenuTitle(_hMenu, _sTitle);
2289 SetMenuExitBackButton(_hMenu, true);
2290
2291 if(type <= 3)
2292 {
2293 for(new i = 1; i <= MaxClients; i++)
2294 {
2295 if(IsClientInGame(i))
2296 {
2297 strcopy(_sTitle, sizeof(_sTitle), g_sName[i]);
2298 AdminMenu_GetPunishPhrase(client, i, _sTitle, sizeof(_sTitle));
2299 Format(_sOption, sizeof(_sOption), "%d %d", GetClientUserId(i), type);
2300 AddMenuItem(_hMenu, _sOption, _sTitle, (CanUserTarget(client, i) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED));
2301 }
2302 }
2303 }
2304 else
2305 {
2306 new _iClients;
2307 for(new i = 1; i <= MaxClients; i++)
2308 {
2309 if(IsClientInGame(i))
2310 {
2311 switch(type)
2312 {
2313 case COMM_MUTED:
2314 {
2315 if(g_bTempMuted[i] || g_iMuteType[i])
2316 {
2317 _iClients++;
2318 strcopy(_sTitle, sizeof(_sTitle), g_sName[i]);
2319 Format(_sOption, sizeof(_sOption), "%d %d", GetClientUserId(i), type);
2320 AddMenuItem(_hMenu, _sOption, _sTitle, (CanUserTarget(client, i) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED));
2321 }
2322 }
2323 case COMM_GAGGED:
2324 {
2325 if(g_bTempGagged[i] || g_iGagType[i])
2326 {
2327 _iClients++;
2328 strcopy(_sTitle, sizeof(_sTitle), g_sName[i]);
2329 Format(_sOption, sizeof(_sOption), "%d %d", GetClientUserId(i), type);
2330 AddMenuItem(_hMenu, _sOption, _sTitle, (CanUserTarget(client, i) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED));
2331 }
2332 }
2333 case COMM_SILENCED:
2334 {
2335 if((g_bTempMuted[i] || g_iMuteType[i]) && (g_bTempGagged[i] || g_iGagType[i]))
2336 {
2337 _iClients++;
2338 strcopy(_sTitle, sizeof(_sTitle), g_sName[i]);
2339 Format(_sOption, sizeof(_sOption), "%d %d", GetClientUserId(i), type);
2340 AddMenuItem(_hMenu, _sOption, _sTitle, (CanUserTarget(client, i) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED));
2341 }
2342 }
2343 }
2344 }
2345 }
2346
2347 if(!_iClients)
2348 {
2349 switch(type)
2350 {
2351 case COMM_MUTED:
2352 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Option_Mute_Empty", client);
2353 case COMM_GAGGED:
2354 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Option_Gag_Empty", client);
2355 case COMM_SILENCED:
2356 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Option_Silence_Empty", client);
2357 }
2358 AddMenuItem(_hMenu, "0", _sTitle, ITEMDRAW_DISABLED);
2359 }
2360 }
2361 SetMenuExitButton(_hMenu, true);
2362 DisplayMenu(_hMenu, client, MENU_TIME_FOREVER);
2363}
2364
2365public MenuHandler_MenuTarget(Handle:menu, MenuAction:action, param1, param2)
2366{
2367 switch(action)
2368 {
2369 case MenuAction_End:
2370 CloseHandle(menu);
2371 case MenuAction_Cancel:
2372 {
2373 if(param2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
2374 DisplayTopMenu(g_hTopMenu, param1, TopMenuPosition_LastCategory);
2375 }
2376 case MenuAction_Select:
2377 {
2378 decl String:_sOption[32], String:_sTemp[2][8];
2379 GetMenuItem(menu, param2, _sOption, sizeof(_sOption));
2380 ExplodeString(_sOption, " ", _sTemp, 2, 8);
2381 new target = GetClientOfUserId(StringToInt(_sTemp[0]));
2382
2383 if(Bool_ValidMenuTarget(param1, target))
2384 {
2385 new type = StringToInt(_sTemp[1]);
2386 if(type <= 3)
2387 {
2388 if(g_iNumTimes && g_hDatabase != INVALID_HANDLE)
2389 AdminMenu_Duration(param1, target, type);
2390 else
2391 {
2392 GetIssuerName(param1, _sOption, sizeof(_sOption));
2393 switch(type)
2394 {
2395 case COMM_MUTE:
2396 PerformMuteCommand(param1, target, -1, "", _sOption);
2397 case COMM_GAG:
2398 PerformGagCommand(param1, target, -1, "", _sOption);
2399 case COMM_SILENCE:
2400 PerformSilenceCommand(param1, target, -1, "", _sOption);
2401 }
2402 }
2403 }
2404 else
2405 {
2406 switch(type)
2407 {
2408 case COMM_MUTED:
2409 PerformMutedCommand(param1, target, true);
2410 case COMM_GAGGED:
2411 PerformGaggedCommand(param1, target, true);
2412 case COMM_SILENCED:
2413 PerformSilencedCommand(param1, target, true);
2414 }
2415 }
2416 }
2417 }
2418 }
2419}
2420
2421AdminMenu_Duration(client, target, type)
2422{
2423 new Handle:_hMenu = CreateMenu(MenuHandler_MenuDuration);
2424 decl String:_sBuffer[192], String:_sTemp[64];
2425 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Title_Durations", client);
2426 SetMenuTitle(_hMenu, _sBuffer);
2427 SetMenuExitBackButton(_hMenu, true);
2428
2429 new _iFlags = GetUserFlagBits(client);
2430 for(new i = g_iNumTimes; i >= 0; i--)
2431 {
2432 if(!g_iTimeFlags[i] || _iFlags & g_iTimeFlags[i])
2433 {
2434 Format(_sTemp, sizeof(_sTemp), "%d %d %d", GetClientUserId(target), type, i);
2435 AddMenuItem(_hMenu, _sTemp, g_sTimeDisplays[i]);
2436 }
2437 }
2438
2439 DisplayMenu(_hMenu, client, MENU_TIME_FOREVER);
2440}
2441
2442public MenuHandler_MenuDuration(Handle:menu, MenuAction:action, param1, param2)
2443{
2444 switch(action)
2445 {
2446 case MenuAction_End:
2447 CloseHandle(menu);
2448 case MenuAction_Cancel:
2449 {
2450 if(param2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
2451 DisplayTopMenu(g_hTopMenu, param1, TopMenuPosition_LastCategory);
2452 }
2453 case MenuAction_Select:
2454 {
2455 decl String:_sOption[32], String:_sTemp[3][8];
2456 GetMenuItem(menu, param2, _sOption, sizeof(_sOption));
2457 ExplodeString(_sOption, " ", _sTemp, 3, 8);
2458 new target = GetClientOfUserId(StringToInt(_sTemp[0]));
2459
2460 if(Bool_ValidMenuTarget(param1, target))
2461 {
2462 new type = StringToInt(_sTemp[1]);
2463 new length = StringToInt(_sTemp[2]);
2464
2465 if(g_iNumReasons && g_iTimeSeconds[length] >= 0)
2466 AdminMenu_Reason(param1, target, type, length);
2467 else
2468 {
2469 GetIssuerName(param1, _sOption, sizeof(_sOption));
2470 switch(type)
2471 {
2472 case COMM_MUTE:
2473 PerformMuteCommand(param1, target, g_iTimeSeconds[length], "", _sOption);
2474 case COMM_GAG:
2475 PerformGagCommand(param1, target, g_iTimeSeconds[length], "", _sOption);
2476 case COMM_SILENCE:
2477 PerformSilenceCommand(param1, target, g_iTimeSeconds[length], "", _sOption);
2478 }
2479 }
2480 }
2481 }
2482 }
2483}
2484
2485AdminMenu_Reason(client, target, type, length = -1)
2486{
2487 new Handle:_hMenu = CreateMenu(MenuHandler_MenuReason);
2488 decl String:_sBuffer[192], String:_sTemp[64];
2489 Format(_sBuffer, sizeof(_sBuffer), "%T", "AdminMenu_Title_Reasons", client);
2490 SetMenuTitle(_hMenu, _sBuffer);
2491 SetMenuExitBackButton(_hMenu, true);
2492
2493 new _iFlags = GetUserFlagBits(client);
2494 for(new i = g_iNumReasons; i >= 0; i--)
2495 {
2496 if(!g_iReasonFlags[i] || _iFlags & g_iReasonFlags[i])
2497 {
2498 Format(_sTemp, sizeof(_sTemp), "%d %d %d %d", GetClientUserId(target), type, i, length);
2499 AddMenuItem(_hMenu, _sTemp, g_sReasonDisplays[i]);
2500 }
2501 }
2502
2503 DisplayMenu(_hMenu, client, MENU_TIME_FOREVER);
2504}
2505
2506public MenuHandler_MenuReason(Handle:menu, MenuAction:action, param1, param2)
2507{
2508 switch(action)
2509 {
2510 case MenuAction_End:
2511 CloseHandle(menu);
2512 case MenuAction_Cancel:
2513 {
2514 if(param2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
2515 DisplayTopMenu(g_hTopMenu, param1, TopMenuPosition_LastCategory);
2516 }
2517 case MenuAction_Select:
2518 {
2519 decl String:_sOption[64], String:_sTemp[4][8];
2520 GetMenuItem(menu, param2, _sOption, sizeof(_sOption));
2521 ExplodeString(_sOption, " ", _sTemp, 4, 8);
2522 new target = GetClientOfUserId(StringToInt(_sTemp[0]));
2523
2524 if(Bool_ValidMenuTarget(param1, target))
2525 {
2526 new type = StringToInt(_sTemp[1]);
2527 new reason = StringToInt(_sTemp[2]);
2528 new length = StringToInt(_sTemp[3]) >= 0 ? g_iTimeSeconds[StringToInt(_sTemp[3])] : -1;
2529
2530 GetIssuerName(param1, _sOption, sizeof(_sOption));
2531 switch(type)
2532 {
2533 case COMM_MUTE:
2534 PerformMuteCommand(param1, target, length, g_sReasonReasons[reason], _sOption);
2535 case COMM_GAG:
2536 PerformGagCommand(param1, target, length, g_sReasonReasons[reason], _sOption);
2537 case COMM_SILENCE:
2538 PerformSilenceCommand(param1, target, length, g_sReasonReasons[reason], _sOption);
2539 }
2540 }
2541 }
2542 }
2543}
2544
2545AdminMenu_List(client, index)
2546{
2547 decl String:_sTitle[192], String:_sOption[32];
2548 Format(_sTitle, sizeof(_sTitle), "%T", "AdminMenu_Select_List", client);
2549 new _iClients, Handle:_hMenu = CreateMenu(MenuHandler_MenuList);
2550 SetMenuTitle(_hMenu, _sTitle);
2551 if(!g_iPeskyPanels[client][viewingList])
2552 SetMenuExitBackButton(_hMenu, true);
2553
2554 for(new i = 1; i <= MaxClients; i++)
2555 {
2556 if(IsClientInGame(i) && (g_bTempMuted[i] || g_bTempGagged[i] || g_iMuteType[i] || g_iGagType[i]))
2557 {
2558 _iClients++;
2559 strcopy(_sTitle, sizeof(_sTitle), g_sName[i]);
2560 AdminMenu_GetPunishPhrase(client, i, _sTitle, sizeof(_sTitle));
2561 Format(_sOption, sizeof(_sOption), "%d", GetClientUserId(i));
2562 AddMenuItem(_hMenu, _sOption, _sTitle);
2563 }
2564 }
2565
2566 if(!_iClients)
2567 {
2568 Format(_sTitle, sizeof(_sTitle), "%T", "ListMenu_Option_Empty", client);
2569 AddMenuItem(_hMenu, "0", _sTitle, ITEMDRAW_DISABLED);
2570 }
2571
2572 DisplayMenuAtItem(_hMenu, client, index, MENU_TIME_FOREVER);
2573}
2574
2575public MenuHandler_MenuList(Handle:menu, MenuAction:action, param1, param2)
2576{
2577 switch(action)
2578 {
2579 case MenuAction_End:
2580 CloseHandle(menu);
2581 case MenuAction_Cancel:
2582 {
2583 if(!g_iPeskyPanels[param1][viewingList])
2584 if(param2 == MenuCancel_ExitBack && g_hTopMenu != INVALID_HANDLE)
2585 DisplayTopMenu(g_hTopMenu, param1, TopMenuPosition_LastCategory);
2586 }
2587 case MenuAction_Select:
2588 {
2589 decl String:_sOption[32];
2590 GetMenuItem(menu, param2, _sOption, sizeof(_sOption));
2591 new target = GetClientOfUserId(StringToInt(_sOption));
2592
2593 if(Bool_ValidMenuTarget(param1, target, false))
2594 AdminMenu_ListTarget(param1, target, GetMenuSelectionPosition());
2595 else
2596 AdminMenu_List(param1, GetMenuSelectionPosition());
2597 }
2598 }
2599}
2600
2601AdminMenu_ListTarget(client, target, index, viewMute = 0, viewGag = 0)
2602{
2603 new userid = GetClientUserId(target), Handle:_hMenu = CreateMenu(MenuHandler_MenuListTarget);
2604 decl String:_sBuffer[192], String:_sOption[32];
2605 SetMenuTitle(_hMenu, g_sName[target]);
2606 SetMenuPagination(_hMenu, MENU_NO_PAGINATION);
2607 SetMenuExitButton(_hMenu, true);
2608 SetMenuExitBackButton(_hMenu, true);
2609
2610 if(g_bTempMuted[target] || g_iMuteType[target])
2611 {
2612 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Mute", client);
2613 Format(_sOption, sizeof(_sOption), "0 %d %d %b %b", userid, index, viewMute, viewGag);
2614 AddMenuItem(_hMenu, _sOption, _sBuffer);
2615
2616 if(viewMute)
2617 {
2618 if(g_iMuteType[target])
2619 {
2620 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Admin", client, g_sMuteAdmin[target]);
2621 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2622 }
2623 else
2624 {
2625 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Admin", client, g_sTempMuted[target]);
2626 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2627 }
2628
2629 decl String:_sMuteTemp[192], String:_sMuteTime[192];
2630 Format(_sMuteTemp, sizeof(_sMuteTemp), "%T", "ListMenu_Option_Duration", client);
2631 if(g_iMuteType[target] & COMM_MUTE_PERM)
2632 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, "ListMenu_Option_Duration_Perm", client);
2633 else if(g_iMuteType[target] & COMM_MUTE_TIME)
2634 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, "ListMenu_Option_Duration_Time", client, (g_iMuteLength[target] / 60));
2635 else
2636 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, "ListMenu_Option_Duration_Temp", client);
2637 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2638
2639 if(g_iMuteType[target])
2640 {
2641 FormatTime(_sMuteTime, sizeof(_sMuteTime), g_bNullTime ? NULL_STRING : g_sTimeFormat, g_iMuteTime[target]);
2642 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Issue", client, _sMuteTime);
2643 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2644 }
2645
2646 Format(_sMuteTemp, sizeof(_sMuteTemp), "%T", "ListMenu_Option_Expire", client);
2647 if(g_iMuteType[target] & COMM_MUTE_PERM)
2648 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, "ListMenu_Option_Expire_Perm", client);
2649 else if(g_iMuteType[target] & COMM_MUTE_TIME)
2650 {
2651 FormatTime(_sMuteTime, sizeof(_sMuteTime), g_bNullTime ? NULL_STRING : g_sTimeFormat, (g_iMuteTime[target] + g_iMuteLength[target]));
2652 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, "ListMenu_Option_Expire_Time", client, _sMuteTime);
2653 }
2654 else
2655 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sMuteTemp, g_bTemporary ? "ListMenu_Option_Expire_Temp" : "ListMenu_Option_Expire_Temp_Reconnect", client);
2656 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2657
2658 if(g_iMuteType[target])
2659 {
2660 if(strlen(g_sMuteReason[target]) > 0)
2661 {
2662 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Reason", client);
2663 Format(_sOption, sizeof(_sOption), "1 %d %d %b %b", userid, index, viewMute, viewGag);
2664 AddMenuItem(_hMenu, _sOption, _sBuffer);
2665 }
2666 else
2667 {
2668 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Reason_None", client);
2669 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2670 }
2671 }
2672 }
2673 }
2674
2675 if(g_bTempGagged[target] || g_iGagType[target])
2676 {
2677 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Gag", client);
2678 Format(_sOption, sizeof(_sOption), "2 %d %d %b %b", userid, index, viewMute, viewGag);
2679 AddMenuItem(_hMenu, _sOption, _sBuffer);
2680
2681 if(viewGag)
2682 {
2683 if(g_iGagType[target])
2684 {
2685 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Admin", client, g_sGagAdmin[target]);
2686 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2687 }
2688 else
2689 {
2690 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Admin", client, g_sTempGagged[target]);
2691 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2692 }
2693
2694 decl String:_sGagTemp[192], String:_sGagTime[192];
2695 Format(_sGagTemp, sizeof(_sGagTemp), "%T", "ListMenu_Option_Duration", client);
2696 if(g_iGagType[target] & COMM_GAG_PERM)
2697 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, "ListMenu_Option_Duration_Perm", client);
2698 else if(g_iGagType[target] & COMM_GAG_TIME)
2699 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, "ListMenu_Option_Duration_Time", client, (g_iGagLength[target] / 60));
2700 else
2701 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, "ListMenu_Option_Duration_Temp", client);
2702 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2703
2704 if(g_iGagType[target])
2705 {
2706 FormatTime(_sGagTime, sizeof(_sGagTime), g_bNullTime ? NULL_STRING : g_sTimeFormat, g_iGagTime[target]);
2707 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Issue", client, _sGagTime);
2708 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2709 }
2710
2711 Format(_sGagTemp, sizeof(_sGagTemp), "%T", "ListMenu_Option_Expire", client);
2712 if(g_iGagType[target] & COMM_GAG_PERM)
2713 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, "ListMenu_Option_Expire_Perm", client);
2714 else if(g_iGagType[target] & COMM_GAG_TIME)
2715 {
2716 FormatTime(_sGagTime, sizeof(_sGagTime), g_bNullTime ? NULL_STRING : g_sTimeFormat, (g_iGagTime[target] + g_iGagLength[target]));
2717 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, "ListMenu_Option_Expire_Time", client, _sGagTime);
2718 }
2719 else
2720 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sGagTemp, g_bTemporary ? "ListMenu_Option_Expire_Temp" : "ListMenu_Option_Expire_Temp_Reconnect", client);
2721 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2722
2723 if(g_iGagType[target])
2724 {
2725 if(strlen(g_sGagReason[target]) > 0)
2726 {
2727 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Reason", client);
2728 Format(_sOption, sizeof(_sOption), "3 %d %d %b %b", userid, index, viewMute, viewGag);
2729 AddMenuItem(_hMenu, _sOption, _sBuffer);
2730 }
2731 else
2732 {
2733 Format(_sBuffer, sizeof(_sBuffer), "%T", "ListMenu_Option_Reason_None", client);
2734 AddMenuItem(_hMenu, "", _sBuffer, ITEMDRAW_DISABLED);
2735 }
2736 }
2737 }
2738 }
2739
2740 g_iPeskyPanels[client][curIndex] = index;
2741 g_iPeskyPanels[client][curTarget] = target;
2742 g_iPeskyPanels[client][viewingGag] = viewGag;
2743 g_iPeskyPanels[client][viewingMute] = viewMute;
2744 SetMenuExitButton(_hMenu, true);
2745 DisplayMenu(_hMenu, client, MENU_TIME_FOREVER);
2746}
2747
2748public MenuHandler_MenuListTarget(Handle:menu, MenuAction:action, param1, param2)
2749{
2750 switch(action)
2751 {
2752 case MenuAction_End:
2753 CloseHandle(menu);
2754 case MenuAction_Cancel:
2755 {
2756 if(param2 == MenuCancel_ExitBack)
2757 AdminMenu_List(param1, g_iPeskyPanels[param1][curIndex]);
2758 }
2759 case MenuAction_Select:
2760 {
2761 decl String:_sOption[64], String:_sTemp[5][8];
2762 GetMenuItem(menu, param2, _sOption, sizeof(_sOption));
2763 ExplodeString(_sOption, " ", _sTemp, 5, 8);
2764
2765 new target = GetClientOfUserId(StringToInt(_sTemp[1]));
2766 if(Bool_ValidMenuTarget(param1, target, false))
2767 {
2768 switch(StringToInt(_sTemp[0]))
2769 {
2770 case 0:
2771 AdminMenu_ListTarget(param1, target, StringToInt(_sTemp[2]), !(StringToInt(_sTemp[3])), 0);
2772 case 1, 3:
2773 AdminMenu_ListTargetReason(param1, target, g_iPeskyPanels[param1][viewingMute], g_iPeskyPanels[param1][viewingGag]);
2774 case 2:
2775 AdminMenu_ListTarget(param1, target, StringToInt(_sTemp[2]), 0, !(StringToInt(_sTemp[4])));
2776 }
2777 }
2778 else
2779 AdminMenu_List(param1, StringToInt(_sTemp[2]));
2780
2781 }
2782 }
2783}
2784
2785AdminMenu_ListTargetReason(client, target, showMute, showGag)
2786{
2787 decl String:_sTemp[192], String:_sBuffer[192];
2788 new Handle:_hPanel = CreatePanel();
2789 SetPanelTitle(_hPanel, g_sName[target]);
2790 DrawPanelItem(_hPanel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
2791
2792 if(showMute)
2793 {
2794 Format(_sTemp, sizeof(_sTemp), "%T", "ReasonPanel_Punishment_Mute", client);
2795 if(g_iMuteType[target] & COMM_MUTE_PERM)
2796 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Perm", client);
2797 else if(g_iMuteType[target] & COMM_MUTE_TIME)
2798 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Time", client, (g_iMuteLength[target] / 60));
2799 else
2800 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Temp", client);
2801 DrawPanelText(_hPanel, _sBuffer);
2802
2803 Format(_sBuffer, sizeof(_sBuffer), "%T", "ReasonPanel_Reason", client, g_sMuteReason[target]);
2804 DrawPanelText(_hPanel, _sBuffer);
2805 }
2806 else if(showGag)
2807 {
2808 Format(_sTemp, sizeof(_sTemp), "%T", "ReasonPanel_Punishment_Gag", client);
2809 if(g_iGagType[target] & COMM_GAG_PERM)
2810 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Perm", client);
2811 else if(g_iGagType[target] & COMM_GAG_TIME)
2812 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Time", client, (g_iGagLength[target] / 60));
2813 else
2814 Format(_sBuffer, sizeof(_sBuffer), "%s%T", _sTemp, "ReasonPanel_Temp", client);
2815 DrawPanelText(_hPanel, _sBuffer);
2816
2817 Format(_sBuffer, sizeof(_sBuffer), "%T", "ReasonPanel_Reason", client, g_sGagReason[target]);
2818 DrawPanelText(_hPanel, _sBuffer);
2819 }
2820
2821 DrawPanelItem(_hPanel, " ", ITEMDRAW_SPACER|ITEMDRAW_RAWLINE);
2822 SetPanelCurrentKey(_hPanel, 9);
2823 DrawPanelItem(_hPanel, "Kilépés");
2824 SendPanelToClient(_hPanel, client, PanelHandler_ListTargetReason, MENU_TIME_FOREVER);
2825 CloseHandle(_hPanel);
2826}
2827
2828public PanelHandler_ListTargetReason(Handle:menu, MenuAction:action, param1, param2)
2829{
2830 switch(action)
2831 {
2832 case MenuAction_Select:
2833 {
2834 AdminMenu_ListTarget(param1, g_iPeskyPanels[param1][curTarget], g_iPeskyPanels[param1][curIndex], g_iPeskyPanels[param1][viewingMute], g_iPeskyPanels[param1][viewingGag]);
2835 }
2836 }
2837}