From 72bea7dffc02bf6badc09ee8970753c0546db44a Mon Sep 17 00:00:00 2001 From: Moltard Date: Sat, 25 Dec 2021 18:52:48 +0100 Subject: [PATCH] Added DisguisePlugin, FunSuperAdmin and PropSpawner. Changed the flag used in them to g --- DisguisePlugin/configs/DisguisePlugin.cfg | 114 ++ DisguisePlugin/scripting/DisguisePlugin.sp | 322 +++++ FunSuperAdmin/scripting/FunSuperAdmin.sp | 1492 ++++++++++++++++++++ PropSpawner/configs/PropSpawner.cfg | 307 ++++ PropSpawner/scripting/PropSpawner.sp | 490 +++++++ 5 files changed, 2725 insertions(+) create mode 100644 DisguisePlugin/configs/DisguisePlugin.cfg create mode 100644 DisguisePlugin/scripting/DisguisePlugin.sp create mode 100644 FunSuperAdmin/scripting/FunSuperAdmin.sp create mode 100644 PropSpawner/configs/PropSpawner.cfg create mode 100644 PropSpawner/scripting/PropSpawner.sp diff --git a/DisguisePlugin/configs/DisguisePlugin.cfg b/DisguisePlugin/configs/DisguisePlugin.cfg new file mode 100644 index 00000000..7d751720 --- /dev/null +++ b/DisguisePlugin/configs/DisguisePlugin.cfg @@ -0,0 +1,114 @@ +"models" +{ + "0" + { + "name" "Rock" + "model" "models/props/de_inferno/de_inferno_boulder_01.mdl" + } + "1" + { + "name" "Antlion" + "model" "models/antlion.mdl" + } + "2" + { + "name" "Barricade" + "model" "models/props_wasteland/barricade001a.mdl" + } + "3" + { + "name" "Barrel" + "model" "models/props_c17/oildrum001.mdl" + } + "4" + { + "name" "Beware of Dog Sign" + "model" "models/props_lab/bewaredog.mdl" + } + "5" + { + "name" "Bicycle" + "model" "models/props_junk/bicycle01a.mdl" + } + "6" + { + "name" "Cactus" + "model" "models/props/de_inferno/cactus.mdl" + } + "7" + { + "name" "Wine Barrel" + "model" "models/props/de_inferno/wine_barrel.mdl" + } + "8" + { + "name" "Zombie" + "model" "models/zombie/classic.mdl" + } + "9" + { + "name" "Crow" + "model" "models/crow.mdl" + } + "10" + { + "name" "Fern" + "model" "models/props/cs_militia/fern01.mdl" + } + "11" + { + "name" "Float" + "model" "models/props/de_nuke/lifepreserver.mdl" + } + "12" + { + "name" "Flower Barrel" + "model" "models/props/de_inferno/flower_barrel.mdl" + } + "13" + { + "name" "Fruit Crate" + "model" "models/props/de_inferno/crate_fruit_break.mdl" + } + "14" + { + "name" "Headcrab" + "model" "models/headcrabclassic.mdl" + } + "15" + { + "name" "Mysterious Man" + "model" "models/player.mdl" + } + "16" + { + "name" "Pigeon" + "model" "models/pigeon.mdl" + } + "17" + { + "name" "Seagull" + "model" "models/seagull.mdl" + } + "18" + { + "name" "Poison Headcrab" + "model" "models/headcrabblack.mdl" + } + "19" + { + "name" "Small Statue" + "model" "models/props_combine/breenbust.mdl" + } + "20" + { + "name" "Snowman Head" + "model" "models/props/cs_office/snowman_face.mdl" + } + "21" + { + "name" "Turret" + "model" "models/combine_turrets/floor_turret.mdl" + } + +} \ No newline at end of file diff --git a/DisguisePlugin/scripting/DisguisePlugin.sp b/DisguisePlugin/scripting/DisguisePlugin.sp new file mode 100644 index 00000000..1cbf9276 --- /dev/null +++ b/DisguisePlugin/scripting/DisguisePlugin.sp @@ -0,0 +1,322 @@ +#pragma semicolon 1 +#include +#include + +public Plugin myinfo = +{ + name = "Disguise Plugin", + author = "Moltard / LightningZLaser", + description = "A plugin to disguise players", + version = "0.1", + url = "https://steamcommunity.com/id/0123456789ABC/" +}; + +Menu g_MainMenu = null; +Menu g_ModelsMenu = null; +Menu g_PlayerMenuD = null; +Menu g_PlayerMenuU = null; + +KeyValues g_Models; + +int DisguiseStatus[MAXPLAYERS + 1] = 0; // List of players that have a disguise +char DisguisePickedOption[MAXPLAYERS + 1][32]; // Save the model id selected by the admin +char OriginalPlayerModel[MAXPLAYERS + 1][128]; // Save the playermodel of the player before changing it + + +public void OnPluginStart() +{ + LoadTranslations("common.phrases"); + char sModelsFile[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, sModelsFile, sizeof(sModelsFile), "configs/DisguisePlugin.cfg"); + + if(!FileExists(sModelsFile)) + { + SetFailState("Could not find config: \"%s\"", sModelsFile); + return; + } + + g_Models = new KeyValues("models"); + if(!g_Models.ImportFromFile(sModelsFile)) + { + delete g_Models; + SetFailState("ImportFromFile() failed!"); + return; + } + g_Models.Rewind(); // Go back to the root node + + HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); + RegAdminCmd("sm_disguise", Command_MainMenu, ADMFLAG_CHANGEMAP); //g +} + +public void OnMapStart() +{ + g_Models.Rewind(); + g_MainMenu = BuildMainMenu(); + g_ModelsMenu = BuildModelsMenu(); + g_PlayerMenuD = InitPlayerMenu(true); + g_PlayerMenuU = InitPlayerMenu(false); +} + +public void OnMapEnd() +{ + if (g_MainMenu != null) + { + delete(g_MainMenu); + g_MainMenu = null; + } + if (g_ModelsMenu != null) + { + delete(g_ModelsMenu); + g_ModelsMenu = null; + } + if (g_PlayerMenuD != null) + { + delete(g_PlayerMenuD); + g_PlayerMenuD = null; + } + if (g_PlayerMenuU != null) + { + delete(g_PlayerMenuU); + g_PlayerMenuU = null; + } +} + +public OnRoundStart(Handle event, const String:name[], bool dontBroadcast) +{ + for (int i = 1; i <= (GetMaxClients()); i++) + { + if (IsValidEntity(i)) + { + DisguiseStatus[i] = 0; + OriginalPlayerModel[i] = ""; + DisguisePickedOption[i] = ""; + } + } +} + +public void OnClientDisconnect(int client){ + DisguiseStatus[client] = 0; + OriginalPlayerModel[client] = ""; + DisguisePickedOption[client] = ""; +} + +/* ----------------------------------- */ + +Menu BuildMainMenu(){ + Menu menu = new Menu(MainMenuHandler); + menu.SetTitle("Disguise Plugin"); + menu.AddItem("menu_disguise", "Disguise Player"); + menu.AddItem("menu_undisguise", "Undisguise Player"); + menu.ExitButton = true; + return menu; +} + + +Menu BuildModelsMenu(){ + + g_Models.Rewind(); // Go back to the root node + Menu menu; + menu = new Menu(ModelsMenuHandler); + menu.SetTitle("Select Disguise"); + menu.AddItem("menu_undisguise", "Undisguise"); + + for(int i = 0; i < 100000; i++){ + char sName[32]; char sIndex[11]; + IntToString(i,sIndex, sizeof(sIndex)); // Index i of the model + if (!(g_Models.JumpToKey(sIndex, false))) // if the key doesnt exist + break; // we stop the loop + g_Models.GetString("name", sName, sizeof(sName)); // Name of the model + menu.AddItem(sIndex,sName); + g_Models.GoBack(); // First sub key of the model category + } + + g_Models.Rewind(); // Go back to the root node + menu.ExitBackButton = true; + menu.ExitButton = true; + return menu; +} + +/* ----------------------------------- */ + +Menu InitPlayerMenu(bool bl_disguise){ + Menu menu = null; + if(bl_disguise){ + menu = new Menu(DisguiseHandle); + menu.SetTitle("Select Player to Disguise"); + } + else{ + menu = new Menu(UndisguiseHandle); + menu.SetTitle("Select Player to Undisguise"); + } + menu.ExitBackButton = true; + menu.ExitButton = true; + return menu; +} + + + +void BuildPlayerMenu(bool bl_disguise){ + + if(bl_disguise){ // If we come from the Disguise menu + g_PlayerMenuD.RemoveAllItems(); + } + else{ // If we come from the Undisguise + g_PlayerMenuU.RemoveAllItems(); + } + for (int i = 1; i <= GetMaxClients(); i++) + { + if ((IsClientInGame(i)) && IsPlayerAlive(i)) + { + char sIndex[11]; + IntToString(GetClientSerial(i),sIndex, sizeof(sIndex)); // Serial of the player + + char playerName[64]; char labelName[64]; + GetClientName(i, playerName, sizeof(playerName)); + if (DisguiseStatus[i] == 1) + { + Format(labelName,sizeof(labelName),"[DISGUISED] %s",playerName); // [DISGUISED] Name + } + else if (DisguiseStatus[i] == 0) + { + labelName = playerName; // Name + } + if(bl_disguise){ // If we come from the Disguise menu + g_PlayerMenuD.AddItem(sIndex,labelName); + } + else{ // If we come from the Undisguise + g_PlayerMenuU.AddItem(sIndex,labelName); + } + } + } +} + +/* ----------------------------------- */ + +public Action Command_MainMenu(int client, int args) +{ + g_MainMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; +} + +public MainMenuHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "menu_disguise")){ + g_ModelsMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_undisguise")){ + BuildPlayerMenu(false); + g_PlayerMenuU.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public ModelsMenuHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "menu_undisguise")) + { + BuildPlayerMenu(false); + g_PlayerMenuU.Display(client, MENU_TIME_FOREVER); + } + else{ + // Info has the index of the model + DisguisePickedOption[client] = info; // we set the index selected by the admin + + BuildPlayerMenu(true); + g_PlayerMenuD.Display(client, MENU_TIME_FOREVER); + } + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public DisguiseHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + if(g_Models.JumpToKey(DisguisePickedOption[client], false)){ + if (DisguiseStatus[playerId] == 0){ // We set the status of the player to disguised + GetClientModel(playerId, OriginalPlayerModel[playerId], 128); + DisguiseStatus[playerId] = 1; + } + char sModelName[64]; + g_Models.GetString("name", sModelName, sizeof(sModelName)); // Name of the model + + char sModelPath[128]; + g_Models.GetString("model", sModelPath, sizeof(sModelPath)); // Path of the model + + PrecacheModel(sModelPath, false); + SetEntityModel(playerId, sModelPath); + + ShowActivity2(client, "\x01[SM] \x04", "\x01disguised %N (Model: \x04%s\x01).",playerId,sModelName); + LogAction(client, -1, "\"%L\" disguised \"%L\" (Model: %s).", client,playerId,sModelName); + } + g_Models.Rewind(); + } + BuildPlayerMenu(true); + g_PlayerMenuD.Display(client, MENU_TIME_FOREVER); // Display again the player menu + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + DisguisePickedOption[client] = ""; + g_ModelsMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public UndisguiseHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + if (DisguiseStatus[playerId] == 0){ // We set the status of the player to disguised + PrintToChat(client, "\x01[SM]\x04 Player is not disguised"); + } + else if (DisguiseStatus[playerId] == 1) + { + PrecacheModel(OriginalPlayerModel[playerId], false); + SetEntityModel(playerId, OriginalPlayerModel[playerId]); + DisguiseStatus[playerId] = 0; + ShowActivity2(client, "\x01[SM] \x04", "\x01undisguised %N.",playerId); + LogAction(client, -1, "\"%L\" undisguised \"%L\".", client,playerId); + } + } + BuildPlayerMenu(false); + g_PlayerMenuU.Display(client, MENU_TIME_FOREVER); // Display again the player menu + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} \ No newline at end of file diff --git a/FunSuperAdmin/scripting/FunSuperAdmin.sp b/FunSuperAdmin/scripting/FunSuperAdmin.sp new file mode 100644 index 00000000..07a23631 --- /dev/null +++ b/FunSuperAdmin/scripting/FunSuperAdmin.sp @@ -0,0 +1,1492 @@ +#pragma semicolon 1 +#include +#include + +public Plugin myinfo = +{ + name = "Fun Super Admin", + author = "Moltard / LightningZLaser", + description = "Admin Plugin with fun commands", + version = "0.1", + url = "https://steamcommunity.com/id/0123456789ABC/" +}; + +Menu g_MainMenu = null; +Menu g_BuryMenu = null; +Menu g_UnburyMenu = null; +Menu g_GodMenu = null; +Menu g_InvisMenu = null; +Menu g_JetpackMenu = null; +Menu g_RegenMenu = null; +Menu g_RocketMenu = null; + +int GodStatus[MAXPLAYERS + 1] = 0; // List of players that have god mode +int InvisStatus[MAXPLAYERS + 1] = 0; // List of players that have invisibility +int JetpackStatus[MAXPLAYERS + 1] = 0; // List of players that have a jetpack +int RegenStatus[MAXPLAYERS + 1] = 0; // List of players that have regen mode +int RocketStatus[MAXPLAYERS + 1] = 0; // List of players that are in rocket mode + +bool bl_RegenInit = false; // Prevent the timer from looking at each player until the command is used once + +ConVar g_RocketMode; +ConVar g_RocketKill; +ConVar g_RocketSpeed; +bool bl_RocketMode_1 = false; +bool bl_RocketMode_2 = false; +bool bl_RocketInit = false; // Prevent the timer from executing until the command is used once +new rocketSprite[MAXPLAYERS + 1]; // Will contain the env_spritetrail created + +int g_RocketPosition[MAXPLAYERS + 1] = 1; // To alternate between Origin Z1 and Origin Z2 +float g_Rocket_Vec1[MAXPLAYERS + 1][3]; +float g_Rocket_Vec2[MAXPLAYERS + 1][3]; +float g_Rocket_Z1[MAXPLAYERS + 1] = 0.0; +float g_Rocket_Z2[MAXPLAYERS + 1] = 1.0; + +public void OnPluginStart() +{ + LoadTranslations("common.phrases"); + + HookEvent("round_start", OnRoundStart, EventHookMode_PostNoCopy); + HookEvent("player_death", OnPlayerDie, EventHookMode_PostNoCopy); + + RegAdminCmd("sm_fsa", Command_MainMenu, ADMFLAG_CHANGEMAP); // g + RegAdminCmd("sm_bury", Command_Bury, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_unbury", Command_Unbury, ADMFLAG_CHANGEMAP); + + RegAdminCmd("sm_god", Command_God, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_godmode", Command_God, ADMFLAG_CHANGEMAP); + +// RegAdminCmd("sm_alpha", Command_Alpha, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_invis", Command_Invis, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_invisible", Command_Invis, ADMFLAG_CHANGEMAP); + + RegAdminCmd("sm_jet", Command_Jetpack, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_jetpack", Command_Jetpack, ADMFLAG_CHANGEMAP); + + RegAdminCmd("sm_regen", Command_Regen, ADMFLAG_CHANGEMAP); + CreateTimer(1.5, Timer_Regeneration, _, TIMER_REPEAT); + + RegAdminCmd("sm_stealcookies", Command_Cookies, ADMFLAG_CHANGEMAP); + RegAdminCmd("sm_givecookies", Command_Cookies2, ADMFLAG_CHANGEMAP); + + RegAdminCmd("sm_rocket", Command_Rocket, ADMFLAG_CHANGEMAP); + CreateTimer(0.1, Timer_Rocket, _, TIMER_REPEAT); + + CreateConVar("fsa_rocket_type", "2", "Rocket type 1 does not work in Zombie: Reloaded while rocket type 2 does", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); + g_RocketMode = FindConVar("fsa_rocket_type"); + if (g_RocketMode != null) + { + g_RocketMode.AddChangeHook(OnRocketModeChange); + } + + CreateConVar("fsa_rocket_will_kill", "0", "Set to 1 so that players will die when rocketted", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); + g_RocketKill = FindConVar("fsa_rocket_will_kill"); + if (g_RocketKill != null) + { + g_RocketKill.AddChangeHook(OnRocketKillChange); + } + + CreateConVar("fsa_rocket_speed", "20.0", "Sets rocket speed. Important note: Must be higher than 5 (6 at least)", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); + g_RocketSpeed = FindConVar("fsa_rocket_speed"); + if (g_RocketSpeed != null) + { + g_RocketSpeed.AddChangeHook(OnRocketSpeedChange); + } +} + +public void OnRocketModeChange(ConVar convar, char[] oldValue, char[] newValue) +{ + if (StringToInt(newValue) == 1) + { + convar.IntValue = 1; + bl_RocketMode_1 = true; + bl_RocketMode_2 = false; + } + else if (StringToInt(newValue) == 2){ + convar.IntValue = 2; + bl_RocketMode_1 = false; + bl_RocketMode_2 = true; + } + else{ + convar.IntValue = StringToInt(oldValue); + } +} + +public void OnRocketSpeedChange(ConVar convar, char[] oldValue, char[] newValue) +{ + if (StringToFloat(newValue) != 0) + { + if (StringToFloat(newValue) >= 6){ + convar.FloatValue = StringToFloat(newValue); + } + else{ + convar.FloatValue = 6.0; + } + } + else{ + convar.FloatValue = StringToFloat(oldValue); + } +} + +public void OnRocketKillChange(ConVar convar, char[] oldValue, char[] newValue) +{ + if (StringToInt(newValue) == 0) + { + convar.IntValue = 0; + } + else if(StringToInt(newValue) == 1){ + convar.IntValue = 1; + } + else{ + convar.IntValue = StringToInt(oldValue); + } +} + +public void OnMapStart() +{ + g_MainMenu = BuildMainMenu(); + g_BuryMenu = InitAllPlayersMenu("bury"); + g_UnburyMenu = InitAllPlayersMenu("unbury"); + g_GodMenu = InitAllPlayersMenu("god"); + g_InvisMenu = InitAllPlayersMenu("invis"); + g_JetpackMenu = InitAllPlayersMenu("jetpack"); + g_RegenMenu = InitAllPlayersMenu("regen"); + g_RocketMenu = InitAllPlayersMenu("rocket"); + + if (g_RocketMode != null) + { + if(g_RocketMode.IntValue == 1){ + bl_RocketMode_1 = true; + bl_RocketMode_2 = false; + } + else{ + bl_RocketMode_1 = false; + bl_RocketMode_2 = true; + } + } + // Precache for rocket + PrecacheModel("sprites/sprite_fire01.vmt", false); + PrecacheSound("weapons/rpg/rocketfire1.wav", false); + PrecacheSound("weapons/rpg/rocket1.wav", false); + PrecacheSound("weapons/explode3.wav", false); + +} + +public void OnMapEnd() +{ + if (g_MainMenu != null) + { + delete(g_MainMenu); + g_MainMenu = null; + } + if (g_BuryMenu != null) + { + delete(g_BuryMenu); + g_BuryMenu = null; + } + if (g_UnburyMenu != null) + { + delete(g_UnburyMenu); + g_UnburyMenu = null; + } + if (g_GodMenu != null) + { + delete(g_GodMenu); + g_GodMenu = null; + } + if (g_InvisMenu != null) + { + delete(g_InvisMenu); + g_InvisMenu = null; + } + if (g_JetpackMenu != null) + { + delete(g_JetpackMenu); + g_JetpackMenu = null; + } + if (g_RegenMenu != null) + { + delete(g_RegenMenu); + g_RegenMenu = null; + } + if (g_RocketMenu != null) + { + delete(g_RocketMenu); + g_RocketMenu = null; + } + +} + +public OnRoundStart(Handle event, const String:name[], bool dontBroadcast) +{ + bl_RegenInit = false; + bl_RocketInit = false; + for(int i = 1; i <= (GetMaxClients()); i++){ + if(IsValidEntity(i)){ + GodStatus[i] = 0; + InvisStatus[i] = 0; + JetpackStatus[i] = 0; + RegenStatus[i] = 0; + RocketStatus[i] = 0; + SetEntityGravity(i, 1.0); + + if((IsClientInGame(i)) && (IsPlayerAlive(i))){ + SetEntityRenderMode(i, RENDER_NORMAL); + } + } + } +} + +public OnPlayerDie(Handle event, const String:name[], bool dontBroadcast) +{ + int idClient = GetClientOfUserId(GetEventInt(event, "userid")); // Get Player's userid + if(IsValidEntity(idClient)){ + GodStatus[idClient] = 0; + InvisStatus[idClient] = 0; + JetpackStatus[idClient] = 0; + RegenStatus[idClient] = 0; + RocketStatus[idClient] = 0; + SetEntityGravity(idClient, 1.0); + } +} + +public void OnClientDisconnect(int client){ + GodStatus[client] = 0; + JetpackStatus[client] = 0; + RegenStatus[client] = 0; + RocketStatus[client] = 0; +} + +/* ----------------------------------- */ + +Menu BuildMainMenu(){ + Menu menu = new Menu(MainMenuHandler); + menu.SetTitle("Fun Super Admin"); + menu.AddItem("menu_rocket_debug", "Fix Rocket Spam"); + menu.AddItem("menu_rocket", "Rocket"); + menu.AddItem("menu_bury", "Bury"); + menu.AddItem("menu_unbury", "Unbury"); + menu.AddItem("menu_god", "Godmode"); + menu.AddItem("menu_invisible", "Invisible"); + menu.AddItem("menu_jetpack", "Jetpack"); + menu.AddItem("menu_regen", "Regeneration"); + + menu.ExitBackButton = true; + return menu; +} + +void displayMainMenu(client){ + g_MainMenu.Display(client, MENU_TIME_FOREVER); +} + +public Action Command_MainMenu(int client, int args) +{ + displayMainMenu(client); + return Plugin_Handled; +} + +public MainMenuHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "menu_bury")){ + BuildPlayerMenu("bury"); + g_BuryMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_unbury")){ + BuildPlayerMenu("unbury"); + g_UnburyMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_god")){ + BuildPlayerMenu("god"); + g_GodMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_invisible")){ + BuildPlayerMenu("invis"); + g_InvisMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_jetpack")){ + BuildPlayerMenu("jetpack"); + g_JetpackMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_regen")){ + BuildPlayerMenu("regen"); + g_RegenMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_rocket")){ + BuildPlayerMenu("rocket"); + g_RocketMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_rocket_debug")){ + StopAllRocketSound(); + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +/* ----------------------------------- */ + +Menu InitAllPlayersMenu(char[] menuType){ + Menu menu = null; + if(StrEqual(menuType, "bury")) + { + menu = new Menu(BuryHandle); + menu.SetTitle("Select Player to Bury"); + } + else if(StrEqual(menuType, "unbury")) + { + menu = new Menu(UnburyHandle); + menu.SetTitle("Select Player to Unbury"); + } + else if(StrEqual(menuType, "god")) + { + menu = new Menu(GodHandle); + menu.SetTitle("Select Player for Godmode"); + } + else if(StrEqual(menuType, "invis")) + { + menu = new Menu(InvisHandle); + menu.SetTitle("Select Player for Invisibility"); + } + else if(StrEqual(menuType, "jetpack")) + { + menu = new Menu(JetpackHandle); + menu.SetTitle("Select Player to Give/Remove Jetpack"); + } + else if(StrEqual(menuType, "regen")) + { + menu = new Menu(RegenHandle); + menu.SetTitle("Select Player to Give/Remove Regeneration"); + } + else if(StrEqual(menuType, "rocket")) + { + menu = new Menu(RocketHandle); + menu.SetTitle("Select Player to turn into a Rocket"); + } + menu.ExitBackButton = true; + menu.ExitButton = true; + return menu; +} + + +void BuildPlayerMenu(char[] menuType){ + + if(StrEqual(menuType, "bury")) + { + g_BuryMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "unbury")) + { + g_UnburyMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "god")) + { + g_GodMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "invis")) + { + g_InvisMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "jetpack")) + { + g_JetpackMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "regen")) + { + g_RegenMenu.RemoveAllItems(); + } + else if(StrEqual(menuType, "rocket")) + { + g_RocketMenu.RemoveAllItems(); + } + for (int i = 1; i <= GetMaxClients(); i++) + { + if ((IsClientInGame(i)) && IsPlayerAlive(i)) + { + char sIndex[11]; + IntToString(GetClientSerial(i),sIndex, sizeof(sIndex)); // Serial of the player + + char playerName[64]; char labelName[64]; + GetClientName(i, playerName, sizeof(playerName)); + + if (GodStatus[i] == 1 && StrEqual(menuType, "god")) + { + Format(labelName,sizeof(labelName),"[GOD] %s",playerName); // [GOD] Name + } + else if (InvisStatus[i] == 1 && StrEqual(menuType, "invis")) + { + Format(labelName,sizeof(labelName),"[INVISIBLE] %s",playerName); // [JETPACK] Name + } + else if (JetpackStatus[i] == 1 && StrEqual(menuType, "jetpack")) + { + Format(labelName,sizeof(labelName),"[JETPACK] %s",playerName); // [JETPACK] Name + } + else if (RegenStatus[i] == 1 && StrEqual(menuType, "regen")) + { + Format(labelName,sizeof(labelName),"[REGEN] %s",playerName); // [REGEN] Name + } + else if (RocketStatus[i] == 1 && StrEqual(menuType, "rocket")) + { + Format(labelName,sizeof(labelName),"[ROCKET] %s",playerName); // [ROCKET] Name + } + else + { + labelName = playerName; // Name + } + + if(StrEqual(menuType, "bury")) + { + g_BuryMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "unbury")) + { + g_UnburyMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "god")) + { + g_GodMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "invis")) + { + g_InvisMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "jetpack")) + { + g_JetpackMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "regen")) + { + g_RegenMenu.AddItem(sIndex,labelName); + } + else if(StrEqual(menuType, "rocket")) + { + g_RocketMenu.AddItem(sIndex,labelName); + } + } + } +} + + + +/* ----------------------------------- */ + +public Action Command_Bury(int client, int args) +{ + if(args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_bury [#userid|name]"); + BuildPlayerMenu("bury"); + g_BuryMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 1) + { + char sArgs[64]; + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + for(int i = 0; i < iTargetCount; i++) + { + float buryOrigin[3]; + GetClientAbsOrigin(iTargets[i], buryOrigin); + buryOrigin[2] = buryOrigin[2] - 50; + TeleportEntity(iTargets[i], buryOrigin, NULL_VECTOR, NULL_VECTOR); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Buried \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" buried \"%s\".", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" buried \"%L\".", client, iTargets[0]); + + return Plugin_Handled; + } + else // args > 1 + { + ReplyToCommand(client, "[SM] Usage: sm_bury [#userid|name]"); + return Plugin_Handled; + } +} + +public Action Command_Unbury(int client, int args) +{ + if(args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_unbury [#userid|name]"); + BuildPlayerMenu("unbury"); + g_UnburyMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 1) + { + char sArgs[64]; + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + for(int i = 0; i < iTargetCount; i++) + { + float buryOrigin[3]; + GetClientAbsOrigin(iTargets[i], buryOrigin); + buryOrigin[2] = buryOrigin[2] + 50; + TeleportEntity(iTargets[i], buryOrigin, NULL_VECTOR, NULL_VECTOR); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Unburied \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" unburied \"%s\".", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" unburied \"%L\".", client, iTargets[0]); + + return Plugin_Handled; + } + else // args > 1 + { + ReplyToCommand(client, "[SM] Usage: sm_unbury [#userid|name]"); + return Plugin_Handled; + } +} + +public BuryHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + float buryOrigin[3]; + GetClientAbsOrigin(playerId, buryOrigin); + buryOrigin[2] = buryOrigin[2] - 50; + TeleportEntity(playerId, buryOrigin, NULL_VECTOR, NULL_VECTOR); + + ShowActivity2(client, "\x01[SM] \x04", "\x01Buried \x04%N\x01.", playerId); + LogAction(client, playerId, "\"%L\" buried \"%L\".", client,playerId); + } + BuildPlayerMenu("bury"); + g_BuryMenu.Display(client, MENU_TIME_FOREVER); // Display again the player menu + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public UnburyHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + float buryOrigin[3]; + GetClientAbsOrigin(playerId, buryOrigin); + buryOrigin[2] = buryOrigin[2] + 50; + TeleportEntity(playerId, buryOrigin, NULL_VECTOR, NULL_VECTOR); + + ShowActivity2(client, "\x01[SM] \x04", "\x01Unburied \x04%N\x01.", playerId); + LogAction(client, playerId, "\"%L\" unburied \"%L\".", client,playerId); + } + BuildPlayerMenu("unbury"); + g_UnburyMenu.Display(client, MENU_TIME_FOREVER); // Display again the player menu + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +/* ----------------------------------- */ + +public Action Command_God(int client, int args) +{ + if(args < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_god [#userid|name] [0/1]"); + BuildPlayerMenu("god"); + g_GodMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 2) + { + char sArgs[64]; + char sValueGod[11]; + int iValueGod; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sValueGod, sizeof(sValueGod)); + iValueGod = StringToInt(sValueGod); + if(iValueGod != 0){ // If the value is anything but 0, we set 1 + iValueGod = 1; + } + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + if(iValueGod == 1){ // Add GodMode + for(int i = 0; i < iTargetCount; i++) + { + GodStatus[iTargets[i]] = 1; + SetEntProp(iTargets[i], Prop_Data, "m_takedamage", 0, 1); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave Godmode to \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" gave Godmode to \"%s\".", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" gave Godmode to \"%L\".", client, iTargets[0]); + } + else{ // Remove GodMode + for(int i = 0; i < iTargetCount; i++) + { + GodStatus[iTargets[i]] = 0; + SetEntProp(iTargets[i], Prop_Data, "m_takedamage", 2, 1); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%s\x01's Godmode.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" removed \"%s\"'s Godmode.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" removed \"%L\"'s Godmode.", client, iTargets[0]); + } + return Plugin_Handled; + } + else // args > 2 + { + ReplyToCommand(client, "[SM] Usage: sm_god [#userid|name] [0/1]"); + return Plugin_Handled; + } +} + + +public GodHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + if(GodStatus[playerId] == 0){ // Player doesnt have god mode + GodStatus[playerId] = 1; + SetEntProp(playerId, Prop_Data, "m_takedamage", 0, 1); + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave Godmode to \x04%N\x01.", playerId); + LogAction(client, playerId, "\"%L\" gave Godmode to \"%L\".", client, playerId); + } + else{ // Player already has god mode + GodStatus[playerId] = 0; + SetEntProp(playerId, Prop_Data, "m_takedamage", 2, 1); + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%N\x01's Godmode.", playerId); + LogAction(client, playerId, "\"%L\" removed \"%L\"'s Godmode.", client, playerId); + } + } + BuildPlayerMenu("god"); + g_GodMenu.Display(client, MENU_TIME_FOREVER); + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +/* ----------------------------------- */ + + +public Action Command_Invis(int client, int args) +{ + if(args < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_invis [#userid|name] [0/1]"); + BuildPlayerMenu("invis"); + g_InvisMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 2) + { + char sArgs[64]; + char sValueInvis[11]; + int iValueInvis; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sValueInvis, sizeof(sValueInvis)); + iValueInvis = StringToInt(sValueInvis); + if(iValueInvis != 0){ // If the value is anything but 0, we set 1 + iValueInvis = 1; + } + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + if(iValueInvis == 1){ // Set Invisibility + for(int i = 0; i < iTargetCount; i++) + { + InvisStatus[iTargets[i]] = 1; + SetEntityRenderMode(iTargets[i], RENDER_NONE); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Turned \x04%s\x01 invisible.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" turned \"%s\" invisible.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" turned \"%L\" invisible.", client, iTargets[0]); + } + else{ // Remove Invisibility + for(int i = 0; i < iTargetCount; i++) + { + InvisStatus[iTargets[i]] = 0; + SetEntityRenderMode(iTargets[i], RENDER_NORMAL); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Made \x04%s\x01 visible.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" made \"%s\" visible.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" made \"%L\" visible.", client, iTargets[0]); + } + return Plugin_Handled; + } + else // args > 2 + { + ReplyToCommand(client, "[SM] Usage: sm_invis [#userid|name] [0/1]"); + return Plugin_Handled; + } +} + + +public InvisHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + if(InvisStatus[playerId] == 0){ // Player isnt invisible + InvisStatus[playerId] = 1; + SetEntityRenderMode(playerId, RENDER_NONE); + ShowActivity2(client, "\x01[SM] \x04", "\x01Turned \x04%N\x01 invisible.", playerId); + LogAction(client, playerId, "\"%L\" turned \"%L\" invisible.", client, playerId); + } + else{ // Player is invisible + InvisStatus[playerId] = 0; + SetEntityRenderMode(playerId, RENDER_NORMAL); + ShowActivity2(client, "\x01[SM] \x04", "\x01Made \x04%N\x01 visible.", playerId); + LogAction(client, playerId, "\"%L\" made \"%L\" visible.", client, playerId); + } + } + BuildPlayerMenu("invis"); + g_InvisMenu.Display(client, MENU_TIME_FOREVER); + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +/* ----------------------------------- */ + +public Action Command_Jetpack(int client, int args) +{ + if(args < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_jetpack [#userid|name] [0/1]"); + BuildPlayerMenu("jetpack"); + g_JetpackMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 2) + { + char sArgs[64]; + char sValueJet[11]; + int iValueJet; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sValueJet, sizeof(sValueJet)); + iValueJet = StringToInt(sValueJet); + if(iValueJet != 0){ // If the value is anything but 0, we set 1 + iValueJet = 1; + } + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + if(iValueJet == 1){ // Set Jetpack + for(int i = 0; i < iTargetCount; i++) + { + JetpackStatus[iTargets[i]] = 1; + SetEntityMoveType(iTargets[i], MOVETYPE_FLY); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave Jetpack to \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" gave Jetpack to \"%s\".", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" gave Jetpack to \"%L\".", client, iTargets[0]); + } + else{ // Remove Jetpack + for(int i = 0; i < iTargetCount; i++) + { + JetpackStatus[iTargets[i]] = 0; + SetEntityMoveType(iTargets[i], MOVETYPE_WALK); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%s\x01's Jetpack.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" removed \"%s\"'s Jetpack.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" removed \"%L\"'s Jetpack.", client, iTargets[0]); + } + return Plugin_Handled; + } + else // args > 2 + { + ReplyToCommand(client, "[SM] Usage: sm_jetpack [#userid|name] [0/1]"); + return Plugin_Handled; + } +} + + +public JetpackHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + if(JetpackStatus[playerId] == 0){ // Player has no jetpack + JetpackStatus[playerId] = 1; + SetEntityMoveType(playerId, MOVETYPE_FLY); + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave Jetpack to \x04%N\x01.", playerId); + LogAction(client, playerId, "\"%L\" gave Jetpack to \"%L\".", client, playerId); + } + else{ // Player has a jetpack + JetpackStatus[playerId] = 0; + SetEntityMoveType(playerId, MOVETYPE_WALK); + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%N\x01's Jetpack.", playerId); + LogAction(client, playerId, "\"%L\" removed \"%L\"'s Jetpack.", client, playerId); + } + } + BuildPlayerMenu("jetpack"); + g_JetpackMenu.Display(client, MENU_TIME_FOREVER); + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +/* ----------------------------------- */ + +public Action Command_Regen(int client, int args) +{ + if(args < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_regen [#userid|name] [0/1]"); + BuildPlayerMenu("regen"); + g_RegenMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 2) + { + char sArgs[64]; + char sValueRegen[11]; + int iValueRegen; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sValueRegen, sizeof(sValueRegen)); + iValueRegen = StringToInt(sValueRegen); + if(iValueRegen != 0){ // If the value is anything but 0, we set 1 + iValueRegen = 1; + } + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + bl_RegenInit = true; + if(iValueRegen == 1){ // Add Regeneration + for(int i = 0; i < iTargetCount; i++) + { + RegenStatus[iTargets[i]] = 1; + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave regeneration to \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" gave regeneration to \"%s\".", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" gave regeneration to \"%L\".", client, iTargets[0]); + } + else{ // Remove Regeneration + for(int i = 0; i < iTargetCount; i++) + { + RegenStatus[iTargets[i]] = 0; + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%s\x01's regeneration.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" removed \"%s\"'s regeneration.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" removed \"%L\"'s regeneration.", client, iTargets[0]); + } + return Plugin_Handled; + } + else // args > 2 + { + ReplyToCommand(client, "[SM] Usage: sm_regen [#userid|name] [0/1]"); + return Plugin_Handled; + } +} + +public RegenHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + bl_RegenInit = true; + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + if(RegenStatus[playerId] == 0){ // Player has no regeneration + RegenStatus[playerId] = 1; + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave regeneration to \x04%N\x01.", playerId); + LogAction(client, playerId, "\"%L\" gave regeneration to \"%L\".", client, playerId); + } + else{ // Player has regeneration + RegenStatus[playerId] = 0; + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%N\x01's regeneration.", playerId); + LogAction(client, playerId, "\"%L\" removed \"%L\"'s regeneration.", client, playerId); + } + } + BuildPlayerMenu("regen"); + g_RegenMenu.Display(client, MENU_TIME_FOREVER); + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public Action Timer_Regeneration(Handle timer) +{ + if(bl_RegenInit){ // If the regen command was not used, the timer doesnt iterate + bool bl_RegenUsed = false; + for (int i = 1; i <= GetMaxClients(); i++) + { + if (IsClientInGame(i) && IsPlayerAlive(i)) + { + if(RegenStatus[i] == 1){ + bl_RegenUsed = true; + int clientHP = GetClientHealth(i); + if(clientHP < 100){ + int newHP = clientHP + 10; + if(newHP > 100) + newHP = 100; + SetEntityHealth(i, newHP); + } + } + } + } + if(!bl_RegenUsed){ // If nobody had the regen mode, we stop the timer + bl_RegenInit = false; + } + } +} + + + +/* ----------------------------------- */ + +public Action Command_Cookies(int client, int args) +{ + if(args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_stealcookies [#userid|name]"); + return Plugin_Handled; + } + else if(args == 1) + { + char sArgs[64]; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + ShowActivity2(client, "\x01[SM] \x04", "\x01Stole \x04%s\x01's cookies.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" stole \"%s\"'s cookies.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" stole \"%L\"'s cookies.", client, iTargets[0]); + + for(int i = 0; i < iTargetCount; i++) + { + char sCookieMessage[64]; + getCookiesMessage(sCookieMessage, sizeof(sCookieMessage)); + PrintToChat(iTargets[0], sCookieMessage); + } + return Plugin_Handled; + } + else // args > 1 + { + ReplyToCommand(client, "[SM] Usage: sm_stealcookies [#userid|name]"); + return Plugin_Handled; + } +} + +void getCookiesMessage(char[] getCookiesMessage, int length){ + int randNumber = GetRandomInt(0, 5); + char tempMessage[64] = ""; + switch(randNumber){ + case (0): + { + tempMessage = "\x01[SM]\x04 \x01Oh no! You lost a cookie!"; + } + case (1): + { + tempMessage = "\x01[SM]\x04 \x01Somebody stole your cookie!"; + } + case (2): + { + tempMessage = "\x01[SM]\x04 \x01Somebody stole your whole tin of cookies!"; + } + case (3): + { + tempMessage = "\x01[SM]\x04 \x01Get that cookie thief!"; + } + case (4): + { + tempMessage = "\x01[SM]\x04 \x01Aww, you lost a cookie!"; + } + case (5): + { + tempMessage = "\x01[SM]\x04 \x01Somebody stole all your cookies!"; + } + default: + { + tempMessage = "\x01[SM]\x04 \x01Somebody gave you some cookies!"; + } + } + strcopy(getCookiesMessage, length, tempMessage); +} + +public Action Command_Cookies2(int client, int args) +{ + if(args < 1) + { + ReplyToCommand(client, "[SM] Usage: sm_givecookies [#userid|name]"); + return Plugin_Handled; + } + else if(args == 1) + { + char sArgs[64]; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, 0, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + + char sCookieMessage[64]; + Format(sCookieMessage,sizeof(sCookieMessage),"\x01[SM]\x04 %N\x01 gave you some cookies!",client); + + ShowActivity2(client, "\x01[SM] \x04", "\x01Gave cookies to \x04%s\x01.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" gave \"%s\" cookies.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" gave \"%L\" cookies.", client, iTargets[0]); + + for(int i = 0; i < iTargetCount; i++) + { + PrintToChat(iTargets[i], sCookieMessage); + } + return Plugin_Handled; + } + else // args > 1 + { + ReplyToCommand(client, "[SM] Usage: sm_givecookies [#userid|name]"); + return Plugin_Handled; + } +} + +/* ----------------------------------- */ + +public Action Command_Rocket(int client, int args) +{ + if(args < 2) + { + ReplyToCommand(client, "[SM] Usage: sm_rocket [#userid|name] [0/1]"); + BuildPlayerMenu("rocket"); + g_RocketMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; + } + else if(args == 2) + { + char sArgs[64]; + char sValueRocket[11]; + int iValueRocket; + + char sTargetName[MAX_TARGET_LENGTH]; + int iTargets[MAXPLAYERS]; + int iTargetCount; + bool bIsML; + + GetCmdArg(1, sArgs, sizeof(sArgs)); + GetCmdArg(2, sValueRocket, sizeof(sValueRocket)); + iValueRocket = StringToInt(sValueRocket); + if(iValueRocket != 0){ // If the value is anything but 0, we set 1 + iValueRocket = 1; + } + + if((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_ALIVE, sTargetName, sizeof(sTargetName), bIsML)) <= 0) + { + ReplyToTargetError(client, iTargetCount); + return Plugin_Handled; + } + bl_RocketInit = true; + if(iValueRocket == 1){ // Add Rocket + for(int i = 0; i < iTargetCount; i++) + { + RocketStatus[iTargets[i]] = 1; + createNewRocketPlayer(iTargets[i]); + createNewRocketTrail(iTargets[i]); + EmitSoundToAll("weapons/rpg/rocketfire1.wav", .channel=SNDCHAN_STATIC, .volume=1.0); + CreateTimer(0.25, Timer_StartRocketSound); +// CreateTimer(0.25, Timer_StartRocketSound, INVALID_HANDLE, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Turned \x04%s\x01 into a rocket.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" turned \"%s\" into a rocket.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" turned \"%L\" into a rocket.", client, iTargets[0]); + } + else{ // Remove Rocket + for(int i = 0; i < iTargetCount; i++) + { + RocketStatus[iTargets[i]] = 0; + RocketStatus[iTargets[i]] = 0; + SetEntityGravity(iTargets[i], 1.0); + SetEntityMoveType(iTargets[i], MOVETYPE_WALK); + StopAllRocketSound(); + AcceptEntityInput(rocketSprite[iTargets[i]], "Kill", -1, -1, 0); + } + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%s\x01's rocket transformation.", sTargetName); + if(iTargetCount > 1) + LogAction(client, -1, "\"%L\" removed \"%s\"'s rocket transformation.", client, sTargetName); + else + LogAction(client, iTargets[0], "\"%L\" removed \"%L\"'s rocket transformation.", client, iTargets[0]); + } + return Plugin_Handled; + } + else // args > 2 + { + ReplyToCommand(client, "[SM] Usage: sm_rocket [#userid|name] [0/1]"); + return Plugin_Handled; + } +} + +void createNewRocketPlayer(int playerId){ + if (bl_RocketMode_1) + { + SetEntityGravity(playerId, -0.1); + float originPlayer[3]; + GetClientAbsOrigin(playerId, originPlayer); + originPlayer[2] = originPlayer[2] + 5; + TeleportEntity(playerId, originPlayer, NULL_VECTOR, NULL_VECTOR); + } + else if (bl_RocketMode_2) + { + SetEntityMoveType(playerId, MOVETYPE_NONE); + } +} + +void createNewRocketTrail(int playerId){ + + rocketSprite[playerId] = CreateEntityByName("env_spritetrail"); + char rocketName[32]; + Format(rocketName,sizeof(rocketName),"fsa_rocket_%d",playerId); + + float spriteorigin[3]; + GetClientAbsOrigin(playerId, spriteorigin); + DispatchKeyValue(rocketSprite[playerId], "targetname", rocketName); + DispatchKeyValue(rocketSprite[playerId], "model", "sprites/sprite_fire01.vmt"); + DispatchKeyValue(rocketSprite[playerId], "endwidth", "2.0"); + DispatchKeyValue(rocketSprite[playerId], "lifetime", "2.0"); + DispatchKeyValue(rocketSprite[playerId], "startwidth", "16.0"); + DispatchKeyValue(rocketSprite[playerId], "renderamt", "255"); + DispatchKeyValue(rocketSprite[playerId], "rendercolor", "255 255 255"); + DispatchKeyValue(rocketSprite[playerId], "rendermode", "5"); + DispatchKeyValue(rocketSprite[playerId], "parentname", rocketName); + DispatchSpawn(rocketSprite[playerId]); + TeleportEntity(rocketSprite[playerId], spriteorigin, NULL_VECTOR, NULL_VECTOR); + SetVariantString(rocketName); + AcceptEntityInput(rocketSprite[playerId], "SetParent"); +} + +public RocketHandle(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; // serial id of the player + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(bl_RocketMode_1 || bl_RocketMode_2){ + bl_RocketInit = true; + int serialId = StringToInt(info); + int playerId = GetClientFromSerial(serialId); // 0 if invalid + if ((IsClientInGame(playerId)) && (IsPlayerAlive(playerId)) && playerId != 0){ + + if(RocketStatus[playerId] == 0){ // Player has no rocket + RocketStatus[playerId] = 1; + createNewRocketPlayer(playerId); + createNewRocketTrail(playerId); + EmitSoundToAll("weapons/rpg/rocketfire1.wav", .channel=SNDCHAN_STATIC, .volume=1.0); + CreateTimer(0.25, Timer_StartRocketSound); +// CreateTimer(0.25, Timer_StartRocketSound, INVALID_HANDLE, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); + + ShowActivity2(client, "\x01[SM] \x04", "\x01Turned \x04%N\x01 into a rocket.", playerId); + LogAction(client, playerId, "\"%L\" turned \"%L\" into a rocket.", client, playerId); + } + else{ // Player has rocket + RocketStatus[playerId] = 0; + SetEntityMoveType(playerId, MOVETYPE_WALK); + SetEntityGravity(playerId, 1.0); + StopAllRocketSound(); + CreateTimer(2.0, Timer_StopRocketSound); + AcceptEntityInput(rocketSprite[playerId], "Kill", -1, -1, 0); + ShowActivity2(client, "\x01[SM] \x04", "\x01Removed \x04%N\x01's rocket transformation.", playerId); + LogAction(client, playerId, "\"%L\" removed \"%L\"'s rocket transformation.", client, playerId); + } + } + BuildPlayerMenu("rocket"); + g_RocketMenu.Display(client, MENU_TIME_FOREVER); + } + + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +void StopAllRocketSound(){ + for (int i = 1; i <= (GetMaxClients()); i++) + { + StopSound(i, SNDCHAN_STATIC, "weapons/rpg/rocket1.wav"); + } +} + +public Action Timer_StartRocketSound(Handle timer) +{ + EmitSoundToAll("weapons/rpg/rocket1.wav", .channel=SNDCHAN_STATIC, .volume=1.0); + if(!bl_RocketInit) // If there is no rocket guy + return Plugin_Stop; + return Plugin_Continue; +} + +public Action Timer_StopRocketSound(Handle timer) +{ + StopAllRocketSound(); + if(bl_RocketInit) // If there is a rocket guy + return Plugin_Stop; + return Plugin_Continue; +} + + +public Action Timer_Rocket(Handle timer) +{ + if(bl_RocketMode_1){ // If the cvar mode is on 1 + if(bl_RocketInit){ // If the rocket command was not used, the timer doesnt iterate + bool bl_RocketUsed = false; + for (int i = 1; i <= GetMaxClients(); i++) + { + if (IsClientInGame(i) && IsPlayerAlive(i)) + { + if(RocketStatus[i] == 1){ // If the player is a rocket + bl_RocketUsed = true; + if(g_RocketPosition[i] == 1){ // We save the player origin + GetClientAbsOrigin(i, g_Rocket_Vec1[i]); + g_Rocket_Z1[i] = g_Rocket_Vec1[i][2]; + g_RocketPosition[i] = 0; + } + else{ // with 0.1 sec interval, in 2 different array + GetClientAbsOrigin(i, g_Rocket_Vec2[i]); + g_Rocket_Z2[i] = g_Rocket_Vec2[i][2]; + g_RocketPosition[i] = 1; + } + if (g_Rocket_Z1[i] == g_Rocket_Z2[i]){ // To compare the current origin with the previous + SetEntityGravity(i, 1.0); + if (g_RocketKill.IntValue == 1){ + ForcePlayerSuicide(i); + } + StopAllRocketSound(); + CreateTimer(2.0, Timer_StopRocketSound); + AcceptEntityInput(rocketSprite[i], "Kill", -1, -1, 0); + EmitSoundToAll("weapons/explode3.wav", .channel=SNDCHAN_STATIC, .volume=1.0); + RocketStatus[i] = 0; + } + } + } + } + if(!bl_RocketUsed){ // If nobody had the rocket mode, we stop the timer + bl_RocketInit = false; + } + } + } + else if(bl_RocketMode_2){ // If the cvar mode is on 2 + if(bl_RocketInit){ // If the rocket command was not used, the timer doesnt iterate + bool bl_RocketUsed = false; + for (int i = 1; i <= GetMaxClients(); i++) + { + if (IsClientInGame(i) && IsPlayerAlive(i)) + { + if(RocketStatus[i] == 1){ + bl_RocketUsed = true; + float RocketAbsOrigin[3]; + float RocketEndOrigin[3]; + GetClientEyePosition(i, RocketAbsOrigin); + float AbsAngle[3]; + AbsAngle[0] = -90.0; AbsAngle[1] = 0.0; AbsAngle[2] = 0.0; + TR_TraceRayFilter(RocketAbsOrigin, AbsAngle, MASK_SOLID, RayType_Infinite, TraceEntityFilter_FilterCaller); + TR_GetEndPosition(RocketEndOrigin); + float DistanceBetween = RocketEndOrigin[2] - RocketAbsOrigin[2]; + if (DistanceBetween <= (g_RocketSpeed.FloatValue + 0.1)) + { + if (g_RocketKill.IntValue == 1) + { + ForcePlayerSuicide(i); + } + StopAllRocketSound(); + CreateTimer(2.0, Timer_StopRocketSound); + AcceptEntityInput(rocketSprite[i], "Kill", -1, -1, 0); + EmitSoundToAll("weapons/explode3.wav", .channel=SNDCHAN_STATIC, .volume=1.0); + if (IsPlayerAlive(i)) + { + RocketStatus[i] = 0; + SetEntityMoveType(i, MOVETYPE_WALK); + float ClientOrigin[3]; + GetClientAbsOrigin(i, ClientOrigin); + ClientOrigin[2] = ClientOrigin[2] - (g_RocketSpeed.FloatValue + 0.1); + TeleportEntity(i, ClientOrigin, NULL_VECTOR, NULL_VECTOR); + } + } + else if (DistanceBetween >= (g_RocketSpeed.FloatValue + 0.1)) + { + float ClientOrigin[3]; + GetClientAbsOrigin(i, ClientOrigin); + ClientOrigin[2] = ClientOrigin[2] + g_RocketSpeed.FloatValue; + TeleportEntity(i, ClientOrigin, NULL_VECTOR, NULL_VECTOR); + } + } + } + } + if(!bl_RocketUsed){ // If nobody had the rocket mode, we stop the timer + bl_RocketInit = false; + } + } + } +} + +bool TraceEntityFilter_FilterCaller(int entity, int contentsMask, int client) +{ + return entity != client; +} diff --git a/PropSpawner/configs/PropSpawner.cfg b/PropSpawner/configs/PropSpawner.cfg new file mode 100644 index 00000000..b468e101 --- /dev/null +++ b/PropSpawner/configs/PropSpawner.cfg @@ -0,0 +1,307 @@ +"models" +{ + "physic" + { + "0" + { + "name" "Barrel" + "model" "models/props_c17/oildrum001.mdl" + "z_offset" "15" + } + "1" + { + "name" "Explosive Barrel" + "model" "models/props_c17/oildrum001_explosive.mdl" + "z_offset" "15" + "precache" + { + "0" "models/props_c17/oildrum001_explosive.mdl" + "1" "models/props_c17/oildrumchunk01a.mdl" + "2" "models/props_c17/oildrumchunk01b.mdl" + "3" "models/props_c17/oildrumchunk01c.mdl" + "4" "models/props_c17/oildrumchunk01d.mdl" + "5" "models/props_c17/oildrumchunk01e.mdl" + } + "health" "1" + "explode" "1" + "explodedamage" "50" + "exploderadius" "1000" + } + "2" + { + "name" "Vending Machine" + "model" "models/props/cs_office/vending_machine.mdl" + "z_offset" "5" + } + "3" + { + "name" "Heavy Vending Machine" + "model" "models/props_interiors/vendingmachinesoda01a.mdl" + "z_offset" "60" + } + "4" + { + "name" "Bananas" + "model" "models/props/cs_italy/bananna_bunch.mdl" + "z_offset" "15" + "precache" + { + "0" "models/props/cs_italy/bananna_bunch.mdl" + "1" "models/props/cs_italy/bananna.mdl" + "2" "models/props/cs_italy/banannagib1.mdl" + "3" "models/props/cs_italy/banannagib2.mdl" + } + "health" "1" + } + "5" + { + "name" "Orange" + "model" "models/props/cs_italy/orange.mdl" + "z_offset" "15" + "precache" + { + "0" "models/props/cs_italy/orange.mdl" + "1" "models/props/cs_italy/orangegib1.mdl" + "2" "models/props/cs_italy/orangegib2.mdl" + "3" "models/props/cs_italy/orangegib3.mdl" + } + "health" "1" + } + "6" + { + "name" "Watermelon" + "model" "models/props_junk/watermelon01.mdl" + "z_offset" "15" + "precache" + { + "0" "models/props_junk/watermelon01.mdl" + "1" "models/props_junk/watermelon01_chunk01a.mdl" + "2" "models/props_junk/watermelon01_chunk01b.mdl" + "3" "models/props_junk/watermelon01_chunk01c.mdl" + "4" "models/props_junk/watermelon01_chunk02a.mdl" + "5" "models/props_junk/watermelon01_chunk02b.mdl" + "6" "models/props_junk/watermelon01_chunk02c.mdl" + } + "health" "1" + } + "7" + { + "name" "Wine Barrel" + "model" "models/props/de_inferno/wine_barrel.mdl" + "z_offset" "15" + "precache" + { + "0" "models/props/de_inferno/wine_barrel.mdl" + "1" "models/props/de_inferno/wine_barrel_p1.mdl" + "2" "models/props/de_inferno/wine_barrel_p2.mdl" + "3" "models/props/de_inferno/wine_barrel_p3.mdl" + "4" "models/props/de_inferno/wine_barrel_p4.mdl" + "5" "models/props/de_inferno/wine_barrel_p5.mdl" + "6" "models/props/de_inferno/wine_barrel_p6.mdl" + "7" "models/props/de_inferno/wine_barrel_p7.mdl" + "8" "models/props/de_inferno/wine_barrel_p8.mdl" + "9" "models/props/de_inferno/wine_barrel_p9.mdl" + "10" "models/props/de_inferno/wine_barrel_p10.mdl" + "11" "models/props/de_inferno/wine_barrel_p11.mdl" + } + } + "8" + { + "name" "Swampy Turtle" + "model" "models/props/de_tides/vending_turtle.mdl" + "z_offset" "15" + } + "9" + { + "name" "File Cabinet" + "model" "models/props/cs_office/file_cabinet3.mdl" + "z_offset" "15" + } + "10" + { + "name" "Bookcase" + "model" "models/props/cs_havana/bookcase_large.mdl" + "z_offset" "15" + } + "11" + { + "name" "Dryer" + "model" "models/props/cs_militia/dryer.mdl" + "z_offset" "35" + } + "12" + { + "name" "Leather Sofa" + "model" "models/props/cs_office/sofa.mdl" + "z_offset" "10" + } + + } + "dynamic" + { + "0" + { + "name" "Blastdoor" + "model" "models/props_lab/blastdoor001c.mdl" + } + "1" + { + "name" "Fountain" + "model" "models/props/de_inferno/fountain.mdl" + } + "2" + { + "name" "Lamppost" + "model" "models/props_c17/lamppost03a_off.mdl" + } + "3" + { + "name" "Pipe" + "model" "models/props_pipes/pipecluster32d_001a.mdl" + } + "4" + { + "name" "Propane Machine" + "model" "models/props/de_train/processor_nobase.mdl" + } + "5" + { + "name" "Rock" + "model" "models/props/de_inferno/de_inferno_boulder_01.mdl" + } + "6" + { + "name" "Fabric Sofa" + "model" "models/props/cs_militia/couch.mdl" + } + "7" + { + "name" "Table" + "model" "models/props/cs_militia/table_kitchen.mdl" + } + "8" + { + "name" "Tank" + "model" "models/props_vehicles/apc001.mdl" + } + "9" + { + "name" "Toilet" + "model" "models/props/cs_militia/toilet.mdl" + } + "10" + { + "name" "Wooden Box" + "model" "models/props/cs_militia/crate_extralargemill.mdl" + } + "11" + { + "name" "Jeep" + "model" "models/buggy.mdl" + } + "12" + { + "name" "Airboat" + "model" "models/airboat.mdl" + } + + } + "npc" + { + "0" + { + "name" "Alyx" + "model" "models/alyx.mdl" + } + "1" + { + "name" "Antlion" + "model" "models/antlion.mdl" + } + "2" + { + "name" "Antlion Guard" + "model" "models/antlion_guard.mdl" + } + "3" + { + "name" "Barney" + "model" "models/barney.mdl" + } + "4" + { + "name" "Breen" + "model" "models/breen.mdl" + } + "5" + { + "name" "Counter-Terrorist" + "model" "models/player/ct_gign.mdl" + } + "6" + { + "name" "Crow" + "model" "models/crow.mdl" + } + "7" + { + "name" "Dog" + "model" "models/dog.mdl" + } + "8" + { + "name" "Eli" + "model" "models/eli.mdl" + } + "9" + { + "name" "Fast Headcrab" + "model" "models/headcrab.mdl" + } + "10" + { + "name" "Fast Zombie" + "model" "models/zombie/fast.mdl" + } + "11" + { + "name" "Headcrab" + "model" "models/headcrabclassic.mdl" + } + "12" + { + "name" "Hostage" + "model" "models/characters/hostage_02.mdl" + } + "13" + { + "name" "Kleiner" + "model" "models/kleiner.mdl" + } + "14" + { + "name" "Poison Headcrab" + "model" "models/headcrabblack.mdl" + } + "15" + { + "name" "Poison Zombie" + "model" "models/zombie/poison.mdl" + } + "16" + { + "name" "Terrorist" + "model" "models/player/t_guerilla.mdl" + } + "17" + { + "name" "Vortigaunt" + "model" "models/vortigaunt.mdl" + } + "18" + { + "name" "Zombie" + "model" "models/zombie/classic.mdl" + } + } +} \ No newline at end of file diff --git a/PropSpawner/scripting/PropSpawner.sp b/PropSpawner/scripting/PropSpawner.sp new file mode 100644 index 00000000..582191dd --- /dev/null +++ b/PropSpawner/scripting/PropSpawner.sp @@ -0,0 +1,490 @@ +#pragma semicolon 1 +#include +#include + +public Plugin myinfo = +{ + name = "Prop Spawner", + author = "Moltard / LightningZLaser", + description = "A plugin to spawn props", + version = "0.1", + url = "https://steamcommunity.com/id/0123456789ABC/" +}; + +Menu g_MainMenu = null; +Menu g_RotationMenu = null; +Menu g_PhysicMenu = null; +Menu g_DynamicMenu = null; +Menu g_NpcMenu = null; + +KeyValues g_Models; + + +public void OnPluginStart() +{ + LoadTranslations("common.phrases"); + char sModelsFile[PLATFORM_MAX_PATH]; + BuildPath(Path_SM, sModelsFile, sizeof(sModelsFile), "configs/PropSpawner.cfg"); + + if(!FileExists(sModelsFile)) + { + SetFailState("Could not find config: \"%s\"", sModelsFile); + return; + } + + g_Models = new KeyValues("models"); + if(!g_Models.ImportFromFile(sModelsFile)) + { + delete g_Models; + SetFailState("ImportFromFile() failed!"); + return; + } + g_Models.Rewind(); // Go back to the root node + + RegAdminCmd("sm_propspawner", Command_MainMenu, ADMFLAG_CHANGEMAP); //g +} + +public void OnMapStart() +{ + g_Models.Rewind(); + + g_MainMenu = BuildMainMenu(); + g_RotationMenu = BuildRotationMenu(); + g_PhysicMenu = BuildModelsMenu("physic"); + g_DynamicMenu = BuildModelsMenu("dynamic"); + g_NpcMenu = BuildModelsMenu("npc"); +} + +public void OnMapEnd() +{ + if (g_MainMenu != null) + { + delete(g_MainMenu); + g_MainMenu = null; + } + if (g_RotationMenu != null) + { + delete(g_RotationMenu); + g_RotationMenu = null; + } + if (g_PhysicMenu != null) + { + delete(g_PhysicMenu); + g_PhysicMenu = null; + } + if (g_DynamicMenu != null) + { + delete(g_DynamicMenu); + g_DynamicMenu = null; + } + if (g_NpcMenu != null) + { + delete(g_NpcMenu); + g_NpcMenu = null; + } +} + +/* ----------------------------------- */ + +Menu BuildMainMenu(){ + Menu menu = new Menu(MainMenuHandler); + menu.SetTitle("Prop Spawner"); + menu.AddItem("menu_prop_delete", "Delete Prop"); + menu.AddItem("menu_prop_rotate", "Rotate Prop"); + menu.AddItem("menu_prop_dynamic", "Dynamic/Static Props"); + menu.AddItem("menu_prop_physic", "Physic Props"); + menu.AddItem("menu_prop_npc", "NPCs"); + menu.ExitButton = true; + return menu; +} + +Menu BuildRotationMenu(){ + Menu menu = new Menu(RotationHandler); + SetMenuTitle(menu, "Rotate Menu"); + menu.AddItem( "X_+45", "Rotate X +45 Degrees"); + menu.AddItem( "X_-45", "Rotate X -45 Degrees"); + menu.AddItem( "Y_+45", "Rotate Y +45 Degrees"); + menu.AddItem( "Y_-45", "Rotate Y -45 Degrees"); + menu.AddItem( "Z_+45", "Rotate Z +45 Degrees"); + menu.AddItem( "Z_-45", "Rotate Z -45 Degrees"); + menu.ExitBackButton = true; + menu.ExitButton = true; + return menu; +} + +Menu BuildModelsMenu(char[] modelType){ + Menu menu; + if(StrEqual(modelType, "physic")){ + menu = new Menu(PhysicHandler); + SetMenuTitle(menu, "Physic Props"); + } + else if(StrEqual(modelType, "dynamic")){ + menu = new Menu(DynamicHandler); + SetMenuTitle(menu, "Dynamic Props"); + } + else if(StrEqual(modelType, "npc")){ + menu = new Menu(NpcHandler); + SetMenuTitle(menu, "NPCs"); + } + menu.AddItem("deleteProp", "Delete Prop"); + if(g_Models.JumpToKey(modelType, false)){ + for(int i = 0; i < 100000; i++){ + char sName[32]; char sIndex[11]; + IntToString(i,sIndex, sizeof(sIndex)); // Index i of the model + if (!(g_Models.JumpToKey(sIndex, false))) // if the key doesnt exist + break; // we stop the loop + g_Models.GetString("name", sName, sizeof(sName)); // Name of the model + menu.AddItem(sIndex,sName); + g_Models.GoBack(); // First sub key of the prop category + } + } + g_Models.Rewind(); // Go back to the root node + menu.ExitBackButton = true; + menu.ExitButton = true; + return menu; +} + +/* ----------------------------------- */ + +public Action Command_MainMenu(int client, int args) +{ + g_MainMenu.Display(client, MENU_TIME_FOREVER); + return Plugin_Handled; +} + +public int MainMenuHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "menu_prop_delete")){ + DeleteProp(client); + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_prop_rotate")){ + g_RotationMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_prop_dynamic")){ + g_DynamicMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_prop_physic")){ + g_PhysicMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(info, "menu_prop_npc")){ + g_NpcMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + +public RotationHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "X_+45")) + { + RotateProp(45.0,0,client); + } + else if(StrEqual(info, "Y_+45")) + { + RotateProp(45.0,1,client); + } + else if(StrEqual(info, "Z_+45")) + { + RotateProp(45.0,2,client); + } + else if(StrEqual(info, "X_-45")) + { + RotateProp(-45.0,0,client); + } + else if(StrEqual(info, "Y_-45")) + { + RotateProp(-45.0,1,client); + } + else if(StrEqual(info, "Z_-45")) + { + RotateProp(-45.0,2,client); + } + g_RotationMenu.Display(client, MENU_TIME_FOREVER); + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +public PhysicHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "deleteProp")) + { + DeleteProp(client); + g_PhysicMenu.Display(client, MENU_TIME_FOREVER); + } + else{ + // Info has the index of the model + SpawnProp("physic",info,client); + } + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +public DynamicHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "deleteProp")) + { + DeleteProp(client); + g_DynamicMenu.Display(client, MENU_TIME_FOREVER); // We display again the menu + } + else{ + // Info has the index of the model in the array + SpawnProp("dynamic",info,client); + } + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +public NpcHandler(Menu menu, MenuAction action, int client, int param2) +{ + char info[32]; + menu.GetItem(param2, info, sizeof(info)); // Get the string of the picked option + switch(action) { + case(MenuAction_Select): + { + if(StrEqual(info, "deleteProp")) + { + DeleteProp(client); + g_NpcMenu.Display(client, MENU_TIME_FOREVER); // We display again the menu + } + else{ + // Info has the index of the model in the array + SpawnProp("npc",info,client); + } + } + case(MenuAction_Cancel): + { + if(param2 == MenuCancel_ExitBack) { + g_MainMenu.Display(client, MENU_TIME_FOREVER); + } + } + } +} + + +bool isAProp(char[] classname){ + if(StrEqual(classname, "prop_physics") || StrEqual(classname, "prop_physics_override") || StrEqual(classname, "prop_dynamic") || StrEqual(classname, "prop_dynamic_override") || StrEqual(classname, "prop_physics_multiplayer") || StrEqual(classname, "prop_dynamic_ornament") || StrEqual(classname, "prop_static")){ + return true; + } + return false; +} + + +void DeleteProp(int client){ + + char classname[64]; + new DeleteIndex = GetClientAimTarget(client, false); + if (DeleteIndex != -1) + { + GetEdictClassname(DeleteIndex, classname, sizeof(classname)); + if(isAProp(classname)) + { + AcceptEntityInput(DeleteIndex, "Kill", -1, -1, 0); + ShowActivity2(client, "\x01[SM] \x04", "deleted a prop."); + LogAction(client, -1, "\"%L\" deleted a prop.", client); + } + } + if ((DeleteIndex == -1) || !isAProp(classname)) + { + ReplyToCommand(client, "[SM] No entity found or invalid entity."); + } +} + +void RotateProp(float RotateValue, int RotateAxis, int client){ + char classname[64]; + float RotateVec[3]; + int RotateIndex = GetClientAimTarget(client, false); + if (RotateIndex != -1) + { + GetEdictClassname(RotateIndex, classname, sizeof(classname)); + if(isAProp(classname)) + { + GetEntPropVector(RotateIndex, Prop_Send, "m_angRotation", RotateVec); + RotateVec[RotateAxis] = RotateVec[RotateAxis] + RotateValue; + TeleportEntity(RotateIndex, NULL_VECTOR, RotateVec, NULL_VECTOR); + AcceptEntityInput(RotateIndex, "EnableCollision"); + AcceptEntityInput(RotateIndex, "TurnOn", RotateIndex, RotateIndex, 0); + + ShowActivity2(client, "\x01[SM] \x04", "rotated a prop."); + LogAction(client, -1, "\"%L\" rotated a prop.", client); + } + } + if ((RotateIndex == -1) || !isAProp(classname)) + { + ReplyToCommand(client, "[SM] No entity found or invalid entity."); + } +} + + +void SpawnProp(char[] TypeProp, char[] PropId, int client){ + + if(StrEqual(TypeProp, "physic") || StrEqual(TypeProp, "dynamic") || StrEqual(TypeProp, "npc")){ + + if(g_Models.JumpToKey(TypeProp, false)){ + if (g_Models.JumpToKey(PropId, false)){ + prop_any_create(client); + } + } + if(StrEqual(TypeProp, "physic")){ + g_PhysicMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(TypeProp, "dynamic")){ + g_DynamicMenu.Display(client, MENU_TIME_FOREVER); + } + else if(StrEqual(TypeProp, "npc")){ + g_NpcMenu.Display(client, MENU_TIME_FOREVER); + } + int i_PropId = StringToInt(PropId)+1; // +1 cause of 'Delete Prop' in the menu + int pageMenu = RoundToFloor(float(i_PropId)/7); // We get the quotient of the division + for(int i = 1; i <= pageMenu; i++){ // We change the menu page until we are back where we were + FakeClientCommandEx(client, "menuselect 9"); + } + } +} + + + +bool TraceEntityFilter_FilterCaller(int entity, int contentsMask, int client) +{ + return entity != client; +} + +void prop_any_create(int client) +{ + char sModelName[64]; + g_Models.GetString("name", sModelName, sizeof(sModelName)); // Name of the model + + char sModelPath[128]; + g_Models.GetString("model", sModelPath, sizeof(sModelPath)); // Path of the model + + int z_Offset = g_Models.GetNum("z_offset",0); // if "z_offset" is not set, then it's 0 + + char sModelHealth[11]; + char sModelExplodeDamage[11]; + char sModelExplodeRadius[11]; + int iModelExplode = g_Models.GetNum("explode",0); // if "explode" is not set, then it's 0 + + g_Models.GetString("health", sModelHealth, sizeof(sModelHealth),"0"); // if "health" is not set, then it's 0 + g_Models.GetString("explodedamage", sModelExplodeDamage, sizeof(sModelExplodeDamage),"1"); + g_Models.GetString("exploderadius", sModelExplodeRadius, sizeof(sModelExplodeRadius),"1"); + + if(g_Models.JumpToKey("precache", false)){ // Precache each model used by the prop + + for(int i = 0; i < 100000; i++){ + char sIndex[11]; + IntToString(i,sIndex, sizeof(sIndex)); // Index i of the model + if (!(g_Models.JumpToKey(sIndex, false))) // if the key doesnt exist + break; // we stop the loop + char sModelPrecache[128]; + g_Models.GetString(NULL_STRING, sModelPrecache, sizeof(sModelPrecache)); + PrecacheModel(sModelPrecache,true); + g_Models.GoBack(); + } + g_Models.GoBack(); // Back to the index of the prop + } + else{ // If "precache" doesnt exist, we precache only the model we spawn + PrecacheModel(sModelPath,true); + } + g_Models.GoBack(); // Back to the type of prop (physic, dynamic, npc) + + char sPropType[32]; + g_Models.GetSectionName(sPropType, sizeof(sPropType)); // physic, dynamic, npc + + int prop; + if(StrEqual(sPropType,"physic")){ + prop = CreateEntityByName("prop_physics_override"); + } + else if(StrEqual(sPropType,"dynamic") || StrEqual(sPropType,"npc")){ + prop = CreateEntityByName("prop_dynamic_override"); + } + g_Models.Rewind(); // Back to root node + + DispatchKeyValue(prop, "model", sModelPath); + + if (!StrEqual(sModelHealth,"0")) + { + DispatchKeyValue(prop, "health", sModelHealth); + } + if (iModelExplode != 0) + { + DispatchKeyValue(prop, "explodedamage", sModelExplodeDamage); + DispatchKeyValue(prop, "exploderadius", sModelExplodeRadius); + } + + float VecOrigin[3]; + float VecAngles[3]; + float normal[3]; + + GetClientEyePosition(client, VecOrigin); + GetClientEyeAngles(client, VecAngles); + TR_TraceRayFilter(VecOrigin, VecAngles, MASK_SOLID, RayType_Infinite, TraceEntityFilter_FilterCaller, client); + TR_GetEndPosition(VecOrigin); + + DispatchKeyValue(prop, "StartDisabled", "false"); + DispatchKeyValue(prop, "Solid", "6"); + SetEntProp(prop, Prop_Data, "m_CollisionGroup", 5); + + + if(StrEqual(sPropType,"physic")){ + VecAngles[0] = 0.0; + VecAngles[2] = 0.0; + VecOrigin[2] = VecOrigin[2] + z_Offset; + SetEntityMoveType(prop, MOVETYPE_VPHYSICS); + TeleportEntity(prop, VecOrigin, VecAngles, NULL_VECTOR); + } + else if(StrEqual(sPropType,"dynamic") || StrEqual(sPropType,"npc")){ + TR_GetPlaneNormal(INVALID_HANDLE, normal); + GetVectorAngles(normal, normal); + normal[0] += 90.0; + TeleportEntity(prop, VecOrigin, normal, NULL_VECTOR); + AcceptEntityInput(prop, "TurnOn", prop, prop, 0); + } + + DispatchSpawn(prop); + AcceptEntityInput(prop, "TurnOn", prop, prop, 0); + AcceptEntityInput(prop, "EnableCollision"); + + ShowActivity2(client, "\x01[SM] \x04", "\x01Spawned \x04%s\x01.", sModelName); + LogAction(client, -1, "\"%L\" Spawned \"%s\".", client, sModelName); +} \ No newline at end of file