plugins/funcommands/ice.sp
author Scott Ehlert <ds@alliedmods.net>
Sun Mar 30 07:00:22 2008 +0000 (2008-03-30)
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod Basefuncommands Plugin
ds@1952
     5
 * Provides freeze and freezebomb functionality
ds@1952
     6
 *
ds@1952
     7
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     8
 * =============================================================================
ds@1952
     9
 *
ds@1952
    10
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
    11
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    12
 * Free Software Foundation.
ds@1952
    13
 * 
ds@1952
    14
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    17
 * details.
ds@1952
    18
 *
ds@1952
    19
 * You should have received a copy of the GNU General Public License along with
ds@1952
    20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    21
 *
ds@1952
    22
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    23
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    24
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    25
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    26
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    27
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    28
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    29
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    30
 *
ds@1952
    31
 * Version: $Id$
ds@1952
    32
 */
ds@1952
    33
ds@1952
    34
new Handle:g_FreezeTimers[MAXPLAYERS+1];
ds@1952
    35
new Handle:g_FreezeBombTimers[MAXPLAYERS+1];
ds@1952
    36
new g_FreezeTracker[MAXPLAYERS+1];
ds@1952
    37
new g_FreezeBombTracker[MAXPLAYERS+1];
ds@1952
    38
ds@1952
    39
new Handle:g_FreezeDuration = INVALID_HANDLE;
ds@1952
    40
new Handle:g_FreezeBombTicks = INVALID_HANDLE;
ds@1952
    41
new Handle:g_FreezeBombRadius = INVALID_HANDLE;
ds@1952
    42
new Handle:g_FreezeBombMode = INVALID_HANDLE;
ds@1952
    43
ds@1952
    44
SetupIce()
ds@1952
    45
{
ds@1952
    46
	RegAdminCmd("sm_freeze", Command_Freeze, ADMFLAG_SLAY, "sm_freeze <#userid|name> [time]");
ds@1952
    47
	RegAdminCmd("sm_freezebomb", Command_FreezeBomb, ADMFLAG_SLAY, "sm_freezebomb <#userid|name> [0/1]");
ds@1952
    48
ds@1952
    49
	g_FreezeDuration = CreateConVar("sm_freeze_duration", "10.0", "Sets the default duration for sm_freeze and freezebomb victims", 0, true, 1.0, true, 120.0);	
ds@1952
    50
	g_FreezeBombTicks = CreateConVar("sm_freezebomb_ticks", "10", "Sets how long the freezebomb fuse is.", 0, true, 5.0, true, 120.0);
ds@1952
    51
	g_FreezeBombRadius = CreateConVar("sm_freezebomb_radius", "600", "Sets the freezebomb blast radius.", 0, true, 50.0, true, 3000.0);
ds@1952
    52
	g_FreezeBombMode = CreateConVar("sm_freezebomb_mode", "0", "Who is targetted by the freezebomb? 0 = Target only, 1 = Target's team, 2 = Everyone", 0, true, 0.0, true, 2.0);
ds@1952
    53
}
ds@1952
    54
ds@1952
    55
FreezeClient(client, time)
ds@1952
    56
{
ds@1952
    57
	if (g_FreezeTimers[client] != INVALID_HANDLE)
ds@1952
    58
	{
ds@1952
    59
		UnfreezeClient(client);
ds@1952
    60
	}
ds@1952
    61
	
ds@1952
    62
	SetEntityMoveType(client, MOVETYPE_NONE);
ds@1952
    63
	SetEntityRenderColor(client, 0, 128, 255, 192);
ds@1952
    64
	
ds@1952
    65
	new Float:vec[3];
ds@1952
    66
	GetClientEyePosition(client, vec);
ds@1952
    67
	EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
ds@1952
    68
ds@1952
    69
	g_FreezeTimers[client] = CreateTimer(1.0, Timer_Freeze, client, TIMER_REPEAT);
ds@1952
    70
	g_FreezeTracker[client] = time;
ds@1952
    71
}
ds@1952
    72
