3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides beacon 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_BeaconSerial[MAXPLAYERS+1] = { 0, ... };
36 new Handle:g_Cvar_BeaconRadius = INVALID_HANDLE;
40 g_BeaconSerial[client] = ++g_Serial_Gen;
41 CreateTimer(1.0, Timer_Beacon, client | (g_Serial_Gen << 7), DEFAULT_TIMER_FLAGS);
46 g_BeaconSerial[client] = 0;
48 if (IsClientInGame(client))
50 SetEntityRenderColor(client, 255, 255, 255, 255);
56 for (new i = 1; i <= MaxClients; i++)
62 PerformBeacon(client, target)
64 if (g_BeaconSerial[target] == 0)
67 LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
72 LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
76 public Action:Timer_Beacon(Handle:timer, any:value)
78 new client = value & 0x7f;
79 new serial = value >> 7;
81 if (!IsClientInGame(client)
82 || !IsPlayerAlive(client)
83 || g_BeaconSerial[client] != serial)
89 new team = GetClientTeam(client);
92 GetClientAbsOrigin(client, vec);
95 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 15, 0.5, 5.0, 0.0, greyColor, 10, 0);
100 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, redColor, 10, 0);
104 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, blueColor, 10, 0);
108 TE_SetupBeamRingPoint(vec, 10.0, GetConVarFloat(g_Cvar_BeaconRadius), g_BeamSprite, g_HaloSprite, 0, 10, 0.6, 10.0, 0.5, greenColor, 10, 0);
113 GetClientEyePosition(client, vec);
114 EmitAmbientSound(SOUND_BLIP, vec, client, SNDLEVEL_RAIDSIREN);
116 return Plugin_Continue;
119 public AdminMenu_Beacon(Handle:topmenu,
120 TopMenuAction:action,
121 TopMenuObject:object_id,
126 if (action == TopMenuAction_DisplayOption)
128 Format(buffer, maxlength, "%T", "Beacon player", param);
130 else if (action == TopMenuAction_SelectOption)
132 DisplayBeaconMenu(param);
136 DisplayBeaconMenu(client)
138 new Handle:menu = CreateMenu(MenuHandler_Beacon);
140 decl String:title[100];
141 Format(title, sizeof(title), "%T:", "Beacon player", client);
142 SetMenuTitle(menu, title);
143 SetMenuExitBackButton(menu, true);
145 AddTargetsToMenu(menu, client, true, true);
147 DisplayMenu(menu, client, MENU_TIME_FOREVER);
150 public MenuHandler_Beacon(Handle:menu, MenuAction:action, param1, param2)
152 if (action == MenuAction_End)
156 else if (action == MenuAction_Cancel)
158 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
160 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
163 else if (action == MenuAction_Select)
165 decl String:info[32];
168 GetMenuItem(menu, param2, info, sizeof(info));
169 userid = StringToInt(info);
171 if ((target = GetClientOfUserId(userid)) == 0)
173 PrintToChat(param1, "[SM] %t", "Player no longer available");
175 else if (!CanUserTarget(param1, target))
177 PrintToChat(param1, "[SM] %t", "Unable to target");
182 GetClientName(target, name, sizeof(name));
184 PerformBeacon(param1, target);
185 ShowActivity2(param1, "[SM] ", "%t", "Toggled beacon on target", "_s", name);
188 /* Re-draw the menu if they're still valid */
189 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
191 DisplayBeaconMenu(param1);
196 public Action:Command_Beacon(client, args)
200 ReplyToCommand(client, "[SM] Usage: sm_beacon <#userid|name>");
201 return Plugin_Handled;
205 GetCmdArg(1, arg, sizeof(arg));
207 decl String:target_name[MAX_TARGET_LENGTH];
208 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
210 if ((target_count = ProcessTargetString(
215 COMMAND_FILTER_ALIVE,
220 ReplyToTargetError(client, target_count);
221 return Plugin_Handled;
224 for (new i = 0; i < target_count; i++)
226 PerformBeacon(client, target_list[i]);
231 ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", target_name);
235 ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", "_s", target_name);
238 return Plugin_Handled;