plugins/basecomm/gag.sp
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/plugins/basecomm/gag.sp	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,547 +0,0 @@
     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 -DisplayGagTypesMenu(client)
    1.15 -{
    1.16 -	new Handle:menu = CreateMenu(MenuHandler_GagTypes);
    1.17 -	
    1.18 -	decl String:title[100];
    1.19 -	Format(title, sizeof(title), "%T:", "Choose Type", client);
    1.20 -	SetMenuTitle(menu, title);
    1.21 -	SetMenuExitBackButton(menu, true);
    1.22 -	
    1.23 -	new target = g_GagTarget[client];
    1.24 -	
    1.25 -	if (!g_Muted[target])
    1.26 -	{
    1.27 -		AddMenuItem(menu, "0", "Mute Player");
    1.28 -	}
    1.29 -	else
    1.30 -	{
    1.31 -		AddMenuItem(menu, "1", "UnMute Player");
    1.32 -	}
    1.33 -	
    1.34 -	if (!g_Gagged[target])
    1.35 -	{
    1.36 -		AddMenuItem(menu, "2", "Gag Player");
    1.37 -	}
    1.38 -	else
    1.39 -	{
    1.40 -		AddMenuItem(menu, "3", "UnGag Player");
    1.41 -	}
    1.42 -	
    1.43 -	if (!g_Muted[target] || !g_Gagged[target])
    1.44 -	{
    1.45 -		AddMenuItem(menu, "4", "Silence Player");
    1.46 -	}
    1.47 -	else
    1.48 -	{
    1.49 -		AddMenuItem(menu, "5", "UnSilence Player");
    1.50 -	}
    1.51 -		
    1.52 -	DisplayMenu(menu, client, MENU_TIME_FOREVER);
    1.53 -}
    1.54 -
    1.55 -DisplayGagPlayerMenu(client)
    1.56 -{
    1.57 -	new Handle:menu = CreateMenu(MenuHandler_GagPlayer);
    1.58 -	
    1.59 -	decl String:title[100];
    1.60 -	Format(title, sizeof(title), "%T:", "Gag/Mute player", client);
    1.61 -	SetMenuTitle(menu, title);
    1.62 -	SetMenuExitBackButton(menu, true);
    1.63 -	
    1.64 -	AddTargetsToMenu(menu, client, true, false);
    1.65 -	
    1.66 -	DisplayMenu(menu, client, MENU_TIME_FOREVER);
    1.67 -}
    1.68 -
    1.69 -public AdminMenu_Gag(Handle:topmenu, 
    1.70 -					  TopMenuAction:action,
    1.71 -					  TopMenuObject:object_id,
    1.72 -					  param,
    1.73 -					  String:buffer[],
    1.74 -					  maxlength)
    1.75 -{
    1.76 -	if (action == TopMenuAction_DisplayOption)
    1.77 -	{
    1.78 -		Format(buffer, maxlength, "%T", "Gag/Mute player", param);
    1.79 -	}
    1.80 -	else if (action == TopMenuAction_SelectOption)
    1.81 -	{
    1.82 -		DisplayGagPlayerMenu(param);
    1.83 -	}
    1.84 -}
    1.85 -
    1.86 -public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2)
    1.87 -{
    1.88 -	if (action == MenuAction_End)
    1.89 -	{
    1.90 -		CloseHandle(menu);
    1.91 -	}
    1.92 -	else if (action == MenuAction_Cancel)
    1.93 -	{
    1.94 -		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
    1.95 -		{
    1.96 -			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
    1.97 -		}
    1.98 -	}
    1.99 -	else if (action == MenuAction_Select)
   1.100 -	{
   1.101 -		decl String:info[32];
   1.102 -		new userid, target;
   1.103 -		
   1.104 -		GetMenuItem(menu, param2, info, sizeof(info));
   1.105 -		userid = StringToInt(info);
   1.106 -
   1.107 -		if ((target = GetClientOfUserId(userid)) == 0)
   1.108 -		{
   1.109 -			PrintToChat(param1, "[SM] %t", "Player no longer available");
   1.110 -		}
   1.111 -		else if (!CanUserTarget(param1, target))
   1.112 -		{
   1.113 -			PrintToChat(param1, "[SM] %t", "Unable to target");
   1.114 -		}
   1.115 -		else
   1.116 -		{
   1.117 -			g_GagTarget[param1] = GetClientOfUserId(userid);
   1.118 -			DisplayGagTypesMenu(param1);
   1.119 -		}
   1.120 -	}
   1.121 -}
   1.122 -
   1.123 -public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2)
   1.124 -{
   1.125 -	if (action == MenuAction_End)
   1.126 -	{
   1.127 -		CloseHandle(menu);
   1.128 -	}
   1.129 -	else if (action == MenuAction_Cancel)
   1.130 -	{
   1.131 -		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
   1.132 -		{
   1.133 -			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
   1.134 -		}
   1.135 -	}
   1.136 -	else if (action == MenuAction_Select)
   1.137 -	{
   1.138 -		decl String:info[32];
   1.139 -		new CommType:type;
   1.140 -		
   1.141 -		GetMenuItem(menu, param2, info, sizeof(info));
   1.142 -		type = CommType:StringToInt(info);
   1.143 -		
   1.144 -		decl String:name[MAX_NAME_LENGTH];
   1.145 -		GetClientName(g_GagTarget[param1], name, sizeof(name));
   1.146 -
   1.147 -		switch (type)
   1.148 -		{
   1.149 -			case CommType_Mute:
   1.150 -			{
   1.151 -				PerformMute(param1, g_GagTarget[param1]);
   1.152 -				ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
   1.153 -			}
   1.154 -			case CommType_UnMute:
   1.155 -			{
   1.156 -				PerformUnMute(param1, g_GagTarget[param1]);
   1.157 -				ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
   1.158 -			}
   1.159 -			case CommType_Gag:
   1.160 -			{
   1.161 -				PerformGag(param1, g_GagTarget[param1]);
   1.162 -				ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
   1.163 -			}
   1.164 -			case CommType_UnGag:
   1.165 -			{
   1.166 -				PerformUnGag(param1, g_GagTarget[param1]);
   1.167 -				ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
   1.168 -			}
   1.169 -			case CommType_Silence:
   1.170 -			{
   1.171 -				PerformSilence(param1, g_GagTarget[param1]);
   1.172 -				ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
   1.173 -			}
   1.174 -			case CommType_UnSilence:
   1.175 -			{
   1.176 -				PerformUnSilence(param1, g_GagTarget[param1]);
   1.177 -				ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
   1.178 -			}
   1.179 -		}
   1.180 -	}
   1.181 -}
   1.182 -
   1.183 -PerformMute(client, target)
   1.184 -{
   1.185 -	g_Muted[target] = true;
   1.186 -	SetClientListeningFlags(target, VOICE_MUTED);	
   1.187 -	LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
   1.188 -}
   1.189 -
   1.190 -PerformUnMute(client, target)
   1.191 -{
   1.192 -	g_Muted[target] = false;
   1.193 -	if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
   1.194 -	{
   1.195 -		SetClientListeningFlags(target, VOICE_LISTENALL);
   1.196 -	}
   1.197 -	else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
   1.198 -	{
   1.199 -		SetClientListeningFlags(target, VOICE_TEAM);
   1.200 -	}
   1.201 -	else
   1.202 -	{
   1.203 -		SetClientListeningFlags(target, VOICE_NORMAL);
   1.204 -	}
   1.205 -	
   1.206 -	LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
   1.207 -}
   1.208 -
   1.209 -PerformGag(client, target)
   1.210 -{
   1.211 -	g_Gagged[target] = true;
   1.212 -	LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
   1.213 -}
   1.214 -
   1.215 -PerformUnGag(client, target)
   1.216 -{
   1.217 -	g_Gagged[target] = false;
   1.218 -	LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
   1.219 -}
   1.220 -
   1.221 -PerformSilence(client, target)
   1.222 -{
   1.223 -	if (!g_Gagged[target])
   1.224 -	{
   1.225 -		g_Gagged[target] = true;
   1.226 -	}
   1.227 -	
   1.228 -	if (!g_Muted[target])
   1.229 -	{
   1.230 -		g_Muted[target] = true;
   1.231 -		SetClientListeningFlags(target, VOICE_MUTED);
   1.232 -	}
   1.233 -	
   1.234 -	LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
   1.235 -}
   1.236 -
   1.237 -PerformUnSilence(client, target)
   1.238 -{
   1.239 -	if (g_Gagged[target])
   1.240 -	{
   1.241 -		g_Gagged[target] = false;
   1.242 -	}
   1.243 -	
   1.244 -	if (g_Muted[target])
   1.245 -	{
   1.246 -		g_Muted[target] = false;
   1.247 -		
   1.248 -		if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
   1.249 -		{
   1.250 -			SetClientListeningFlags(target, VOICE_LISTENALL);
   1.251 -		}
   1.252 -		else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
   1.253 -		{
   1.254 -			SetClientListeningFlags(target, VOICE_TEAM);
   1.255 -		}
   1.256 -		else
   1.257 -		{
   1.258 -			SetClientListeningFlags(target, VOICE_NORMAL);
   1.259 -		}	
   1.260 -	}
   1.261 -	
   1.262 -	LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
   1.263 -}
   1.264 -
   1.265 -public Action:Command_Mute(client, args)
   1.266 -{	
   1.267 -	if (args < 1)
   1.268 -	{
   1.269 -		ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
   1.270 -		return Plugin_Handled;
   1.271 -	}
   1.272 -	
   1.273 -	decl String:arg[64];
   1.274 -	GetCmdArg(1, arg, sizeof(arg));
   1.275 -	
   1.276 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.277 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.278 -	
   1.279 -	if ((target_count = ProcessTargetString(
   1.280 -			arg,
   1.281 -			client, 
   1.282 -			target_list, 
   1.283 -			MAXPLAYERS, 
   1.284 -			0,
   1.285 -			target_name,
   1.286 -			sizeof(target_name),
   1.287 -			tn_is_ml)) <= 0)
   1.288 -	{
   1.289 -		ReplyToTargetError(client, target_count);
   1.290 -		return Plugin_Handled;
   1.291 -	}
   1.292 -
   1.293 -	for (new i = 0; i < target_count; i++)
   1.294 -	{
   1.295 -		new target = target_list[i];
   1.296 -		
   1.297 -		PerformMute(client, target);
   1.298 -	}
   1.299 -	
   1.300 -	if (tn_is_ml)
   1.301 -	{
   1.302 -		ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
   1.303 -	}
   1.304 -	else
   1.305 -	{
   1.306 -		ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
   1.307 -	}
   1.308 -	
   1.309 -	return Plugin_Handled;	
   1.310 -}
   1.311 -
   1.312 -public Action:Command_Gag(client, args)
   1.313 -{	
   1.314 -	if (args < 1)
   1.315 -	{
   1.316 -		ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
   1.317 -		return Plugin_Handled;
   1.318 -	}
   1.319 -	
   1.320 -	decl String:arg[64];
   1.321 -	GetCmdArg(1, arg, sizeof(arg));
   1.322 -	
   1.323 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.324 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.325 -	
   1.326 -	if ((target_count = ProcessTargetString(
   1.327 -			arg,
   1.328 -			client, 
   1.329 -			target_list, 
   1.330 -			MAXPLAYERS, 
   1.331 -			0,
   1.332 -			target_name,
   1.333 -			sizeof(target_name),
   1.334 -			tn_is_ml)) <= 0)
   1.335 -	{
   1.336 -		ReplyToTargetError(client, target_count);
   1.337 -		return Plugin_Handled;
   1.338 -	}
   1.339 -
   1.340 -	for (new i = 0; i < target_count; i++)
   1.341 -	{
   1.342 -		new target = target_list[i];
   1.343 -		
   1.344 -		PerformGag(client, target);
   1.345 -	}
   1.346 -	
   1.347 -	if (tn_is_ml)
   1.348 -	{
   1.349 -		ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
   1.350 -	}
   1.351 -	else
   1.352 -	{
   1.353 -		ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
   1.354 -	}
   1.355 -	
   1.356 -	return Plugin_Handled;	
   1.357 -}
   1.358 -
   1.359 -public Action:Command_Silence(client, args)
   1.360 -{	
   1.361 -	if (args < 1)
   1.362 -	{
   1.363 -		ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
   1.364 -		return Plugin_Handled;
   1.365 -	}
   1.366 -	
   1.367 -	decl String:arg[64];
   1.368 -	GetCmdArg(1, arg, sizeof(arg));
   1.369 -	
   1.370 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.371 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.372 -	
   1.373 -	if ((target_count = ProcessTargetString(
   1.374 -			arg,
   1.375 -			client, 
   1.376 -			target_list, 
   1.377 -			MAXPLAYERS, 
   1.378 -			0,
   1.379 -			target_name,
   1.380 -			sizeof(target_name),
   1.381 -			tn_is_ml)) <= 0)
   1.382 -	{
   1.383 -		ReplyToTargetError(client, target_count);
   1.384 -		return Plugin_Handled;
   1.385 -	}
   1.386 -
   1.387 -	for (new i = 0; i < target_count; i++)
   1.388 -	{
   1.389 -		new target = target_list[i];
   1.390 -		
   1.391 -		PerformSilence(client, target);
   1.392 -	}
   1.393 -	
   1.394 -	if (tn_is_ml)
   1.395 -	{
   1.396 -		ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
   1.397 -	}
   1.398 -	else
   1.399 -	{
   1.400 -		ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
   1.401 -	}
   1.402 -	
   1.403 -	return Plugin_Handled;	
   1.404 -}
   1.405 -
   1.406 -public Action:Command_Unmute(client, args)
   1.407 -{	
   1.408 -	if (args < 1)
   1.409 -	{
   1.410 -		ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
   1.411 -		return Plugin_Handled;
   1.412 -	}
   1.413 -	
   1.414 -	decl String:arg[64];
   1.415 -	GetCmdArg(1, arg, sizeof(arg));
   1.416 -	
   1.417 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.418 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.419 -	
   1.420 -	if ((target_count = ProcessTargetString(
   1.421 -			arg,
   1.422 -			client, 
   1.423 -			target_list, 
   1.424 -			MAXPLAYERS, 
   1.425 -			0,
   1.426 -			target_name,
   1.427 -			sizeof(target_name),
   1.428 -			tn_is_ml)) <= 0)
   1.429 -	{
   1.430 -		ReplyToTargetError(client, target_count);
   1.431 -		return Plugin_Handled;
   1.432 -	}
   1.433 -
   1.434 -	for (new i = 0; i < target_count; i++)
   1.435 -	{
   1.436 -		new target = target_list[i];
   1.437 -		
   1.438 -		if (!g_Muted[target])
   1.439 -		{
   1.440 -			continue;
   1.441 -		}
   1.442 -		
   1.443 -		PerformUnMute(client, target);
   1.444 -	}
   1.445 -	
   1.446 -	if (tn_is_ml)
   1.447 -	{
   1.448 -		ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
   1.449 -	}
   1.450 -	else
   1.451 -	{
   1.452 -		ShowActivity2(client, "[SM] ", "%t", "Unmuted target", "_s", target_name);
   1.453 -	}
   1.454 -	
   1.455 -	return Plugin_Handled;	
   1.456 -}
   1.457 -
   1.458 -public Action:Command_Ungag(client, args)
   1.459 -{	
   1.460 -	if (args < 1)
   1.461 -	{
   1.462 -		ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
   1.463 -		return Plugin_Handled;
   1.464 -	}
   1.465 -	
   1.466 -	decl String:arg[64];
   1.467 -	GetCmdArg(1, arg, sizeof(arg));
   1.468 -	
   1.469 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.470 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.471 -	
   1.472 -	if ((target_count = ProcessTargetString(
   1.473 -			arg,
   1.474 -			client, 
   1.475 -			target_list, 
   1.476 -			MAXPLAYERS, 
   1.477 -			0,
   1.478 -			target_name,
   1.479 -			sizeof(target_name),
   1.480 -			tn_is_ml)) <= 0)
   1.481 -	{
   1.482 -		ReplyToTargetError(client, target_count);
   1.483 -		return Plugin_Handled;
   1.484 -	}
   1.485 -
   1.486 -	for (new i = 0; i < target_count; i++)
   1.487 -	{
   1.488 -		new target = target_list[i];
   1.489 -		
   1.490 -		PerformUnGag(client, target);
   1.491 -	}
   1.492 -	
   1.493 -	if (tn_is_ml)
   1.494 -	{
   1.495 -		ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
   1.496 -	}
   1.497 -	else
   1.498 -	{
   1.499 -		ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
   1.500 -	}
   1.501 -	
   1.502 -	return Plugin_Handled;	
   1.503 -}
   1.504 -
   1.505 -public Action:Command_Unsilence(client, args)
   1.506 -{	
   1.507 -	if (args < 1)
   1.508 -	{
   1.509 -		ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
   1.510 -		return Plugin_Handled;
   1.511 -	}
   1.512 -	
   1.513 -	decl String:arg[64];
   1.514 -	GetCmdArg(1, arg, sizeof(arg));
   1.515 -	
   1.516 -	decl String:target_name[MAX_TARGET_LENGTH];
   1.517 -	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
   1.518 -	
   1.519 -	if ((target_count = ProcessTargetString(
   1.520 -			arg,
   1.521 -			client, 
   1.522 -			target_list, 
   1.523 -			MAXPLAYERS, 
   1.524 -			0,
   1.525 -			target_name,
   1.526 -			sizeof(target_name),
   1.527 -			tn_is_ml)) <= 0)
   1.528 -	{
   1.529 -		ReplyToTargetError(client, target_count);
   1.530 -		return Plugin_Handled;
   1.531 -	}
   1.532 -
   1.533 -	for (new i = 0; i < target_count; i++)
   1.534 -	{
   1.535 -		new target = target_list[i];
   1.536 -		
   1.537 -		PerformUnSilence(client, target);
   1.538 -	}
   1.539 -	
   1.540 -	if (tn_is_ml)
   1.541 -	{
   1.542 -		ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
   1.543 -	}
   1.544 -	else
   1.545 -	{
   1.546 -		ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
   1.547 -	}
   1.548 -	
   1.549 -	return Plugin_Handled;	
   1.550 -}