ds@1952
    73
UnfreezeClient(client)
ds@1952
    74
{
ds@1952
    75
	KillFreezeTimer(client);
ds@1952
    76
ds@1952
    77
	new Float:vec[3];
ds@1952
    78
	GetClientAbsOrigin(client, vec);
ds@1952
    79
	vec[2] += 10;	
ds@1952
    80
	
ds@1952
    81
	GetClientEyePosition(client, vec);
ds@1952
    82
	EmitAmbientSound(SOUND_FREEZE, vec, client, SNDLEVEL_RAIDSIREN);
ds@1952
    83
ds@1952
    84
	SetEntityMoveType(client, MOVETYPE_WALK);
ds@1952
    85
	SetEntityRenderColor(client, 255, 255, 255, 255);	
ds@1952
    86
}
ds@1952
    87
ds@1952
    88
KillFreezeTimer(client)
ds@1952
    89
{
ds@1952
    90
	KillTimer(g_FreezeTimers[client]);
ds@1952
    91
	g_FreezeTimers[client] = INVALID_HANDLE;
ds@1952
    92
}
ds@1952
    93
ds@1952
    94
CreateFreezeBomb(client)
ds@1952
    95
{
ds@1952
    96
	g_FreezeBombTimers[client] = CreateTimer(1.0, Timer_FreezeBomb, client, TIMER_REPEAT);
ds@1952
    97
	g_FreezeBombTracker[client] = GetConVarInt(g_FreezeBombTicks);
ds@1952
    98
}
ds@1952
    99
ds@1952
   100
KillFreezeBomb(client)
ds@1952
   101
{
ds@1952
   102
	KillTimer(g_FreezeBombTimers[client]);
ds@1952
   103
	g_FreezeBombTimers[client] = INVALID_HANDLE;
ds@1952
   104
	
ds@1952
   105
	SetEntityRenderColor(client, 255, 255, 255, 255);
ds@1952
   106
}
ds@1952
   107
ds@1952
   108
KillAllFreezes()
ds@1952
   109
{
ds@1952
   110
	new maxclients = GetMaxClients();
ds@1952
   111
	for (new i = 1; i <= maxclients; i++)
ds@1952
   112
	{
ds@1952
   113
		if (g_FreezeTimers[i] != INVALID_HANDLE)
ds@1952
   114
		{
ds@1952
   115
			if(IsClientInGame(i))
ds@1952
   116
			{
ds@1952
   117
				UnfreezeClient(i);
ds@1952
   118
			}
ds@1952
   119
			else
ds@1952
   120
			{
ds@1952
   121
				KillFreezeTimer(i);
ds@1952
   122
			}			
ds@1952
   123
		}		
ds@1952
   124
		
ds@1952
   125
		if (g_FreezeBombTimers[i] != INVALID_HANDLE)
ds@1952
   126
		{
ds@1952
   127
			KillFreezeBomb(i);
ds@1952
   128
		}
ds@1952
   129
	}
ds@1952
   130
}
ds@1952
   131
ds@1952
   132
PerformFreeze(client, target, time)
ds@1952
   133
{
ds@1952
   134
	FreezeClient(target, time);
ds@1952
   135
	LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
ds@1952
   136
}
ds@1952
   137
ds@1952
   138
