Update CS:GO team score gamedata.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides gravity 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_GravityTarget[MAXPLAYERS+1];
36 PerformGravity(client, target, Float:amount)
38 SetEntityGravity(target, amount);
39 LogAction(client, target, "\"%L\" set gravity on \"%L\" to %d.", client, target, amount);
42 public AdminMenu_Gravity(Handle:topmenu,
44 TopMenuObject:object_id,
49 if (action == TopMenuAction_DisplayOption)
51 Format(buffer, maxlength, "%T", "Gravity player", param);
53 else if (action == TopMenuAction_SelectOption)
55 DisplayGravityMenu(param);
59 DisplayGravityMenu(client)
61 new Handle:menu = CreateMenu(MenuHandler_Gravity);
63 decl String:title[100];
64 Format(title, sizeof(title), "%T:", "Gravity player", client);
65 SetMenuTitle(menu, title);
66 SetMenuExitBackButton(menu, true);
68 AddTargetsToMenu(menu, client, true, true);
70 DisplayMenu(menu, client, MENU_TIME_FOREVER);
73 DisplayGravityAmountMenu(client)
75 new Handle:menu = CreateMenu(MenuHandler_GravityAmount);
77 decl String:title[100];
78 Format(title, sizeof(title), "%T: %N", "Gravity amount", client, GetClientOfUserId(g_GravityTarget[client]));
79 SetMenuTitle(menu, title);
80 SetMenuExitBackButton(menu, true);
82 AddTranslatedMenuItem(menu, "4.0", "Gravity Very High", client);
83 AddTranslatedMenuItem(menu, "2.0", "Gravity High", client);
84 AddTranslatedMenuItem(menu, "1.0", "Gravity Normal", client);
85 AddTranslatedMenuItem(menu, "0.5", "Gravity Low", client);
86 AddTranslatedMenuItem(menu, "0.1", "Gravity Very Low", client);
88 DisplayMenu(menu, client, MENU_TIME_FOREVER);
91 public MenuHandler_Gravity(Handle:menu, MenuAction:action, param1, param2)
93 if (action == MenuAction_End)
97 else if (action == MenuAction_Cancel)
99 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
101 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
104 else if (action == MenuAction_Select)
106 decl String:info[32];
109 GetMenuItem(menu, param2, info, sizeof(info));
110 userid = StringToInt(info);
112 if ((target = GetClientOfUserId(userid)) == 0)
114 PrintToChat(param1, "[SM] %t", "Player no longer available");
116 else if (!CanUserTarget(param1, target))
118 PrintToChat(param1, "[SM] %t", "Unable to target");
122 g_GravityTarget[param1] = userid;
123 DisplayGravityAmountMenu(param1);
124 return; // Return, because we went to a new menu and don't want the re-draw to occur.
127 /* Re-draw the menu if they're still valid */
128 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
130 DisplayGravityMenu(param1);
137 public MenuHandler_GravityAmount(Handle:menu, MenuAction:action, param1, param2)
139 if (action == MenuAction_End)
143 else if (action == MenuAction_Cancel)
145 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
147 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
150 else if (action == MenuAction_Select)
152 decl String:info[32];
153 new Float:amount, target;
155 GetMenuItem(menu, param2, info, sizeof(info));
156 amount = StringToFloat(info);
158 if ((target = GetClientOfUserId(g_GravityTarget[param1])) == 0)
160 PrintToChat(param1, "[SM] %t", "Player no longer available");
162 else if (!CanUserTarget(param1, target))
164 PrintToChat(param1, "[SM] %t", "Unable to target");
169 GetClientName(target, name, sizeof(name));
171 PerformGravity(param1, target, amount);
172 ShowActivity2(param1, "[SM] ", "%t", "Set gravity on target", "_s", name, amount);
175 /* Re-draw the menu if they're still valid */
176 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
178 DisplayGravityMenu(param1);
183 public Action:Command_Gravity(client, args)
187 ReplyToCommand(client, "[SM] Usage: sm_gravity <#userid|name> [amount]");
188 return Plugin_Handled;
192 GetCmdArg(1, arg, sizeof(arg));
194 new Float:amount = 1.0;
197 decl String:arg2[20];
198 GetCmdArg(2, arg2, sizeof(arg2));
199 if (StringToFloatEx(arg2, amount) == 0)
201 ReplyToCommand(client, "[SM] %t", "Invalid Amount");
202 return Plugin_Handled;
211 decl String:target_name[MAX_TARGET_LENGTH];
212 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
214 if ((target_count = ProcessTargetString(
219 COMMAND_FILTER_ALIVE,
224 ReplyToTargetError(client, target_count);
225 return Plugin_Handled;
228 for (new i = 0; i < target_count; i++)
230 PerformGravity(client, target_list[i], amount);
235 ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", target_name);
239 ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", "_s", target_name);
242 return Plugin_Handled;