Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides freeze and freezebomb functionality
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
34 new g_FreezeSerial[MAXPLAYERS+1] = { 0, ... };
35 new g_FreezeBombSerial[MAXPLAYERS+1] = { 0, ... };
36 new g_FreezeTime[MAXPLAYERS+1] = { 0, ... };
37 new g_FreezeBombTime[MAXPLAYERS+1] = { 0, ... };
39 new Handle:g_Cvar_FreezeDuration = INVALID_HANDLE;
40 new Handle:g_Cvar_FreezeBombTicks = INVALID_HANDLE;
41 new Handle:g_Cvar_FreezeBombRadius = INVALID_HANDLE;
42 new Handle:g_Cvar_FreezeBombMode = INVALID_HANDLE;
44 FreezeClient(client, time)
46 if (g_FreezeSerial[client] != 0)
48 UnfreezeClient(client);
51 SetEntityMoveType(client, MOVETYPE_NONE);
52 SetEntityRenderColor(client, 0, 128, 255, 192);
57 GetClientEyePosition(client, vec);
58 EmitAmbientSound(g_FreezeSound, vec, client, SNDLEVEL_RAIDSIREN);
61 g_FreezeTime[client] = time;
62 g_FreezeSerial[client] = ++ g_Serial_Gen;
63 CreateTimer(1.0, Timer_Freeze, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
66 UnfreezeClient(client)
68 g_FreezeSerial[client] = 0;
69 g_FreezeTime[client] = 0;
71 if (IsClientInGame(client))
76 GetClientAbsOrigin(client, vec);
79 GetClientEyePosition(client, vec);
80 EmitAmbientSound(g_FreezeSound, vec, client, SNDLEVEL_RAIDSIREN);
83 SetEntityMoveType(client, MOVETYPE_WALK);
85 SetEntityRenderColor(client, 255, 255, 255, 255);
89 CreateFreezeBomb(client)
91 if (g_FreezeBombSerial[client] != 0)
93 KillFreezeBomb(client);
96 g_FreezeBombTime[client] = GetConVarInt(g_Cvar_FreezeBombTicks);
97 g_FreezeBombSerial[client] = ++g_Serial_Gen;
98 CreateTimer(1.0, Timer_FreezeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
101 KillFreezeBomb(client)
103 g_FreezeBombSerial[client] = 0;
104 g_FreezeBombTime[client] = 0;
106 if (IsClientInGame(client))
108 SetEntityRenderColor(client, 255, 255, 255, 255);
114 for(new i = 1; i <= MaxClients; i++)
116 if (g_FreezeSerial[i] != 0)
121 if (g_FreezeBombSerial[i] != 0)
128 PerformFreeze(client, target, time)
130 FreezeClient(target, time);
131 LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
134 PerformFreezeBomb(client, target)
136 if (g_FreezeBombSerial[target] != 0)
138 KillFreezeBomb(target);
139 LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
143 CreateFreezeBomb(target);
144 LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
148 public Action:Timer_Freeze(Handle:timer, any:value)
150 new client = value & 0x7f;
151 new serial = value >> 7;
153 if (!IsClientInGame(client)
154 || !IsPlayerAlive(client)
155 || g_FreezeSerial[client] != serial)
157 UnfreezeClient(client);
161 if (g_FreezeTime[client] == 0)
163 UnfreezeClient(client);
165 /* HintText doesn't work on Dark Messiah */
166 if (g_GameEngine != Engine_DarkMessiah)
168 PrintHintText(client, "%t", "Unfrozen");
172 PrintCenterText(client, "%t", "Unfrozen");
178 if (g_GameEngine != Engine_DarkMessiah)
180 PrintHintText(client, "%t", "You will be unfrozen", g_FreezeTime[client]);
184 PrintCenterText(client, "%t", "You will be unfrozen", g_FreezeTime[client]);
187 g_FreezeTime[client]--;
188 SetEntityMoveType(client, MOVETYPE_NONE);
189 SetEntityRenderColor(client, 0, 128, 255, 135);
192 GetClientAbsOrigin(client, vec);
195 if (g_GlowSprite > -1)
197 TE_SetupGlowSprite(vec, g_GlowSprite, 0.95, 1.5, 50);
200 else if (g_HaloSprite > -1)
202 TE_SetupGlowSprite(vec, g_HaloSprite, 0.95, 1.5, 50);
206 return Plugin_Continue;
209 public Action:Timer_FreezeBomb(Handle:timer, any:value)
211 new client = value & 0x7f;
212 new serial = value >> 7;
214 if (!IsClientInGame(client)
215 || !IsPlayerAlive(client)
216 || g_FreezeBombSerial[client] != serial)
218 KillFreezeBomb(client);
223 GetClientEyePosition(client, vec);
224 g_FreezeBombTime[client]--;
226 if (g_FreezeBombTime[client] > 0)
230 if (g_FreezeBombTime[client] > 1)
232 color = RoundToFloor(g_FreezeBombTime[client] * (255.0 / GetConVarFloat(g_Cvar_FreezeBombTicks)));
235 EmitAmbientSound(g_BeepSound, vec, client, SNDLEVEL_RAIDSIREN);
243 EmitAmbientSound(g_FinalSound, vec, client, SNDLEVEL_RAIDSIREN);
247 SetEntityRenderColor(client, color, color, 255, 255);
249 decl String:name[64];
250 GetClientName(client, name, sizeof(name));
251 PrintCenterTextAll("%t", "Till Explodes", name, g_FreezeBombTime[client]);
253 if (g_BeamSprite > -1 && g_HaloSprite > -1)
255 GetClientAbsOrigin(client, vec);
258 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
260 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_FreezeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
263 return Plugin_Continue;
267 if (g_ExplosionSprite > -1)
269 TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_FreezeBombRadius), 5000);
275 EmitAmbientSound(g_BoomSound, vec, client, SNDLEVEL_RAIDSIREN);
278 KillFreezeBomb(client);
279 FreezeClient(client, GetConVarInt(g_Cvar_FreezeDuration));
281 if (GetConVarInt(g_Cvar_FreezeBombMode) > 0)
283 new bool:teamOnly = ((GetConVarInt(g_Cvar_FreezeBombMode) == 1) ? true : false);
285 for (new i = 1; i <= MaxClients; i++)
287 if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
292 if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
298 GetClientEyePosition(i, pos);
300 new Float:distance = GetVectorDistance(vec, pos);
302 if (distance > GetConVarFloat(g_Cvar_FreezeBombRadius))
307 if (g_HaloSprite > -1)
309 if (g_BeamSprite2 > -1)
311 TE_SetupBeamPoints(vec, pos, g_BeamSprite2, g_HaloSprite, 0, 1, 0.7, 20.0, 50.0, 1, 1.5, blueColor, 10);
314 else if (g_BeamSprite > -1)
316 TE_SetupBeamPoints(vec, pos, g_BeamSprite, g_HaloSprite, 0, 1, 0.7, 20.0, 50.0, 1, 1.5, blueColor, 10);
321 FreezeClient(i, GetConVarInt(g_Cvar_FreezeDuration));
328 public AdminMenu_Freeze(Handle:topmenu,
329 TopMenuAction:action,
330 TopMenuObject:object_id,
335 if (action == TopMenuAction_DisplayOption)
337 Format(buffer, maxlength, "%T", "Freeze player", param);
339 else if (action == TopMenuAction_SelectOption)
341 DisplayFreezeMenu(param);
345 public AdminMenu_FreezeBomb(Handle:topmenu,
346 TopMenuAction:action,
347 TopMenuObject:object_id,
352 if (action == TopMenuAction_DisplayOption)
354 Format(buffer, maxlength, "%T", "FreezeBomb player", param);
356 else if (action == TopMenuAction_SelectOption)
358 DisplayFreezeBombMenu(param);
362 DisplayFreezeMenu(client)
364 new Handle:menu = CreateMenu(MenuHandler_Freeze);
366 decl String:title[100];
367 Format(title, sizeof(title), "%T:", "Freeze player", client);
368 SetMenuTitle(menu, title);
369 SetMenuExitBackButton(menu, true);
371 AddTargetsToMenu(menu, client, true, true);
373 DisplayMenu(menu, client, MENU_TIME_FOREVER);
376 DisplayFreezeBombMenu(client)
378 new Handle:menu = CreateMenu(MenuHandler_FreezeBomb);
380 decl String:title[100];
381 Format(title, sizeof(title), "%T:", "FreezeBomb player", client);
382 SetMenuTitle(menu, title);
383 SetMenuExitBackButton(menu, true);
385 AddTargetsToMenu(menu, client, true, true);
387 DisplayMenu(menu, client, MENU_TIME_FOREVER);
390 public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2)
392 if (action == MenuAction_End)
396 else if (action == MenuAction_Cancel)
398 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
400 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
403 else if (action == MenuAction_Select)
405 decl String:info[32];
408 GetMenuItem(menu, param2, info, sizeof(info));
409 userid = StringToInt(info);
411 if ((target = GetClientOfUserId(userid)) == 0)
413 PrintToChat(param1, "[SM] %t", "Player no longer available");
415 else if (!CanUserTarget(param1, target))
417 PrintToChat(param1, "[SM] %t", "Unable to target");
422 GetClientName(target, name, sizeof(name));
424 PerformFreeze(param1, target, GetConVarInt(g_Cvar_FreezeDuration));
425 ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
428 /* Re-draw the menu if they're still valid */
429 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
431 DisplayFreezeMenu(param1);
436 public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2)
438 if (action == MenuAction_End)
442 else if (action == MenuAction_Cancel)
444 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
446 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
449 else if (action == MenuAction_Select)
451 decl String:info[32];
454 GetMenuItem(menu, param2, info, sizeof(info));
455 userid = StringToInt(info);
457 if ((target = GetClientOfUserId(userid)) == 0)
459 PrintToChat(param1, "[SM] %t", "Player no longer available");
461 else if (!CanUserTarget(param1, target))
463 PrintToChat(param1, "[SM] %t", "Unable to target");
468 GetClientName(target, name, sizeof(name));
470 PerformFreezeBomb(param1, target);
471 ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
474 /* Re-draw the menu if they're still valid */
475 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
477 DisplayFreezeBombMenu(param1);
482 public Action:Command_Freeze(client, args)
486 ReplyToCommand(client, "[SM] Usage: sm_freeze <#userid|name> [time]");
487 return Plugin_Handled;
491 GetCmdArg(1, arg, sizeof(arg));
493 new seconds = GetConVarInt(g_Cvar_FreezeDuration);
497 decl String:time[20];
498 GetCmdArg(2, time, sizeof(time));
499 if (StringToIntEx(time, seconds) == 0)
501 ReplyToCommand(client, "[SM] %t", "Invalid Amount");
502 return Plugin_Handled;
506 decl String:target_name[MAX_TARGET_LENGTH];
507 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
509 if ((target_count = ProcessTargetString(
514 COMMAND_FILTER_ALIVE,
519 ReplyToTargetError(client, target_count);
520 return Plugin_Handled;
523 for (new i = 0; i < target_count; i++)
525 PerformFreeze(client, target_list[i], seconds);
530 ShowActivity2(client, "[SM] ", "%t", "Froze target", target_name);
534 ShowActivity2(client, "[SM] ", "%t", "Froze target", "_s", target_name);
537 return Plugin_Handled;
540 public Action:Command_FreezeBomb(client, args)
544 ReplyToCommand(client, "[SM] Usage: sm_freezebomb <#userid|name>");
545 return Plugin_Handled;
549 GetCmdArg(1, arg, sizeof(arg));
551 decl String:target_name[MAX_TARGET_LENGTH];
552 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
554 if ((target_count = ProcessTargetString(
559 COMMAND_FILTER_ALIVE,
564 ReplyToTargetError(client, target_count);
565 return Plugin_Handled;
568 for (new i = 0; i < target_count; i++)
570 PerformFreezeBomb(client, target_list[i]);
575 ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", target_name);
579 ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", target_name);
582 return Plugin_Handled;