PerformFreezeBomb(client, target, toggle)
ds@1952
   139
{
ds@1952
   140
	switch (toggle)
ds@1952
   141
	{
ds@1952
   142
		case (2):
ds@1952
   143
		{
ds@1952
   144
			if (g_FreezeBombTimers[target] == INVALID_HANDLE)
ds@1952
   145
			{
ds@1952
   146
				CreateFreezeBomb(target);
ds@1952
   147
				LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
ds@1952
   148
			}
ds@1952
   149
			else
ds@1952
   150
			{
ds@1952
   151
				KillFreezeBomb(target);
ds@1952
   152
				LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
ds@1952
   153
			}
ds@1952
   154
		}
ds@1952
   155
ds@1952
   156
		case (1):
ds@1952
   157
		{
ds@1952
   158
			if (g_FreezeBombTimers[target] == INVALID_HANDLE)
ds@1952
   159
			{
ds@1952
   160
				CreateFreezeBomb(target);
ds@1952
   161
				LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
ds@1952
   162
			}
ds@1952
   163
		}
ds@1952
   164
		
ds@1952
   165
		case (0):
ds@1952
   166
		{
ds@1952
   167
			if (g_FreezeBombTimers[target] != INVALID_HANDLE)
ds@1952
   168
			{
ds@1952
   169
				KillFreezeBomb(target);
ds@1952
   170
				LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
ds@1952
   171
			}
ds@1952
   172
		}
ds@1952
   173
	}
ds@1952
   174
}
ds@1952
   175
ds@1952
   176
public Action:Timer_Freeze(Handle:timer, any:client)
ds@1952
   177
{
ds@1952
   178
	if (!IsClientInGame(client))
ds@1952
   179
	{
ds@1952
   180
		KillFreezeTimer(client);
ds@1952
   181
ds@1952
   182
		return Plugin_Handled;
ds@1952
   183
	}
ds@1952
   184
	
ds@1952
   185
	if (!IsPlayerAlive(client))
ds@1952
   186
	{
ds@1952
   187
		UnfreezeClient(client);
ds@1952
   188
		
ds@1952
   189
		return Plugin_Handled;
ds@1952
   190
	}		
ds@1952
   191
	
ds@1952
   192
	g_FreezeTracker[client]--;
ds@1952
   193
	
ds@1952
   194
	SetEntityMoveType(client, MOVETYPE_NONE);
ds@1952
   195
	SetEntityRenderColor(client, 0, 128, 255, 135);
ds@1952
   196
	
ds@1952
   197
	new Float:vec[3];
ds@1952
   198
	GetClientAbsOrigin(client, vec);
ds@1952
   199
	vec[2] += 10;
ds@1952
   200
	
ds@1952
   201
	TE_SetupGlowSprite(vec, g_GlowSprite, 0.95, 1.5, 50);
ds@1952
   202
	TE_SendToAll();	
ds@1952
   203
ds@1952
   204
	if (g_FreezeTracker[client] == 0)
ds@1952
   205
	{
ds@1952
   206
		UnfreezeClient(client);
ds@1952
   207
	}
ds@1952
   208
ds@1952
   209
	return Plugin_Handled;
ds@1952
   210
}
ds@1952
   211
ds@1952
   212
public Action:Timer_FreezeBomb(Handle:timer, any:client)
ds@1952
   213
{
ds@1952
   214
	if (!IsClientInGame(client) || !IsPlayerAlive(client))
ds@1952
   215
	{
ds@1952
   216
		KillFreezeBomb(client);
ds@1952
   217
ds@1952
   218
		return Plugin_Handled;
ds@1952
   219
	}
ds@1952
   220
	
ds@1952
   221
	g_FreezeBombTracker[client]--;
ds@1952
   222
	
ds@1952
   223
	new Float:vec[3];
ds@1952
   224
	GetClientEyePosition(client, vec);
ds@1952
   225
	
ds@1952
   226
	if (g_FreezeBombTracker[client] > 0)
ds@1952
   227
	{
ds@1952
   228
		new color;
ds@1952
   229
		
ds@1952
   230
		if (g_FreezeBombTracker[client] > 1)
ds@1952
   231
		{
ds@1952
   232
			color = RoundToFloor(g_FreezeBombTracker[client] * (255.0 / GetConVarFloat(g_FreezeBombTicks)));
ds@1952
   233
			EmitAmbientSound(SOUND_BEEP, vec, client, SNDLEVEL_RAIDSIREN);	
ds@1952
   234
		}
ds@1952
   235
		else
ds@1952
   236
		{
ds@1952
   237
			color = 0;
ds@1952
   238
			EmitAmbientSound(SOUND_FINAL, vec, client, SNDLEVEL_RAIDSIREN);
ds@1952
   239
		}
ds@1952
   240
		
ds@1952
   241
		SetEntityRenderColor(client, color, color, 255, 255);
ds@1952
   242
ds@1952
   243
		decl String:name[64];
ds@1952
   244
		GetClientName(client, name, sizeof(name));
ds@1952
   245
		PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTracker[client]);
ds@1952
   246
		
ds@1952
   247
		GetClientAbsOrigin(client, vec);
ds@1952
   248
		vec[2] += 10;
ds@1952
   249
ds@1952
   250
		TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
ds@1952
   251
		TE_SendToAll();
ds@1952
   252
		TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
ds@1952
   253
		TE_SendToAll();
ds@1952
   254
	}
