Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides TimeBomb 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_TimeBombSerial[MAXPLAYERS+1] = { 0, ... };
35 new g_TimeBombTime[MAXPLAYERS+1] = { 0, ... };
37 new Handle:g_Cvar_TimeBombTicks = INVALID_HANDLE;
38 new Handle:g_Cvar_TimeBombRadius = INVALID_HANDLE;
39 new Handle:g_Cvar_TimeBombMode = INVALID_HANDLE;
41 CreateTimeBomb(client)
43 g_TimeBombSerial[client] = ++g_Serial_Gen;
44 CreateTimer(1.0, Timer_TimeBomb, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
45 g_TimeBombTime[client] = GetConVarInt(g_Cvar_TimeBombTicks);
50 g_TimeBombSerial[client] = 0;
52 if (IsClientInGame(client))
54 SetEntityRenderColor(client, 255, 255, 255, 255);
60 for (new i = 1; i <= MaxClients; i++)
66 PerformTimeBomb(client, target)
68 if (g_TimeBombSerial[target] == 0)
70 CreateTimeBomb(target);
71 LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
76 SetEntityRenderColor(client, 255, 255, 255, 255);
77 LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
81 public Action:Timer_TimeBomb(Handle:timer, any:value)
83 new client = value & 0x7f;
84 new serial = value >> 7;
86 if (!IsClientInGame(client)
87 || !IsPlayerAlive(client)
88 || serial != g_TimeBombSerial[client])
93 g_TimeBombTime[client]--;
96 GetClientEyePosition(client, vec);
98 if (g_TimeBombTime[client] > 0)
102 if (g_TimeBombTime[client] > 1)
104 color = RoundToFloor(g_TimeBombTime[client] * (128.0 / GetConVarFloat(g_Cvar_TimeBombTicks)));
107 EmitAmbientSound(g_BeepSound, vec, client, SNDLEVEL_RAIDSIREN);
115 EmitAmbientSound(g_FinalSound, vec, client, SNDLEVEL_RAIDSIREN);
119 SetEntityRenderColor(client, 255, 128, color, 255);
121 decl String:name[64];
122 GetClientName(client, name, sizeof(name));
123 PrintCenterTextAll("%t", "Till Explodes", name, g_TimeBombTime[client]);
125 if (g_BeamSprite > -1 && g_HaloSprite > -1)
127 GetClientAbsOrigin(client, vec);
130 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
132 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_TimeBombRadius) / 3.0, g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, whiteColor, 10, 0);
135 return Plugin_Continue;
139 if (g_ExplosionSprite > -1)
141 TE_SetupExplosion(vec, g_ExplosionSprite, 5.0, 1, 0, GetConVarInt(g_Cvar_TimeBombRadius), 5000);
147 EmitAmbientSound(g_BoomSound, vec, client, SNDLEVEL_RAIDSIREN);
150 ForcePlayerSuicide(client);
151 KillTimeBomb(client);
152 SetEntityRenderColor(client, 255, 255, 255, 255);
154 if (GetConVarInt(g_Cvar_TimeBombMode) > 0)
156 new teamOnly = ((GetConVarInt(g_Cvar_TimeBombMode) == 1) ? true : false);
158 for (new i = 1; i <= MaxClients; i++)
160 if (!IsClientInGame(i) || !IsPlayerAlive(i) || i == client)
165 if (teamOnly && GetClientTeam(i) != GetClientTeam(client))
171 GetClientEyePosition(i, pos);
173 new Float:distance = GetVectorDistance(vec, pos);
175 if (distance > GetConVarFloat(g_Cvar_TimeBombRadius))
181 damage = RoundToFloor(damage * ((GetConVarFloat(g_Cvar_TimeBombRadius) - distance) / GetConVarFloat(g_Cvar_TimeBombRadius)));
183 SlapPlayer(i, damage, false);
185 if (g_ExplosionSprite > -1)
187 TE_SetupExplosion(pos, g_ExplosionSprite, 0.05, 1, 0, 1, 1);
193 SubtractVectors(vec, pos, dir);
194 TR_TraceRayFilter(vec, dir, MASK_SOLID, RayType_Infinite, TR_Filter_Client);
196 if (i == TR_GetEntityIndex())
199 new radius = GetConVarInt(g_Cvar_TimeBombRadius) / 2;
201 if (distance > radius)
204 damage = RoundToFloor(damage * ((radius - distance) / radius));
207 SlapPlayer(i, damage, false);
216 public AdminMenu_TimeBomb(Handle:topmenu,
217 TopMenuAction:action,
218 TopMenuObject:object_id,
223 if (action == TopMenuAction_DisplayOption)
225 Format(buffer, maxlength, "%T", "TimeBomb player", param);
227 else if (action == TopMenuAction_SelectOption)
229 DisplayTimeBombMenu(param);
233 DisplayTimeBombMenu(client)
235 new Handle:menu = CreateMenu(MenuHandler_TimeBomb);
237 decl String:title[100];
238 Format(title, sizeof(title), "%T:", "TimeBomb player", client);
239 SetMenuTitle(menu, title);
240 SetMenuExitBackButton(menu, true);
242 AddTargetsToMenu(menu, client, true, true);
244 DisplayMenu(menu, client, MENU_TIME_FOREVER);
247 public MenuHandler_TimeBomb(Handle:menu, MenuAction:action, param1, param2)
249 if (action == MenuAction_End)
253 else if (action == MenuAction_Cancel)
255 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
257 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
260 else if (action == MenuAction_Select)
262 decl String:info[32];
265 GetMenuItem(menu, param2, info, sizeof(info));
266 userid = StringToInt(info);
268 if ((target = GetClientOfUserId(userid)) == 0)
270 PrintToChat(param1, "[SM] %t", "Player no longer available");
272 else if (!CanUserTarget(param1, target))
274 PrintToChat(param1, "[SM] %t", "Unable to target");
279 GetClientName(target, name, sizeof(name));
281 PerformTimeBomb(param1, target);
282 ShowActivity2(param1, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", name);
285 /* Re-draw the menu if they're still valid */
286 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
288 DisplayTimeBombMenu(param1);
293 public Action:Command_TimeBomb(client, args)
297 ReplyToCommand(client, "[SM] Usage: sm_timebomb <#userid|name>");
298 return Plugin_Handled;
302 GetCmdArg(1, arg, sizeof(arg));
304 decl String:target_name[MAX_TARGET_LENGTH];
305 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
307 if ((target_count = ProcessTargetString(
312 COMMAND_FILTER_ALIVE,
317 ReplyToTargetError(client, target_count);
318 return Plugin_Handled;
321 for (new i = 0; i < target_count; i++)
323 PerformTimeBomb(client, target_list[i]);
328 ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", target_name);
332 ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", target_name);
335 return Plugin_Handled;