AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Admin Menu (https://forums.alliedmods.net/showthread.php?t=253426)

suundz 12-21-2014 23:59

Admin Menu
 
So I'm trying to make an admin menu and I want to start of with the once I think is hard, slay/slap and mute/gag, when they are done I can do the switching on transfer and such myself :)

Mute = Voice_chat
Gag = Text_Chat

If you dont understand tell me to explain better and I'll do my very best, thanks in advance! :fox:

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "AdminMenu"
#define VERSION "1.0"
#define AUTHOR "CAKE"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("/ftam""ShowMenu"ADMIN_BAN"Admin menu");
}

public 
ShowMenu(idlvlcid)
{
    if(!
cmd_access(idlvlcid0))
        return 
PLUGIN_HANDLED;

    new 
menu menu_create(`"\r[FT] \wAdmin-Menu^n\yMain Menu", "MainMenu_Handler");

    menu_additem(menu, "\wSlay\y/\wSlap", "", 0);
    menu_additem(menu, "\wKick", "", 0);
    menu_additem(menu, "\wTransfer", "", 0);
    menu_additem(menu, "\wMute\y/\wGag", "", 0);

    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
    menu_display(id, menu, 0);
    return PLUGIN_HANDLED;
}

public MainMenu_Handler(id, menu, item)
{
    if(item == MENU_EXIT)
    {
        menu_cancel(id);
        return PLUGIN_HANDLED;
    }
    
    new command[6], name[64], access, callback;
    menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);

    switch(item)
    {
        case 0:
        {
                        // Should lead to another menu
            // Number one menuitem should be able to switch between slay and slap
                        // Number 2, 3, 4 etc should be players including yourself
        }
        case 1:
        {
            
        }
        case 2:
        {
            client_print(id, print_chat, "You have selected Transfer");
        }
        case 3:
        {
            // Should lead to another menu
                        // Number one menuitem should be able to switch between mute and gag
                        // Number 2, 3, 4 etc should be players

        }
    }

    menu_destroy(menu);
    return PLUGIN_HANDLED;



akcaliberg 12-22-2014 07:23

Re: Admin Menu
 
Make another menu function outside of the current menu function, lets call it MenuSlap. So it should be like

public MenuSlap(id) {}

In this function create a menu. The first item (item=0) is for switching. The following items are for players. So you will know if the item equals 0 then switch option is selected. If not, we will get the items info to find the data (which is player id). We will use a global boolean array to find that if the admin wants to slay or slap the players. And we will use the same variable to determine the switch items name.

it may be a little bit confusing but you will understand it with this example

PHP Code:

new bool:slay[33];
public 
MenuSlap(id) {
    
    new 
menu menu_create("Slay/Slap Menu","MenuSlapHandler");
    
    
// First item is for switching
    
menu_additem(menuslay[id] ? "Slay" "Slap",""); // if slay[id] == true then "Slay" else "Slap"
    // Followings will be for player list
    
    
new players[32],iNum;
    
get_players(players,iNum// Search for all players
    
    
static name[32], data[6],tempid;
    
// Loop through all players
    
for(new i;i<iNum;i++) {
        
tempid players[i];
        
get_user_name(tempid,name,31);
        
num_to_str(tempid,data,5); // Convert the id from int to string.
        
menu_additem(menu,name,data); 
    }
    
menu_display(id,menu)
    return 
PLUGIN_HANDLED;
}
public 
MenuSlapHandler(id,menu,item) {
    if(
item == MENU_EXIT) {
        
// Exit is selected, then we must return to the main menu.
        
ShowMenu(id);
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    if(!
item) { // if the first item is selected
        
slay[id] = !slay[id// switch the value of the boolean
        
MenuSlap(id// Display the menu again, or it will be destroyed and we will have to enter the menu again.
        
return PLUGIN_HANDLED
    
}
    
// if the first item is not selected then a player is selected for an action.
    
    // lets find the id of the selected player
    
new name[32], data[6], accesscallback;
    
menu_item_getinfo(menu,item,access,data,charsmax(data),name,charsmax(name),callback);
    
    new 
targetId str_to_num(data);
    if(
is_user_connected(targetId)) {
        
// then target has leaved the game
        
MenuSlap(id// Maybe there are still players that we want to slay/slap, show the menu again
        
return PLUGIN_HANDLED
    
}
    if(
slay[id]) {
        
// we will kill the targetId here
    
}
    else {
        
// we will slap the targetId here
    
}
    
MenuSlap(id// optional
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED




All times are GMT -4. The time now is 15:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.