ds@1952
   255
	else
ds@1952
   256
	{
ds@1952
   257
		TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_FreezeBombRadius), 5000);
ds@1952
   258
		TE_SendToAll();
ds@1952
   259
ds@1952
   260
		EmitAmbientSound(SOUND_BOOM, vec, client, SNDLEVEL_RAIDSIREN);
ds@1952
   261
ds@1952
   262
		KillFreezeBomb(client);
ds@1952
   263
		FreezeClient(client, GetConVarInt(g_FreezeDuration));
ds@1952
   264
		
ds@1952
   265
		if (GetConVarInt(g_FreezeBombMode) > 0)
ds@1952
   266
		{
ds@1952
   267
			new teamOnly = ((GetConVarInt(g_FreezeBombMode) == 1) ? true : false);
ds@1952
   268
			new maxClients = GetMaxClients();
ds@1952
   269
			
ds@1952
   270
			for (new i = 1; i < maxClients; i++)
ds@1952
   271
			{
ds@1952
   272
				if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
ds@1952
   273
				{
ds@1952
   274
					continue;
ds@1952
   275
				}
ds@1952
   276
				
ds@1952
   277
				if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
ds@1952
   278
				{
ds@1952
   279
					continue;
ds@1952
   280
				}
ds@1952
   281
				
ds@1952
   282
				new Float:pos[3];
ds@1952
   283
				GetClientEyePosition(i, pos);
ds@1952
   284
				
ds@1952
   285
				new Float:distance = GetVectorDistance(vec, pos);
ds@1952
   286
				
ds@1952
   287
				if (distance > GetConVarFloat(g_FreezeBombRadius))
ds@1952
   288
				{
ds@1952
   289
					continue;
ds@1952
   290
				}
ds@1952
   291
				
ds@1952
   292
				TE_SetupBeamPoints(vec, pos, g_BeamSprite2, g_HaloSprite, 0, 1, 0.7, 20.0, 50.0, 1, 1.5, blueColor, 10);
ds@1952
   293
				TE_SendToAll();
ds@1952
   294
				
ds@1952
   295
				FreezeClient(i, GetConVarInt(g_FreezeDuration));
ds@1952
   296
			}		
ds@1952
   297
		}
ds@1952
   298
	}
ds@1952
   299
			
ds@1952
   300
	return Plugin_Handled;
ds@1952
   301
}
ds@1952
   302
ds@1952
   303
public AdminMenu_Freeze(Handle:topmenu, 
ds@1952
   304
					  TopMenuAction:action,
ds@1952
   305
					  TopMenuObject:object_id,
ds@1952
   306
					  param,
ds@1952
   307
					  String:buffer[],
ds@1952
   308
					  maxlength)
ds@1952
   309
{
ds@1952
   310
	if (action == TopMenuAction_DisplayOption)
ds@1952
   311
	{
ds@1952
   312
		Format(buffer, maxlength, "%T", "Freeze player", param);
ds@1952
   313
	}
ds@1952
   314
	else if (action == TopMenuAction_SelectOption)
ds@1952
   315
	{
ds@1952
   316
		DisplayFreezeMenu(param);
ds@1952
   317
	}
ds@1952
   318
}
ds@1952
   319
