Added DisguisePlugin, FunSuperAdmin and PropSpawner. Changed the flag used in them to g

This commit is contained in:
Moltard 2021-12-25 18:52:48 +01:00
parent 77e0ba70de
commit 72bea7dffc
5 changed files with 2725 additions and 0 deletions

View File

@ -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"
}
}

View File

@ -0,0 +1,322 @@
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
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);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}
}

View File

@ -0,0 +1,490 @@
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
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);
}