From 6ab87ef82117d9b0dfe7d91d19db62f0aba2d096 Mon Sep 17 00:00:00 2001 From: Michael McKoy Date: Mon, 24 Dec 2007 00:45:28 +0000 Subject: [PATCH] Added sm_blind, sm_drug, sm_gravity, sm_noclip Fixed the duration of sm_freeze when used from the menu --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401827 --- plugins/basefuncommands.sp | 178 ++++++++++++-- plugins/basefuncommands/blind.sp | 279 +++++++++++++++++++++ plugins/basefuncommands/drug.sp | 296 +++++++++++++++++++++++ plugins/basefuncommands/gravity.sp | 252 +++++++++++++++++++ plugins/basefuncommands/ice.sp | 2 +- plugins/basefuncommands/noclip.sp | 175 ++++++++++++++ translations/basefuncommands.phrases.txt | 102 +++++++- 7 files changed, 1255 insertions(+), 29 deletions(-) create mode 100644 plugins/basefuncommands/blind.sp create mode 100644 plugins/basefuncommands/drug.sp create mode 100644 plugins/basefuncommands/gravity.sp create mode 100644 plugins/basefuncommands/noclip.sp diff --git a/plugins/basefuncommands.sp b/plugins/basefuncommands.sp index f15006bb..519a6408 100644 --- a/plugins/basefuncommands.sp +++ b/plugins/basefuncommands.sp @@ -47,6 +47,23 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; +// ------------------------------------------------------------------------------- +// Set any of these to 0 and recompile to completely disable those commands +// ------------------------------------------------------------------------------- +#define BEACON 1 +#define TIMEBOMB 1 +#define FIRE 1 +#define ICE 1 +#define GRAVITY 1 +#define BLIND 1 +#define NOCLIP 1 +#define DRUG 1 +#define TELEPORT 1 +#define HEALTH 1 +#define COLORS 1 +#define CASH 1 +// ------------------------------------------------------------------------------- + new Handle:hTopMenu = INVALID_HANDLE; // Sounds @@ -71,34 +88,77 @@ new blueColor[4] = {75, 75, 255, 255}; new whiteColor[4] = {255, 255, 255, 255}; new greyColor[4] = {128, 128, 128, 255}; -// Used for some trace rays. -/* -new g_FilteredEntity = -1; -public bool:TR_Filter_Client(ent, contentMask) -{ - return (ent == g_FilteredEntity) ? false : true; -} -*/ +// UserMessageId for Fade. +new UserMsg:g_FadeUserMsgId; // Include various commands and supporting functions +#if BEACON #include "basefuncommands/beacon.sp" +#endif +#if TIMEBOMB #include "basefuncommands/timebomb.sp" +#endif +#if FIRE #include "basefuncommands/fire.sp" +#endif +#if ICE #include "basefuncommands/ice.sp" +#endif +#if GRAVITY +#include "basefuncommands/gravity.sp" +#endif +#if BLIND +#include "basefuncommands/blind.sp" +#endif +#if NOCLIP +#include "basefuncommands/noclip.sp" +#endif +#if DRUG +#include "basefuncommands/drug.sp" +#endif public OnPluginStart() { LoadTranslations("common.phrases"); LoadTranslations("basefuncommands.phrases"); + g_FadeUserMsgId = GetUserMessageId("Fade"); + RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> "); HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy); + #if BEACON SetupBeacon(); // sm_beacon + #endif + + #if TIMEBOMB SetupTimeBomb(); // sm_timebomb + #endif + + #if FIRE SetupFire(); // sm_burn and sm_firebomb + #endif + + #if ICE SetupIce(); // sm_freeze and sm_freezebomb + #endif + + #if GRAVITY + SetupGravity(); // sm_gravity + #endif + + #if BLIND + SetupBlind(); // sm_blind + #endif + + #if NOCLIP + SetupNoClip(); // sm_noclip + #endif + + #if DRUG + SetupDrugs(); // sm_drug + #endif AutoExecConfig(true, "funcommands"); @@ -127,18 +187,40 @@ public OnMapStart() public OnMapEnd() { + #if BEACON KillAllBeacons(); + #endif + #if TIMEBOMB KillAllTimeBombs(); + #endif + #if FIRE KillAllFireBombs(); + #endif + #if ICE KillAllFreezes(); + #endif + #if DRUG + KillAllDrugs(); + #endif } public Action:Event_RoundEnd(Handle:event,const String:name[],bool:dontBroadcast) { + #if BEACON KillAllBeacons(); + #endif + #if TIMEBOMB KillAllTimeBombs(); + #endif + #if FIRE KillAllFireBombs(); + #endif + #if ICE KillAllFreezes(); + #endif + #if DRUG + KillAllDrugs(); + #endif return Plugin_Handled; } @@ -159,6 +241,7 @@ public OnAdminMenuReady(Handle:topmenu) if (player_commands != INVALID_TOPMENUOBJECT) { + #if BEACON AddToTopMenu(hTopMenu, "sm_beacon", TopMenuObject_Item, @@ -166,7 +249,19 @@ public OnAdminMenuReady(Handle:topmenu) player_commands, "sm_beacon", ADMFLAG_SLAY); + #endif + #if TIMEBOMB + AddToTopMenu(hTopMenu, + "sm_timebomb", + TopMenuObject_Item, + AdminMenu_TimeBomb, + player_commands, + "sm_timebomb", + ADMFLAG_SLAY); + #endif + + #if FIRE AddToTopMenu(hTopMenu, "sm_burn", TopMenuObject_Item, @@ -175,22 +270,6 @@ public OnAdminMenuReady(Handle:topmenu) "sm_burn", ADMFLAG_SLAY); - AddToTopMenu(hTopMenu, - "sm_freeze", - TopMenuObject_Item, - AdminMenu_Freeze, - player_commands, - "sm_freeze", - ADMFLAG_SLAY); - - AddToTopMenu(hTopMenu, - "sm_timebomb", - TopMenuObject_Item, - AdminMenu_TimeBomb, - player_commands, - "sm_timebomb", - ADMFLAG_SLAY); - AddToTopMenu(hTopMenu, "sm_firebomb", TopMenuObject_Item, @@ -198,6 +277,16 @@ public OnAdminMenuReady(Handle:topmenu) player_commands, "sm_firebomb", ADMFLAG_SLAY); + #endif + + #if ICE + AddToTopMenu(hTopMenu, + "sm_freeze", + TopMenuObject_Item, + AdminMenu_Freeze, + player_commands, + "sm_freeze", + ADMFLAG_SLAY); AddToTopMenu(hTopMenu, "sm_freezebomb", @@ -206,6 +295,47 @@ public OnAdminMenuReady(Handle:topmenu) player_commands, "sm_freezebomb", ADMFLAG_SLAY); + #endif + + #if GRAVITY + AddToTopMenu(hTopMenu, + "sm_gravity", + TopMenuObject_Item, + AdminMenu_Gravity, + player_commands, + "sm_gravity", + ADMFLAG_SLAY); + #endif + + #if BLIND + AddToTopMenu(hTopMenu, + "sm_blind", + TopMenuObject_Item, + AdminMenu_Blind, + player_commands, + "sm_blind", + ADMFLAG_SLAY); + #endif + + #if NOCLIP + AddToTopMenu(hTopMenu, + "sm_noclip", + TopMenuObject_Item, + AdminMenu_NoClip, + player_commands, + "sm_noclip", + ADMFLAG_SLAY); + #endif + + #if DRUG + AddToTopMenu(hTopMenu, + "sm_drug", + TopMenuObject_Item, + AdminMenu_Drug, + player_commands, + "sm_drug", + ADMFLAG_SLAY); + #endif } } diff --git a/plugins/basefuncommands/blind.sp b/plugins/basefuncommands/blind.sp new file mode 100644 index 00000000..3f90aa06 --- /dev/null +++ b/plugins/basefuncommands/blind.sp @@ -0,0 +1,279 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod Basefuncommands Plugin + * Provides blind functionality + * + * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +new g_BlindTarget[MAXPLAYERS+1]; + +SetupBlind() +{ + RegAdminCmd("sm_blind", Command_Blind, ADMFLAG_SLAY, "sm_blind <#userid|name> [amount] - Leave amount off to reset."); +} + +PerformBlind(client, target, amount) +{ + new targets[2]; + targets[0] = target; + + new Handle:message = StartMessageEx(g_FadeUserMsgId, targets, 1); + BfWriteShort(message, 1536); + BfWriteShort(message, 1536); + + if (amount == 0) + { + BfWriteShort(message, (0x0001 | 0x0010)); + } + else + { + BfWriteShort(message, (0x0002 | 0x0008)); + } + + BfWriteByte(message, 0); + BfWriteByte(message, 0); + BfWriteByte(message, 0); + BfWriteByte(message, amount); + + EndMessage(); + + LogAction(client, target, "\"%L\" set blind on \"%L\", amount %d.", client, target, amount); +} + +public AdminMenu_Blind(Handle:topmenu, + TopMenuAction:action, + TopMenuObject:object_id, + param, + String:buffer[], + maxlength) +{ + if (action == TopMenuAction_DisplayOption) + { + Format(buffer, maxlength, "%T", "Blind player", param); + } + else if (action == TopMenuAction_SelectOption) + { + DisplayBlindMenu(param); + } + else if (action == TopMenuAction_DrawOption) + { + // Disable if we could not find the user message id for Fade. + buffer[0] = ((g_FadeUserMsgId == INVALID_MESSAGE_ID) ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT); + } +} + +DisplayBlindMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_Blind); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "Blind player", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddTargetsToMenu(menu, client, true, true); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +DisplayAmountMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_Amount); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "Blind amount", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddMenuItem(menu, "255", "Fully blind"); + AddMenuItem(menu, "240", "Half blind"); + AddMenuItem(menu, "0", "No blind"); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +public MenuHandler_Blind(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + g_BlindTarget[param1] = userid; + DisplayAmountMenu(param1); + return; // Return, because we went to a new menu and don't want the re-draw to occur. + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayBlindMenu(param1); + } + } + + return; +} + +public MenuHandler_Amount(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new amount, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + amount = StringToInt(info); + + if ((target = GetClientOfUserId(g_BlindTarget[param1])) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + new String:name[32]; + GetClientName(target, name, sizeof(name)); + + PerformBlind(param1, target, amount); + ShowActivity2(param1, "[SM] ", "%t", "Set blind on target", "_s", name, amount); + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayBlindMenu(param1); + } + } +} + + +public Action:Command_Blind(client, args) +{ + if (args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_blind <#userid|name> [amount]"); + return Plugin_Handled; + } + + decl String:arg[65]; + GetCmdArg(1, arg, sizeof(arg)); + + new amount = 0; + if (args > 1) + { + decl String:arg2[20]; + GetCmdArg(2, arg2, sizeof(arg2)); + if (StringToIntEx(arg2, amount) == 0) + { + ReplyToCommand(client, "[SM] %t", "Invalid Amount"); + return Plugin_Handled; + } + + if (amount < 0) + { + amount = 0; + } + + if (amount > 255) + { + amount = 255; + } + } + + decl String:target_name[MAX_TARGET_LENGTH]; + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml; + + if ((target_count = ProcessTargetString( + arg, + client, + target_list, + MAXPLAYERS, + COMMAND_FILTER_ALIVE, + target_name, + sizeof(target_name), + tn_is_ml)) <= 0) + { + ReplyToTargetError(client, target_count); + return Plugin_Handled; + } + + for (new i = 0; i < target_count; i++) + { + PerformBlind(client, target_list[i], amount); + } + + if (tn_is_ml) + { + ShowActivity2(client, "[SM] ", "%t", "Set blind on target", target_name); + } + else + { + ShowActivity2(client, "[SM] ", "%t", "Set blind on target", "_s", target_name); + } + + return Plugin_Handled; +} diff --git a/plugins/basefuncommands/drug.sp b/plugins/basefuncommands/drug.sp new file mode 100644 index 00000000..59da6664 --- /dev/null +++ b/plugins/basefuncommands/drug.sp @@ -0,0 +1,296 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod Basefuncommands Plugin + * Provides drug functionality + * + * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +new Handle:g_DrugTimers[MAXPLAYERS+1]; +new Float:g_DrugAngles[20] = {0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 20.0, 15.0, 10.0, 5.0, 0.0, -5.0, -10.0, -15.0, -20.0, -25.0, -20.0, -15.0, -10.0, -5.0}; + +SetupDrugs() +{ + RegAdminCmd("sm_drug", Command_Drug, ADMFLAG_SLAY, "sm_drug <#userid|name> [0/1]"); +} + +CreateDrug(client) +{ + g_DrugTimers[client] = CreateTimer(1.0, Timer_Drug, client, TIMER_REPEAT); +} + +KillDrug(client) +{ + KillTimer(g_DrugTimers[client]); + g_DrugTimers[client] = INVALID_HANDLE; + + new Float:pos[3]; + GetClientAbsOrigin(client, pos); + new Float:angs[3]; + GetClientEyeAngles(client, angs); + + angs[2] = 0.0; + + TeleportEntity(client, pos, angs, NULL_VECTOR); + + new clients[2]; + clients[0] = client; + + new Handle:message = StartMessageEx(g_FadeUserMsgId, clients, 1); + BfWriteShort(message, 1536); + BfWriteShort(message, 1536); + BfWriteShort(message, (0x0001 | 0x0010)); + BfWriteByte(message, 0); + BfWriteByte(message, 0); + BfWriteByte(message, 0); + BfWriteByte(message, 0); + EndMessage(); +} + +KillAllDrugs() +{ + new maxclients = GetMaxClients(); + for (new i = 1; i <= maxclients; i++) + { + if (g_DrugTimers[i] != INVALID_HANDLE) + { + KillDrug(i); + } + } +} + +PerformDrug(client, target, toggle) +{ + switch (toggle) + { + case (2): + { + if (g_DrugTimers[target] == INVALID_HANDLE) + { + CreateDrug(target); + LogAction(client, target, "\"%L\" drugged \"%L\"", client, target); + } + else + { + KillDrug(target); + LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target); + } + } + + case (1): + { + if (g_DrugTimers[target] == INVALID_HANDLE) + { + CreateDrug(target); + LogAction(client, target, "\"%L\" drugged \"%L\"", client, target); + } + } + + case (0): + { + if (g_DrugTimers[target] != INVALID_HANDLE) + { + KillDrug(target); + LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target); + } + } + } +} + +public Action:Timer_Drug(Handle:timer, any:client) +{ + if (!IsClientInGame(client) || !IsPlayerAlive(client)) + { + KillDrug(client); + + return Plugin_Handled; + } + + new Float:pos[3]; + GetClientAbsOrigin(client, pos); + + new Float:angs[3]; + GetClientEyeAngles(client, angs); + + angs[2] = g_DrugAngles[GetRandomInt(0,100) % 20]; + + TeleportEntity(client, pos, angs, NULL_VECTOR); + + new clients[2]; + clients[0] = client; + + new Handle:message = StartMessageEx(g_FadeUserMsgId, clients, 1); + BfWriteShort(message, 255); + BfWriteShort(message, 255); + BfWriteShort(message, (0x0002)); + BfWriteByte(message, GetRandomInt(0,255)); + BfWriteByte(message, GetRandomInt(0,255)); + BfWriteByte(message, GetRandomInt(0,255)); + BfWriteByte(message, 128); + + EndMessage(); + + return Plugin_Handled; +} + +public AdminMenu_Drug(Handle:topmenu, + TopMenuAction:action, + TopMenuObject:object_id, + param, + String:buffer[], + maxlength) +{ + if (action == TopMenuAction_DisplayOption) + { + Format(buffer, maxlength, "%T", "Drug player", param); + } + else if (action == TopMenuAction_SelectOption) + { + DisplayDrugMenu(param); + } +} + +DisplayDrugMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_Drug); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "Drug player", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddTargetsToMenu(menu, client, true, true); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +public MenuHandler_Drug(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + new String:name[32]; + GetClientName(target, name, sizeof(name)); + + PerformDrug(param1, target, 2); + ShowActivity2(param1, "[SM] ", "%t", "Toggled drug on target", "_s", name); + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayDrugMenu(param1); + } + } +} + +public Action:Command_Drug(client, args) +{ + if (args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_drug <#userid|name> [0/1]"); + return Plugin_Handled; + } + + decl String:arg[65]; + GetCmdArg(1, arg, sizeof(arg)); + + new toggle = 2; + if (args > 1) + { + decl String:arg2[2]; + GetCmdArg(2, arg2, sizeof(arg2)); + if (arg2[0]) + { + toggle = 1; + } + else + { + toggle = 0; + } + } + + decl String:target_name[MAX_TARGET_LENGTH]; + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml; + + if ((target_count = ProcessTargetString( + arg, + client, + target_list, + MAXPLAYERS, + COMMAND_FILTER_ALIVE, + target_name, + sizeof(target_name), + tn_is_ml)) <= 0) + { + ReplyToTargetError(client, target_count); + return Plugin_Handled; + } + + for (new i = 0; i < target_count; i++) + { + PerformDrug(client, target_list[i], toggle); + } + + if (tn_is_ml) + { + ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", target_name); + } + else + { + ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", "_s", target_name); + } + + return Plugin_Handled; +} diff --git a/plugins/basefuncommands/gravity.sp b/plugins/basefuncommands/gravity.sp new file mode 100644 index 00000000..dfb7ece8 --- /dev/null +++ b/plugins/basefuncommands/gravity.sp @@ -0,0 +1,252 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod Basefuncommands Plugin + * Provides gravity functionality + * + * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +new g_GravityTarget[MAXPLAYERS+1]; + +SetupGravity() +{ + RegAdminCmd("sm_gravity", Command_Gravity, ADMFLAG_SLAY, "sm_gravity <#userid|name> [amount] - Leave amount off to reset. Amount is 0.0 through 5.0"); +} + +PerformGravity(client, target, Float:amount) +{ + new offset = FindDataMapOffs(client, "m_flGravity"); + new Float:temp = GetEntDataFloat(client, offset); + PrintToChatAll("Gravity check %f", temp); + + SetEntityGravity(target, amount); + LogAction(client, target, "\"%L\" set gravity on \"%L\" to %d.", client, target, amount); +} + +public AdminMenu_Gravity(Handle:topmenu, + TopMenuAction:action, + TopMenuObject:object_id, + param, + String:buffer[], + maxlength) +{ + if (action == TopMenuAction_DisplayOption) + { + Format(buffer, maxlength, "%T", "Gravity player", param); + } + else if (action == TopMenuAction_SelectOption) + { + DisplayGravityMenu(param); + } +} + +DisplayGravityMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_Gravity); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "Gravity player", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddTargetsToMenu(menu, client, true, true); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +DisplayGravityAmountMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_GravityAmount); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "Gravity amount", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddMenuItem(menu, "4.0", "Gravity Very High"); + AddMenuItem(menu, "2.0", "Gravity High"); + AddMenuItem(menu, "1.0", "Gravity Normal"); + AddMenuItem(menu, "0.5", "Gravity Low"); + AddMenuItem(menu, "0.1", "Gravity Very Low"); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +public MenuHandler_Gravity(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + g_GravityTarget[param1] = userid; + DisplayGravityAmountMenu(param1); + return; // Return, because we went to a new menu and don't want the re-draw to occur. + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayGravityMenu(param1); + } + } + + return; +} + +public MenuHandler_GravityAmount(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new Float:amount, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + amount = StringToFloat(info); + + if ((target = GetClientOfUserId(g_GravityTarget[param1])) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + new String:name[32]; + GetClientName(target, name, sizeof(name)); + + PerformGravity(param1, target, amount); + ShowActivity2(param1, "[SM] ", "%t", "Set gravity on target", "_s", name, amount); + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayGravityMenu(param1); + } + } +} + +public Action:Command_Gravity(client, args) +{ + if (args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_gravity <#userid|name> [amount]"); + return Plugin_Handled; + } + + decl String:arg[65]; + GetCmdArg(1, arg, sizeof(arg)); + + new Float:amount = 1.0; + if (args > 1) + { + decl String:arg2[20]; + GetCmdArg(2, arg2, sizeof(arg2)); + if (StringToFloatEx(arg2, amount) == 0) + { + ReplyToCommand(client, "[SM] %t", "Invalid Amount"); + return Plugin_Handled; + } + + if (amount < 0.0) + { + amount = 0.0; + } + } + + decl String:target_name[MAX_TARGET_LENGTH]; + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml; + + if ((target_count = ProcessTargetString( + arg, + client, + target_list, + MAXPLAYERS, + COMMAND_FILTER_ALIVE, + target_name, + sizeof(target_name), + tn_is_ml)) <= 0) + { + ReplyToTargetError(client, target_count); + return Plugin_Handled; + } + + for (new i = 0; i < target_count; i++) + { + PerformGravity(client, target_list[i], amount); + } + + if (tn_is_ml) + { + ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", target_name); + } + else + { + ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", "_s", target_name); + } + + return Plugin_Handled; +} diff --git a/plugins/basefuncommands/ice.sp b/plugins/basefuncommands/ice.sp index 2066d4a6..976742af 100644 --- a/plugins/basefuncommands/ice.sp +++ b/plugins/basefuncommands/ice.sp @@ -374,7 +374,7 @@ public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2) new String:name[32]; GetClientName(target, name, sizeof(name)); - PerformFreeze(param1, target, 2); + PerformFreeze(param1, target, GetConVarInt(g_FreezeDuration)); ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name); } diff --git a/plugins/basefuncommands/noclip.sp b/plugins/basefuncommands/noclip.sp new file mode 100644 index 00000000..22a074af --- /dev/null +++ b/plugins/basefuncommands/noclip.sp @@ -0,0 +1,175 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod Basefuncommands Plugin + * Provides noclip functionality + * + * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +SetupNoClip() +{ + RegAdminCmd("sm_noclip", Command_NoClip, ADMFLAG_SLAY|ADMFLAG_CHEATS, "sm_noclip <#userid|name>"); +} + +PerformNoClip(client, target) +{ + new movetype = GetEntityMovetype(target); + PrintToChatAll("movetype was %d", movetype); + if (movetype != MOVETYPE_NOCLIP) + { + SetEntityMovetype(target, MOVETYPE_NOCLIP); + } + else + { + SetEntityMovetype(target, MOVETYPE_WALK); + } + + LogAction(client, target, "\"%L\" toggled noclip on \"%L\"", client, target); +} + +public AdminMenu_NoClip(Handle:topmenu, + TopMenuAction:action, + TopMenuObject:object_id, + param, + String:buffer[], + maxlength) +{ + if (action == TopMenuAction_DisplayOption) + { + Format(buffer, maxlength, "%T", "NoClip player", param); + } + else if (action == TopMenuAction_SelectOption) + { + DisplayNoClipMenu(param); + } +} + +DisplayNoClipMenu(client) +{ + new Handle:menu = CreateMenu(MenuHandler_NoClip); + + decl String:title[100]; + Format(title, sizeof(title), "%T:", "NoClip player", client); + SetMenuTitle(menu, title); + SetMenuExitBackButton(menu, true); + + AddTargetsToMenu(menu, client, true, true); + + DisplayMenu(menu, client, MENU_TIME_FOREVER); +} + +public MenuHandler_NoClip(Handle:menu, MenuAction:action, param1, param2) +{ + if (action == MenuAction_End) + { + CloseHandle(menu); + } + else if (action == MenuAction_Cancel) + { + if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE) + { + DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory); + } + } + else if (action == MenuAction_Select) + { + decl String:info[32]; + new userid, target; + + GetMenuItem(menu, param2, info, sizeof(info)); + userid = StringToInt(info); + + if ((target = GetClientOfUserId(userid)) == 0) + { + PrintToChat(param1, "[SM] %t", "Player no longer available"); + } + else if (!CanUserTarget(param1, target)) + { + PrintToChat(param1, "[SM] %t", "Unable to target"); + } + else + { + new String:name[32]; + GetClientName(target, name, sizeof(name)); + + PerformNoClip(param1, target); + ShowActivity2(param1, "[SM] ", "%t", "Toggled noclip on target", "_s", name); + } + + /* Re-draw the menu if they're still valid */ + if (IsClientInGame(param1) && !IsClientInKickQueue(param1)) + { + DisplayNoClipMenu(param1); + } + } +} + +public Action:Command_NoClip(client, args) +{ + if (args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_noclip <#userid|name>"); + return Plugin_Handled; + } + + decl String:arg[65]; + GetCmdArg(1, arg, sizeof(arg)); + + decl String:target_name[MAX_TARGET_LENGTH]; + decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml; + + if ((target_count = ProcessTargetString( + arg, + client, + target_list, + MAXPLAYERS, + COMMAND_FILTER_ALIVE, + target_name, + sizeof(target_name), + tn_is_ml)) <= 0) + { + ReplyToTargetError(client, target_count); + return Plugin_Handled; + } + + for (new i = 0; i < target_count; i++) + { + PerformNoClip(client, target_list[i]); + } + + if (tn_is_ml) + { + ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", target_name); + } + else + { + ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", "_s", target_name); + } + + return Plugin_Handled; +} diff --git a/translations/basefuncommands.phrases.txt b/translations/basefuncommands.phrases.txt index e14a9e8e..1d132c9e 100644 --- a/translations/basefuncommands.phrases.txt +++ b/translations/basefuncommands.phrases.txt @@ -34,7 +34,77 @@ "Beacon player" { "en" "Beacon player" - } + } + + "NoClip player" + { + "en" "NoClip player" + } + + "Blind player" + { + "en" "Blind player" + } + + "Drug player" + { + "en" "Drug player" + } + + "Gravity player" + { + "en" "Gravity player" + } + + "Blind amount" + { + "en" "How blind?" + } + + "Fully blind" + { + "en" "Fully blind" + } + + "Half blind" + { + "en" "Half blind" + } + + "No blind" + { + "en" "No blind" + } + + "Gravity amount" + { + "en" "Gravity?" + } + + "Gravity Very High" + { + "en" "Gravity Very High" + } + + "Gravity High" + { + "en" "Gravity High" + } + + "Gravity Normal" + { + "en" "Gravity Normal" + } + + "Gravity Low" + { + "en" "Gravity Low" + } + + "Gravity Very Low" + { + "en" "Gravity Very Low" + } "Set target on fire" { @@ -45,7 +115,7 @@ "Toggled FireBomb on target" { "#format" "{1:t}" - "en" "set a firebomb on {1}." + "en" "toggled firebomb on {1}." } "Froze target" @@ -57,7 +127,7 @@ "Toggled FreezeBomb on target" { "#format" "{1:t}" - "en" "set a freezebomb on {1}." + "en" "toggled freezebomb on {1}." } "Toggled beacon on target" @@ -69,7 +139,31 @@ "Toggled TimeBomb on target" { "#format" "{1:t}" - "en" "set a timebomb on {1}." + "en" "toggled timebomb on {1}." + } + + "Toggled noclip on target" + { + "#format" "{1:t}" + "en" "toggled noclip on {1}." + } + + "Toggled drug on target" + { + "#format" "{1:t}" + "en" "toggled drugs on {1}." + } + + "Set blind on target" + { + "#format" "{1:t}" + "en" "used blind on {1}." + } + + "Set gravity on target" + { + "#format" "{1:t}" + "en" "set {1}'s gravity." } "Till Explodes"