viewing paste Unknown #51533 | SourcePawn

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
#include <sourcemod>
#include <levelsranks>
#include <multi1v1>
#include <gloves/menus>
#include <weapons/menus>
 
#pragma semicolon 1
#pragma newdecls required
 
#define PLUGIN_AUTHOR "Lissner"
#define PLUGIN_VERSION "0.01"
 
public Plugin myinfo = 
{
    name = "JML Home menu",
    author = PLUGIN_AUTHOR,
    description = "One main menu, home for every single plugin on the server.",
    version = PLUGIN_VERSION,
    url = "https://jml.lissner.me/"
};
 
public void OnPluginStart()
{
    // players can use the following 2 commands to open the menu: !home or !jml
    RegConsoleCmd("sm_home", HomeMenu, "Displays the home menu");
    RegConsoleCmd("sm_jml", HomeMenu, "Displays the home menu");
}
 
// Listens for HomeMenu to get called
public Action HomeMenu(int client, int args){
    
    //Creates a new menu first
    Menu menu = new Menu(HomeMenu_Callback)
    
    // Sets the main menu title
    menu.SetTitle("JML ✰ Home Menu");
    
    // Adding 4 options to the menu, 1 arg = handle and the 2nd arg = the item label
    menu.AddItem("option1", "Rank Menu");
    menu.AddItem("option2", "1v1 Settings");
    menu.AddItem("option3", "Shop", ITEMDRAW_DISABLED);                 // Disabled - shop option
    menu.AddItem("option4", "Server Hop", ITEMDRAW_DISABLED);           // Disabled - server hop option
    menu.AddItem("option5", "Sound Settings");
    
    // When everything is set, menu gets called for the client to see (for 30 seconds)
    menu.Display(client, MENU_TIME_FOREVER);
    
    // The Action for HomeMenu is over, and we return plugin handled, to let the handle know that the script went like it was supposed to.
    return Plugin_Handled;
}
 
/*
        RANKMENU     +   1V1 SETTINGS    +   SHOP    +   SERVER HOP     +    SOUNDSETTINGS          Menu
*/
 
// HomeMenu awaiting selection, sets the param1 and param2
public int HomeMenu_Callback(Menu menu, MenuAction action, int param1, int param2)
{
    switch (action) {
        case MenuAction_Select:
        {
            char item[32];
            menu.GetItem(param2, item, sizeof(item));
            
            if(StrEqual(item, "option1")){
                // Rank menu chosen, creating new menu with choices
                Menu menu = new Menu(MenuRank_Callback)
                
                // Sets the main menu title
                menu.SetTitle("JML ✰ Rank\nCommands");
                
                menu.AddItem("option1", "!menu");
                menu.AddItem("option2", "!rank");
                menu.AddItem("option3", "!top"); 
                menu.AddItem("option4", "!toptime");    
                menu.AddItem("option5", "!session");    
                menu.AddItem("option6", "!lvl_reset");
                
                // When everything is set, menu gets called for the client to see (for 30 seconds)
                menu.Display(client, 30);
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option2")){
                // 1v1 menu chosen, creating new menu with choices
                Menu menu = new Menu(Menu1v1_Callback)
                
                menu.SetTitle("JML ✰ 1v1\nSettings");
                
                menu.AddItem("option1", "!guns");
                menu.AddItem("option2", "!challenge");
                menu.AddItem("option3", "!knifes"); 
                menu.AddItem("option4", "!gloves"); 
                menu.AddItem("option5", "!ws"); 
                
                // When everything is set, menu gets called for the client to see (for 30 seconds)
                menu.Display(client, 30);
                return Plugin_Handled;
            }
            else if (StrEqual(item, "option3")){
                // Shop menu chosen - invalid choice
                return Plugin_Handled;
            }
            else if (StrEqual(item, "option4")){
                // Server menu chosen - invalid choice
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option5")){
                // Sound settings chosen
                Menu menu = new Menu(MenuSound_Callback)
                
                menu.SetTitle("JML ✰ Sound\nSettings");
                
                menu.AddItem("option1", "!mes");    
                
                // When everything is set, menu gets called for the client to see (for 30 seconds)
                menu.Display(client, 30);
                return Plugin_Handled;
            }
        }
        case MenuAction_End:
        {
            // deleting menu when we're done to free up memory and prevent memory leaks
            delete menu;
        }
    }   
}
 
 
 
 
// LEVELRANKS SETTINGS MENU ACTIONS
public int MenuRank_Callback(Menu menu, MenuAction action, int param1, int param2)
{
    switch (action) {
        case MenuAction_Select:
        {
            char item[32];
            menu.GetItem(param2, item, sizeof(item));
            
            if(StrEqual(item, "option1")){
                // !lvl chosen - call levelsranks main menu?
                MainMenu(iClient);
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option2")){
                // !rank chosen - call levelsranks rank function?
                MyStats(iClient);
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option3")){
                // !top chosen - call levelsranks top function?
                OverAllRanks(iClient);
                
                return Plugin_Handled;
            }
            else if (StrEqual(item, "option4")){
                // !toptime chosen - call levelsranks toptime function?
                MenuTop(iClient);
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option5")){
                // !session chosen - call levelranks session function?
                MyStatsSession(iClient);
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option6")){
                // !lvl_reset chosen - call levelranks reset function?
                MyStatsReset(iClient);
                
                return Plugin_Handled;
                
            }
        }
        case MenuAction_End:
        {
            // deleting menu when we're done to free up memory and prevent memory leaks
            delete menu;
        }
    }
}
 
 
 
// 1V1 SETTINGS MENU ACTIONS
public int Menu1v1_Callback(Menu menu, MenuAction action, int param1, int param2)
{
    switch (action) {
        case MenuAction_Select:
        {
            char item[32];
            menu.GetItem(param2, item, sizeof(item));
            
            if(StrEqual(item, "option1")){
                // !guns chosen - call 1v1's gun menu?
                GiveWeaponsMenu(client);
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option2")){
                // !challenge chosen - call 1v1's challenge function?
                // ...
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option3")){
                // !knifes - call knifes function?
                // ...
                
                return Plugin_Handled;
            }
            else if (StrEqual(item, "option4")){
                // !gloves chosen - call gloves function?
                // ...
                
                return Plugin_Handled;
                
            }
            else if (StrEqual(item, "option5")){
                // !ws chosen - call ws function?
                // ...
                
                return Plugin_Handled;
                
            }
        }
        case MenuAction_End:
        {
            // deleting menu when we're done to free up memory and prevent memory leaks
            delete menu;
        }
    }
}
Viewed 575 times, submitted by Guest.