1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/basecomm/gag.sp Sat Oct 13 04:43:42 2007 +0000
1.3 @@ -0,0 +1,443 @@
1.4 +enum CommType
1.5 +{
1.6 + CommType_Mute,
1.7 + CommType_UnMute,
1.8 + CommType_Gag,
1.9 + CommType_UnGag,
1.10 + CommType_Silence,
1.11 + CommType_UnSilence
1.12 +
1.13 +};
1.14 +
1.15 +DisplayGagTypesMenu(client)
1.16 +{
1.17 + new Handle:menu = CreateMenu(MenuHandler_GagTypes);
1.18 +
1.19 + decl String:title[100];
1.20 + Format(title, sizeof(title), "%T:", "Choose Type", client);
1.21 + SetMenuTitle(menu, title);
1.22 + SetMenuExitBackButton(menu, true);
1.23 +
1.24 + new target = g_GagTarget[client];
1.25 +
1.26 + if (!g_Muted[target])
1.27 + {
1.28 + AddMenuItem(menu, "0", "Mute Player");
1.29 + }
1.30 + else
1.31 + {
1.32 + AddMenuItem(menu, "1", "UnMute Player");
1.33 + }
1.34 +
1.35 + if (!g_Gagged[target])
1.36 + {
1.37 + AddMenuItem(menu, "2", "Gag Player");
1.38 + }
1.39 + else
1.40 + {
1.41 + AddMenuItem(menu, "3", "UnGag Player");
1.42 + }
1.43 +
1.44 + if (!g_Muted[target] || !g_Gagged[target])
1.45 + {
1.46 + AddMenuItem(menu, "4", "Silence Player");
1.47 + }
1.48 + else
1.49 + {
1.50 + AddMenuItem(menu, "5", "UnSilence Player");
1.51 + }
1.52 +
1.53 + DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.54 +}
1.55 +
1.56 +DisplayGagPlayerMenu(client)
1.57 +{
1.58 + new Handle:menu = CreateMenu(MenuHandler_GagPlayer);
1.59 +
1.60 + decl String:title[100];
1.61 + Format(title, sizeof(title), "%T:", "Gag/Mute Player", client);
1.62 + SetMenuTitle(menu, title);
1.63 + SetMenuExitBackButton(menu, true);
1.64 +
1.65 + AddTargetsToMenu(menu, client, false);
1.66 +
1.67 + DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.68 +}
1.69 +
1.70 +public AdminMenu_Gag(Handle:topmenu,
1.71 + TopMenuAction:action,
1.72 + TopMenuObject:object_id,
1.73 + param,
1.74 + String:buffer[],
1.75 + maxlength)
1.76 +{
1.77 + if (action == TopMenuAction_DisplayOption)
1.78 + {
1.79 + Format(buffer, maxlength, "%T", "Gag/Mute Player", param);
1.80 + }
1.81 + else if (action == TopMenuAction_SelectOption)
1.82 + {
1.83 + DisplayGagPlayerMenu(param);
1.84 + }
1.85 +}
1.86 +
1.87 +public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2)
1.88 +{
1.89 + if (action == MenuAction_End)
1.90 + {
1.91 + CloseHandle(menu);
1.92 + }
1.93 + else if (action == MenuAction_Cancel)
1.94 + {
1.95 + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.96 + {
1.97 + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.98 + }
1.99 + }
1.100 + else if (action == MenuAction_Select)
1.101 + {
1.102 + decl String:info[32];
1.103 + new userid, target;
1.104 +
1.105 + GetMenuItem(menu, param2, info, sizeof(info));
1.106 + userid = StringToInt(info);
1.107 +
1.108 + if ((target = GetClientOfUserId(userid)) == 0)
1.109 + {
1.110 + PrintToChat(param1, "[SM] %t", "Player no longer available");
1.111 + }
1.112 + else if (!CanUserTarget(param1, target))
1.113 + {
1.114 + PrintToChat(param1, "[SM] %t", "Unable to target");
1.115 + }
1.116 + else
1.117 + {
1.118 + g_GagTarget[param1] = GetClientOfUserId(userid);
1.119 + DisplayGagTypesMenu(param1);
1.120 + }
1.121 + }
1.122 +}
1.123 +
1.124 +public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2)
1.125 +{
1.126 + if (action == MenuAction_End)
1.127 + {
1.128 + CloseHandle(menu);
1.129 + }
1.130 + else if (action == MenuAction_Cancel)
1.131 + {
1.132 + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.133 + {
1.134 + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.135 + }
1.136 + }
1.137 + else if (action == MenuAction_Select)
1.138 + {
1.139 + decl String:info[32];
1.140 + new CommType:type;
1.141 +
1.142 + GetMenuItem(menu, param2, info, sizeof(info));
1.143 + type = CommType:StringToInt(info);
1.144 +
1.145 + switch (type)
1.146 + {
1.147 + case CommType_Mute: PerformMute(param1, g_GagTarget[param1]);
1.148 + case CommType_UnMute: PerformUnMute(param1, g_GagTarget[param1]);
1.149 + case CommType_Gag: PerformGag(param1, g_GagTarget[param1]);
1.150 + case CommType_UnGag: PerformUnGag(param1, g_GagTarget[param1]);
1.151 + case CommType_Silence: PerformSilence(param1, g_GagTarget[param1]);
1.152 + case CommType_UnSilence: PerformUnSilence(param1, g_GagTarget[param1]);
1.153 + }
1.154 + }
1.155 +}
1.156 +
1.157 +PerformMute(client, target)
1.158 +{
1.159 + if (g_Muted[target])
1.160 + {
1.161 + ReplyToCommand(client, "%t", "Already Muted");
1.162 + return;
1.163 + }
1.164 +
1.165 + g_Muted[target] = true;
1.166 + SetClientListeningFlags(target, VOICE_MUTED);
1.167 +
1.168 + decl String:name[64];
1.169 + GetClientName(target, name, sizeof(name));
1.170 +
1.171 + ShowActivity(client, "%t", "Player Muted", name);
1.172 + ReplyToCommand(client, "%t", "Player Muted", name);
1.173 + LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
1.174 +}
1.175 +
1.176 +PerformUnMute(client, target)
1.177 +{
1.178 + if (!g_Muted[target])
1.179 + {
1.180 + ReplyToCommand(client, "%t", "Player Not Muted");
1.181 + return;
1.182 + }
1.183 +
1.184 + g_Muted[target] = false;
1.185 + if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
1.186 + {
1.187 + SetClientListeningFlags(target, VOICE_LISTENALL);
1.188 + }
1.189 + else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
1.190 + {
1.191 + SetClientListeningFlags(target, VOICE_TEAM);
1.192 + }
1.193 + else
1.194 + {
1.195 + SetClientListeningFlags(target, VOICE_NORMAL);
1.196 + }
1.197 +
1.198 + decl String:name[64];
1.199 + GetClientName(target, name, sizeof(name));
1.200 +
1.201 + ShowActivity(client, "%t", "Player Unmuted", name);
1.202 + ReplyToCommand(client, "%t", "Player Unmuted", name);
1.203 + LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
1.204 +}
1.205 +
1.206 +PerformGag(client, target)
1.207 +{
1.208 + if (g_Gagged[target])
1.209 + {
1.210 + ReplyToCommand(client, "%t", "Already Gagged");
1.211 + return;
1.212 + }
1.213 +
1.214 + g_Gagged[target] = true;
1.215 +
1.216 + decl String:name[64];
1.217 + GetClientName(target, name, sizeof(name));
1.218 +
1.219 + ShowActivity(client, "%t", "Player Gagged", name);
1.220 + ReplyToCommand(client, "%t", "Player Gagged", name);
1.221 + LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
1.222 +}
1.223 +
1.224 +PerformUnGag(client, target)
1.225 +{
1.226 + if (!g_Gagged[target])
1.227 + {
1.228 + ReplyToCommand(client, "%t", "Player Not Gagged");
1.229 + return;
1.230 + }
1.231 +
1.232 + g_Gagged[target] = false;
1.233 +
1.234 + decl String:name[64];
1.235 + GetClientName(target, name, sizeof(name));
1.236 +
1.237 + ShowActivity(client, "%t", "Player Ungagged", name);
1.238 + ReplyToCommand(client, "%t", "Player Ungagged", name);
1.239 + LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
1.240 +}
1.241 +
1.242 +PerformSilence(client, target)
1.243 +{
1.244 + if (g_Gagged[target] && g_Muted[target])
1.245 + {
1.246 + ReplyToCommand(client, "%t", "Already Silenced");
1.247 + return;
1.248 + }
1.249 +
1.250 + decl String:name[64];
1.251 + GetClientName(target, name, sizeof(name));
1.252 +
1.253 + if (!g_Gagged[target])
1.254 + {
1.255 + g_Gagged[target] = true;
1.256 +
1.257 + ShowActivity(client, "%t", "Player Gagged", name);
1.258 + ReplyToCommand(client, "%t", "Player Gagged", name);
1.259 + LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
1.260 + }
1.261 +
1.262 + if (!g_Muted[target])
1.263 + {
1.264 + g_Muted[target] = true;
1.265 + SetClientListeningFlags(target, VOICE_MUTED);
1.266 +
1.267 + ShowActivity(client, "%t", "Player Muted", name);
1.268 + ReplyToCommand(client, "%t", "Player Muted", name);
1.269 + LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
1.270 + }
1.271 +}
1.272 +
1.273 +PerformUnSilence(client, target)
1.274 +{
1.275 + if (!g_Gagged[target] && !g_Muted[target])
1.276 + {
1.277 + ReplyToCommand(client, "%t", "Player Not Silenced");
1.278 + return;
1.279 + }
1.280 +
1.281 + decl String:name[64];
1.282 + GetClientName(target, name, sizeof(name));
1.283 +
1.284 + if (g_Gagged[target])
1.285 + {
1.286 + g_Gagged[target] = false;
1.287 +
1.288 + ShowActivity(client, "%t", "Player Ungagged", name);
1.289 + ReplyToCommand(client, "%t", "Player Ungagged", name);
1.290 + LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
1.291 + }
1.292 +
1.293 + if (g_Muted[target])
1.294 + {
1.295 + g_Muted[target] = false;
1.296 +
1.297 + if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
1.298 + {
1.299 + SetClientListeningFlags(target, VOICE_LISTENALL);
1.300 + }
1.301 + else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
1.302 + {
1.303 + SetClientListeningFlags(target, VOICE_TEAM);
1.304 + }
1.305 + else
1.306 + {
1.307 + SetClientListeningFlags(target, VOICE_NORMAL);
1.308 + }
1.309 +
1.310 + ShowActivity(client, "%t", "Player Unmuted", name);
1.311 + ReplyToCommand(client, "%t", "Player Unmuted", name);
1.312 + LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
1.313 + }
1.314 +}
1.315 +
1.316 +public Action:Command_Mute(client, args)
1.317 +{
1.318 + if (args < 1)
1.319 + {
1.320 + ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
1.321 + return Plugin_Handled;
1.322 + }
1.323 +
1.324 + decl String:arg[64];
1.325 + GetCmdArg(1, arg, sizeof(arg));
1.326 +
1.327 + new target = FindTarget(client, arg);
1.328 + if (target == -1)
1.329 + {
1.330 + return Plugin_Handled;
1.331 + }
1.332 +
1.333 + PerformMute(client, target);
1.334 +
1.335 + return Plugin_Handled;
1.336 +}
1.337 +
1.338 +public Action:Command_Gag(client, args)
1.339 +{
1.340 + if (args < 1)
1.341 + {
1.342 + ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
1.343 + return Plugin_Handled;
1.344 + }
1.345 +
1.346 + decl String:arg[64];
1.347 + GetCmdArg(1, arg, sizeof(arg));
1.348 +
1.349 + new target = FindTarget(client, arg);
1.350 + if (target == -1)
1.351 + {
1.352 + return Plugin_Handled;
1.353 + }
1.354 +
1.355 + PerformGag(client, target);
1.356 +
1.357 + return Plugin_Handled;
1.358 +}
1.359 +
1.360 +public Action:Command_Silence(client, args)
1.361 +{
1.362 + if (args < 1)
1.363 + {
1.364 + ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
1.365 + return Plugin_Handled;
1.366 + }
1.367 +
1.368 + decl String:arg[64];
1.369 + GetCmdArg(1, arg, sizeof(arg));
1.370 +
1.371 + new target = FindTarget(client, arg);
1.372 + if (target == -1)
1.373 + {
1.374 + return Plugin_Handled;
1.375 + }
1.376 +
1.377 + PerformSilence(client, target);
1.378 +
1.379 + return Plugin_Handled;
1.380 +}
1.381 +
1.382 +public Action:Command_Unmute(client, args)
1.383 +{
1.384 + if (args < 1)
1.385 + {
1.386 + ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
1.387 + return Plugin_Handled;
1.388 + }
1.389 +
1.390 + decl String:arg[64];
1.391 + GetCmdArg(1, arg, sizeof(arg));
1.392 +
1.393 + new target = FindTarget(client, arg);
1.394 + if (target == -1)
1.395 + {
1.396 + return Plugin_Handled;
1.397 + }
1.398 +
1.399 + PerformUnMute(client, target);
1.400 +
1.401 + return Plugin_Handled;
1.402 +}
1.403 +
1.404 +public Action:Command_Ungag(client, args)
1.405 +{
1.406 + if (args < 1)
1.407 + {
1.408 + ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
1.409 + return Plugin_Handled;
1.410 + }
1.411 +
1.412 + decl String:arg[64];
1.413 + GetCmdArg(1, arg, sizeof(arg));
1.414 +
1.415 + new target = FindTarget(client, arg);
1.416 + if (target == -1)
1.417 + {
1.418 + return Plugin_Handled;
1.419 + }
1.420 +
1.421 + PerformUnGag(client, target);
1.422 +
1.423 + return Plugin_Handled;
1.424 +}
1.425 +
1.426 +public Action:Command_Unsilence(client, args)
1.427 +{
1.428 + if (args < 1)
1.429 + {
1.430 + ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
1.431 + return Plugin_Handled;
1.432 + }
1.433 +
1.434 + decl String:arg[64];
1.435 + GetCmdArg(1, arg, sizeof(arg));
1.436 +
1.437 + new target = FindTarget(client, arg);
1.438 + if (target == -1)
1.439 + {
1.440 + return Plugin_Handled;
1.441 + }
1.442 +
1.443 + PerformUnSilence(client, target);
1.444 +
1.445 + return Plugin_Handled;
1.446 +}
1.447 \ No newline at end of file