From c89e6f82351f3fdce147dd3a79674e7006fabf0e Mon Sep 17 00:00:00 2001 From: neon <> Date: Tue, 15 Jan 2019 22:22:14 +0100 Subject: [PATCH] adding VIP_Menu --- VIP_Menu/configs/vip_menu.cfg | 23 ++++++ VIP_Menu/scripting/VIP_Menu.sp | 141 +++++++++++++++++++++++++++++++++ VIP_Test/scripting/VIP_Test.sp | 2 +- 3 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 VIP_Menu/configs/vip_menu.cfg create mode 100644 VIP_Menu/scripting/VIP_Menu.sp diff --git a/VIP_Menu/configs/vip_menu.cfg b/VIP_Menu/configs/vip_menu.cfg new file mode 100644 index 0000000..6ba387f --- /dev/null +++ b/VIP_Menu/configs/vip_menu.cfg @@ -0,0 +1,23 @@ +"vip_menu" +{ + "-1" + { + "command" "zclass" + "description" "Player Skins (!zclass)" + } + "0" + { + "command" "sm_tag" + "description" "Chat Options (!tag)" + } + "1" + { + "command" "sm_glow" + "description" "Glowcolors (!glow)" + } + "2" + { + "command" "sm_rainbow" + "description" "Toggle Rainbow" + } +} diff --git a/VIP_Menu/scripting/VIP_Menu.sp b/VIP_Menu/scripting/VIP_Menu.sp new file mode 100644 index 0000000..2fb63e2 --- /dev/null +++ b/VIP_Menu/scripting/VIP_Menu.sp @@ -0,0 +1,141 @@ +#pragma semicolon 1 +#pragma newdecls required + +#include + +#define MAXCOMMANDS 20 + +/* STRINGS */ +char g_sDataFile[128]; +char g_sVIPCommands[MAXCOMMANDS][2][128]; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "UNLOZE_VIP_Menu", + author = "Neon", + description = "", + version = "1.0", + url = "https://steamcommunity.com/id/n3ontm" +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + BuildPath(Path_SM, g_sDataFile, sizeof(g_sDataFile), "configs/vip_menu.cfg"); + RegAdminCmd("sm_vip", Command_VIP, ADMFLAG_CUSTOM1, "Open VIP Menu."); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnMapStart() +{ + for (int i = 0; i < MAXCOMMANDS; i++) + { + for (int j = 0; j < 2; j++) + g_sVIPCommands[i][j] = ""; + } + + int k = 0; + + if(!FileExists(g_sDataFile)) + { + SetFailState("Config file missing!"); + return; + } + + KeyValues hKvConfig = new KeyValues("vip_menu"); + + if (!(hKvConfig.ImportFromFile(g_sDataFile))) + { + SetFailState("ImportFromFile() failed!"); + return; + } + + hKvConfig.Rewind(); + + if(!hKvConfig.GotoFirstSubKey()) + { + SetFailState("GotoFirstSubKey() failed!"); + return; + } + + do + { + char sSection[64]; + hKvConfig.GetSectionName(sSection, sizeof(sSection)); + + char sCommand[64]; + hKvConfig.GetString("command", sCommand, sizeof(sCommand)); + + if(!sCommand[0]) + { + SetFailState("Could not find \"command\" in \"%s\"", sSection); + return; + } + + char sDescription[64]; + hKvConfig.GetString("description", sDescription, sizeof(sDescription)); + + if(!sDescription[0]) + { + SetFailState("Could not find \"description\" in \"%s\"", sSection); + return; + } + + g_sVIPCommands[k][0] = sCommand; + g_sVIPCommands[k][1] = sDescription; + k++; + + } while(hKvConfig.GotoNextKey(false)); + + delete hKvConfig; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action Command_VIP(int client, int iArgs) +{ + Menu menu = new Menu(MenuHandler_VIPMenu); + menu.SetTitle("VIP Menu"); + + for (int i = 0; i < MAXCOMMANDS; i++) + { + if(!g_sVIPCommands[i][0][0]) + break; + + menu.AddItem(g_sVIPCommands[i][0], g_sVIPCommands[i][1]); + } + + menu.Display(client, MENU_TIME_FOREVER); + + return Plugin_Handled; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int MenuHandler_VIPMenu(Menu menu, MenuAction action, int param1, int param2) +{ + switch(action) + { + case MenuAction_Select: + { + char sInfo[128]; + menu.GetItem(param2, sInfo, sizeof(sInfo)); + FakeClientCommandEx(param1, sInfo); + } + + case MenuAction_End: + { + delete menu; + } + } + return 0; +} \ No newline at end of file diff --git a/VIP_Test/scripting/VIP_Test.sp b/VIP_Test/scripting/VIP_Test.sp index 6788886..0fb48ce 100644 --- a/VIP_Test/scripting/VIP_Test.sp +++ b/VIP_Test/scripting/VIP_Test.sp @@ -40,7 +40,6 @@ public void OnPluginStart() RegConsoleCmd("sm_viptest", Command_VIP, "Activate free VIP period"); RegConsoleCmd("sm_testvip", Command_VIP, "Activate free VIP period"); - RegConsoleCmd("sm_vip", Command_VIP, "Activate free VIP period"); AutoExecConfig(); @@ -228,6 +227,7 @@ public void TQueryCBCommand(Handle owner, Handle rs, const char[] error, any dat ApplyGroupFlags(client); PrintToChat(client, "[UNLOZE] You have now access to !zclass, !tag and !glow and other VIP-Perks."); PrintToChat(client, "[UNLOZE] Your TEST VIP will expire in %d minutes!", g_cvFreeVIPDuration.IntValue); + FakeClientCommandEx(client, "sm_vip"); } }