ds@1952
   320
public AdminMenu_FreezeBomb(Handle:topmenu, 
ds@1952
   321
					  TopMenuAction:action,
ds@1952
   322
					  TopMenuObject:object_id,
ds@1952
   323
					  param,
ds@1952
   324
					  String:buffer[],
ds@1952
   325
					  maxlength)
ds@1952
   326
{
ds@1952
   327
	if (action == TopMenuAction_DisplayOption)
ds@1952
   328
	{
ds@1952
   329
		Format(buffer, maxlength, "%T", "FreezeBomb player", param);
ds@1952
   330
	}
ds@1952
   331
	else if (action == TopMenuAction_SelectOption)
ds@1952
   332
	{
ds@1952
   333
		DisplayFreezeBombMenu(param);
ds@1952
   334
	}
ds@1952
   335
}
ds@1952
   336
ds@1952
   337
DisplayFreezeMenu(client)
ds@1952
   338
{
ds@1952
   339
	new Handle:menu = CreateMenu(MenuHandler_Freeze);
ds@1952
   340
	
ds@1952
   341
	decl String:title[100];
ds@1952
   342
	Format(title, sizeof(title), "%T:", "Freeze player", client);
ds@1952
   343
	SetMenuTitle(menu, title);
ds@1952
   344
	SetMenuExitBackButton(menu, true);
ds@1952
   345
	
ds@1952
   346
	AddTargetsToMenu(menu, client, true, true);
ds@1952
   347
	
ds@1952
   348
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
ds@1952
   349
}
ds@1952
   350
ds@1952
   351
DisplayFreezeBombMenu(client)
ds@1952
   352
{
ds@1952
   353
	new Handle:menu = CreateMenu(MenuHandler_FreezeBomb);
ds@1952
   354
	
ds@1952
   355
	decl String:title[100];
ds@1952
   356
	Format(title, sizeof(title), "%T:", "FreezeBomb player", client);
ds@1952
   357
	SetMenuTitle(menu, title);
ds@1952
   358
	SetMenuExitBackButton(menu, true);
ds@1952
   359
	
ds@1952
   360
	AddTargetsToMenu(menu, client, true, true);
ds@1952
   361
	
ds@1952
   362
	DisplayMenu(menu, client, MENU_TIME_FOREVER);
ds@1952
   363
}
ds@1952
   364
ds@1952
   365
public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2)
ds@1952
   366
{
ds@1952
   367
	if (action == MenuAction_End)
ds@1952
   368
	{
ds@1952
   369
		CloseHandle(menu);
ds@1952
   370
	}
ds@1952
   371
	else if (action == MenuAction_Cancel)
ds@1952
   372
	{
ds@1952
   373
		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
ds@1952
   374
		{
ds@1952
   375
			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
ds@1952
   376
		}
ds@1952
   377
	}
ds@1952
   378
	else if (action == MenuAction_Select)
ds@1952
   379
	{
ds@1952
   380
		decl String:info[32];
ds@1952
   381
		new userid, target;
ds@1952
   382
		
ds@1952
   383
		GetMenuItem(menu, param2, info, sizeof(info));
ds@1952
   384
		userid = StringToInt(info);
ds@1952
   385
ds@1952
   386
		if ((target = GetClientOfUserId(userid)) == 0)
ds@1952
   387
		{
ds@1952
   388
			PrintToChat(param1, "[SM] %t", "Player no longer available");
ds@1952
   389
		}
ds@1952
   390
		else if (!CanUserTarget(param1, target))
ds@1952
   391
		{
ds@1952
   392
			PrintToChat(param1, "[SM] %t", "Unable to target");
ds@1952
   393
		}
ds@1952
   394
		else
ds@1952
   395
		{
ds@1952
   396
			new String:name[32];
ds@1952
   397
			GetClientName(target, name, sizeof(name));
ds@1952
   398
			
ds@1952
   399
			PerformFreeze(param1, target, GetConVarInt(g_FreezeDuration));
ds@1952
   400
			ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
ds@1952
   401
		}
ds@1952
   402
		
ds@1952
   403
		/* Re-draw the menu if they're still valid */
ds@1952
   404
		if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
ds@1952
   405
		{
ds@1952
   406
			DisplayFreezeMenu(param1);
ds@1952
   407
		}
ds@1952
   408
	}
ds@1952
   409
}
ds@1952
   410
ds@1952
   411
public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2)
ds@1952
   412
{
ds@1952
   413
	if (action == MenuAction_End)
ds@1952
   414
	{
ds@1952
   415
		CloseHandle(menu);
ds@1952
   416
	}
ds@1952
   417
	else if (action == MenuAction_Cancel)
ds@1952
   418
	{
ds@1952
   419
		if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
ds@1952
   420
		{
ds@1952
   421
			DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
ds@1952
   422
		}
ds@1952
   423
	}
ds@1952
   424
	else if (action == MenuAction_Select)
ds@1952
   425
	{
ds@1952
   426
		decl String:info[32];
ds@1952
   427
		new userid, target;
ds@1952
   428
		
ds@1952
   429
		GetMenuItem(menu, param2, info, sizeof(info));
ds@1952
   430
		userid = StringToInt(info);
ds@1952
   431
ds@1952
   432
		if ((target = GetClientOfUserId(userid)) == 0)
ds@1952
   433
		{
ds@1952
   434
			PrintToChat(param1, "[SM] %t", "Player no longer available");
ds@1952
   435
		}
ds@1952
   436
		else if (!CanUserTarget(param1, target))
ds@1952
   437
		{
ds@1952
   438
			PrintToChat(param1, "[SM] %t", "Unable to target");
ds@1952
   439
		}
ds@1952
   440
		else
ds@1952
   441
		{
ds@1952
   442
			new String:name[32];
ds@1952
   443
			GetClientName(target, name, sizeof(name));
ds@1952
   444
			
ds@1952
   445
			PerformFreezeBomb(param1, target, 2);
ds@1952
   446
			ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
ds@1952
   447
		}
ds@1952
   448
		
ds@1952
   449
		/* Re-draw the menu if they're still valid */
ds@1952
   450
		if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
ds@1952
   451
		{
ds@1952
   452
			DisplayFreezeBombMenu(param1);
ds@1952
   453
		}
ds@1952
   454
	}
ds@1952
   455
}
ds@1952
   456
ds@1952
   457
public Action:Command_Freeze(client, args)
ds@1952
   458
{
ds@1952
   459
	if (args < 1)
ds@1952
   460
	{
ds@1952
   461
		ReplyToCommand(client, "[SM] Usage: sm_freeze <#userid|name> [time]");
ds@1952
   462
		return Plugin_Handled;
ds@1952
   463
	}
ds@1952
   464
ds@1952
   465
	decl String:arg[65];
ds@1952
   466
	GetCmdArg(1, arg, sizeof(arg));
ds@1952
   467
	
ds@1952
   468
	new seconds = GetConVarInt(g_FreezeDuration);
ds@1952
   469
	
ds@1952
   470
	if (args > 1)
ds@1952
   471
	{
ds@1952
   472
		decl String:time[20];
ds@1952
   473
		GetCmdArg(2, time, sizeof(time));
ds@1952
   474
		if (StringToIntEx(time, seconds) == 0)
ds@1952
   475
		{
ds@1952
   476
			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
ds@1952
   477
			return Plugin_Handled;
ds@1952
   478
		}
ds@1952
   479
	}	
ds@1952
   480
ds@1952
   481
	decl String:target_name[MAX_TARGET_LENGTH];
ds@1952
   482
	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
ds@1952
   483
	
ds@1952
   484
	if ((target_count = ProcessTargetString(
ds@1952
   485
			arg,
ds@1952
   486
			client,
ds@1952
   487
			target_list,
ds@1952
   488
			MAXPLAYERS,
ds@1952
   489
			COMMAND_FILTER_ALIVE,
ds@1952
   490
			target_name,
ds@1952
   491
			sizeof(target_name),
ds@1952
   492
			tn_is_ml)) <= 0)
ds@1952
   493
	{
ds@1952
   494
		ReplyToTargetError(client, target_count);
ds@1952
   495
		return Plugin_Handled;
ds@1952
   496
	}
ds@1952
   497
	
ds@1952
   498
	for (new i = 0; i < target_count; i++)
ds@1952
   499
	{
ds@1952
   500
		PerformFreeze(client, target_list[i], seconds);
ds@1952
   501
	}
ds@1952
   502
	
ds@1952
   503
	if (tn_is_ml)
ds@1952
   504
	{
ds@1952
   505
		ShowActivity2(client, "[SM] ", "%t", "Froze target", target_name);
ds@1952
   506
	}
ds@1952
   507
	else
ds@1952
   508
	{
ds@1952
   509
		ShowActivity2(client, "[SM] ", "%t", "Froze target", "_s", target_name);
ds@1952
   510
	}
ds@1952
   511
	
ds@1952
   512
	return Plugin_Handled;
ds@1952
   513
}
ds@1952
   514
ds@1952
   515
public Action:Command_FreezeBomb(client, args)
ds@1952
   516
{
ds@1952
   517
	if (args < 1)
ds@1952
   518
	{
ds@1952
   519
		ReplyToCommand(client, "[SM] Usage: sm_freezebomb <#userid|name> [0/1]");
ds@1952
   520
		return Plugin_Handled;
ds@1952
   521
	}
ds@1952
   522
ds@1952
   523
	decl String:arg[65];
ds@1952
   524
	GetCmdArg(1, arg, sizeof(arg));
ds@1952
   525
	
ds@1952
   526
	new toggle = 2;
ds@1952
   527
	if (args > 1)
ds@1952
   528
	{
ds@1952
   529
		decl String:arg2[2];
ds@1952
   530
		GetCmdArg(2, arg2, sizeof(arg2));
ds@1952
   531
		if (arg2[0])
ds@1952
   532
		{
ds@1952
   533
			toggle = 1;
ds@1952
   534
		}
ds@1952
   535
		else
ds@1952
   536
		{
ds@1952
   537
			toggle = 0;
ds@1952
   538
		}
ds@1952
   539
	}
ds@1952
   540
ds@1952
   541
	decl String:target_name[MAX_TARGET_LENGTH];
ds@1952
   542
	decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
ds@1952
   543
	
ds@1952
   544
	if ((target_count = ProcessTargetString(
ds@1952
   545
			arg,
ds@1952
   546
			client,
ds@1952
   547
			target_list,
ds@1952
   548
			MAXPLAYERS,
ds@1952
   549
			COMMAND_FILTER_ALIVE,
ds@1952
   550
			target_name,
ds@1952
   551
			sizeof(target_name),
ds@1952
   552
			tn_is_ml)) <= 0)
ds@1952
   553
	{
ds@1952
   554
		ReplyToTargetError(client, target_count);
ds@1952
   555
		return Plugin_Handled;
ds@1952
   556
	}
ds@1952
   557
	
ds@1952
   558
	for (new i = 0; i < target_count; i++)
ds@1952
   559
	{
ds@1952
   560
		PerformFreezeBomb(client, target_list[i], toggle);
ds@1952
   561
	}
ds@1952
   562
	
ds@1952
   563
	if (tn_is_ml)
ds@1952
   564
	{
ds@1952
   565
		ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", target_name);
ds@1952
   566
	}
ds@1952
   567
	else
ds@1952
   568
	{
ds@1952
   569
		ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", target_name);
ds@1952
   570
	}
ds@1952
   571
	
ds@1952
   572
	return Plugin_Handled;
ds@1952
   573
}