AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My plugin =( (https://forums.alliedmods.net/showthread.php?t=26405)

umarsa 04-01-2006 15:47

My plugin =(
 
Hi all i want some help with my plugin that i wanted to make i dont know if you lot can make it but here it goes

my code is
Code:

#include <amxmodx>
#include <amxmisc>


new mAdminMenu // Menu
new mcbAdminMenu // Menu Callback



public plugin_init() {
        /* Menu Admin Menu */
        /* Use menu_display(id, mAdminMenu, 0) to show the menu to an user. */
        mAdminMenu = menu_create("Admin Menu", "mh_AdminMenu")
        mcbAdminMenu = menu_makecallback("mcb_AdminMenu")
        menu_additem(mAdminMenu, "Restart Server (20)", "ma_AdminMenu", ADMIN_IMMUNITY, mcbAdminMenu)
        menu_additem(mAdminMenu, "Shutdown Server (20)", "ma_AdminMenu", ADMIN_IMMUNITY, mcbAdminMenu)
        /* Menu End */

        register_plugin("Admin Menu", "1.0", "Umar Salim")
        register_clcmd("amx_adminmenu", "mAdminMenu")
       
}


/* Menu Admin Menu */

public mh_AdminMenu(id, menu, item) {
        /* This event is called when someone presses a key on this menu */
}

public ma_AdminMenu(id) {
        /* This event is called when an item was selected */
}

public mcb_AdminMenu(id, menu, item) {
        /* This is the callback-event, here you can set items enabled or disabled. */
        /* If you want to enable an item, use: return ITEM_ENABLED */
        /* If you want to disable an item, use: return ITEM_DISABLED */
}

now u see this "register_clcmd("amx_adminmenu", "mAdminMenu")" the mAdminMenu i dont know it that is it and thats the code and i dont know what to register_clcmd i know that i want "amx_adminmenu" to go to this menu i made but i dont know what to bind that to can sum1 help me out :S ?

~ umarsa

v3x 04-01-2006 18:36

Code:
register_clcmd("amx_adminmenu" , "cmd_adminmenu");
Code:
public cmd_adminmenu(id , lvl , cid) {   if(!cmd_access(id , lvl , cid , 1))     return PLUGIN_HANDLED;   menu_display(id , mAdminMenu , 0);   return PLUGIN_HANDLED; }

umarsa 04-02-2006 06:11

thx this works but when i press a key on the menu how do i make it that it returns to the menu not exit the menu ?

Code:


#include <amxmodx>
#include <amxmisc>


new mAdminMenu // Menu
new mcbAdminMenu // Menu Callback



public plugin_init() {
  /* Menu Admin Menu */
  /* Use menu_display(id, mAdminMenu, 0) to show the menu to an user. */
  mAdminMenu = menu_create("Admin Menu", "mh_AdminMenu")
  mcbAdminMenu = menu_makecallback("mcb_AdminMenu")
  menu_additem(mAdminMenu, "Restart Server (20)", "ma_AdminMenu", ADMIN_IMMUNITY, mcbAdminMenu)
  menu_additem(mAdminMenu, "Shutdown Server (20)", "ma_AdminMenu", ADMIN_IMMUNITY, mcbAdminMenu)
  /* Menu End */

        register_plugin("Admin Menu", "1.0", "Umar Salim")
        register_clcmd("amx_adminmenu" , "cmd_adminmenu");
   
}

public cmd_adminmenu(id , lvl , cid)
{
  if(!cmd_access(id , lvl , cid , 1))
    return PLUGIN_HANDLED;

  menu_display(id , mAdminMenu , 0);

  return PLUGIN_HANDLED;
}

/* Menu Admin Menu */

public mh_AdminMenu(id, menu, item) {
  /* This event is called when someone presses a key on this menu */
}

public ma_AdminMenu(id) {
  /* This event is called when an item was selected */
}

public mcb_AdminMenu(id, menu, item) {
  /* This is the callback-event, here you can set items enabled or disabled. */
  /* If you want to enable an item, use: return ITEM_ENABLED */
  /* If you want to disable an item, use: return ITEM_DISABLED */
}

also i got this plugin istalled :

Code:

#include <amxmodx>
#include <amxmisc>

#define SHUTDOWN 0
#define RESTART 1

new g_bShuttingDown
new g_iMode

public plugin_init()
{
        register_plugin("Server Shutdown","2.1","Hawk552")
       
        register_concmd("amx_shutdown","fShutDown",ADMIN_RCON,"<seconds (1-20)> - shuts down the server in seconds")
        register_concmd("say /shutdown","fShutDown",ADMIN_RCON,"<seconds (1-20)> - shuts down the server in seconds")
        register_concmd("amx_restart","fShutDown",ADMIN_RCON,"<seconds (1-20)> - restarts the server in seconds")
        register_concmd("say /restart","fShutDown",ADMIN_RCON,"<seconds (1-20)> - restarts the server in seconds")
}

public fShutDown(id,level,cid)
{
        if(!cmd_access(id,level,cid,2) || g_bShuttingDown)
                return PLUGIN_HANDLED
               
        new szArg[6]
        read_argv(0,szArg,5)
       
        if(equali(szArg,"amx_r"))
                g_iMode = RESTART
               
        read_argv(1,szArg,5)
        new iTime = str_to_num(szArg)
       
        if(!iTime || iTime > 20)
        {
                console_print(id,"[AMXX] You did not supply a valid time (between 1-20 seconds)")
               
                return PLUGIN_HANDLED
        }
       
        new szName[32]
        get_user_name(id,szName,31)
       
        new szAuthid[32]
        get_user_authid(id,szAuthid,31)
       
        log_amx("Cmd: ^"%s<%i><%s>^" initiate %s",szName,id,szAuthid,g_iMode ? "restart" : "shutdown")
       
        switch(get_cvar_num("amx_show_activity"))
        {
                case 1 : client_print(0,print_chat,"ADMIN: %s server in %i seconds",g_iMode ? "Restart" : "Shutdown",iTime)
                case 2 : client_print(0,print_chat,"ADMIN %s: %s server in %i seconds",szName,g_iMode ? "Restart" : "Shutdown",iTime)
        }
       
        fInitiate(iTime)
       
        return PLUGIN_HANDLED
}

public fInitiate(iTime)
{
        g_bShuttingDown = true
       
        new iCount
        for(iCount = iTime;iCount != 0;iCount--)
                set_task(float(abs(iCount-iTime)),"fCallTime",iCount)
       
        set_task(float(iTime),"fCallTime",0)
}

public fCallTime(iCount)
{
        if(!iCount)
        {
                switch(g_iMode)
                {
                        case SHUTDOWN :
                                server_cmd("quit")
                       
                        case RESTART :
                                server_cmd("restart")
                }
        }
       
        new szWord[32]
        num_to_word(iCount,szWord,31)
       
        client_cmd(0,"spk ^"fvox/%s^"",szWord)
}

how do i make it that the "Restart Option" in my menu so it uses the commad amx_restart 20 or do i have to combine both plugins together and use the command "fShutDown" but i dont get it that both commands are the same . same with the Shutdown can u make it so it uses the comand "amx_shutdown 20"

AAleaderNik 04-02-2006 16:28

why dont you use amxmodmenu?

Freecode 04-02-2006 16:52

Heres a tutorial on the new menu system that im writing. Its not done, but most of it is finished.

http://wiki.amxmodx.org/index.php/Using_New_Menu_System

v3x 04-02-2006 23:55

Looks finished to me.


All times are GMT -4. The time now is 16:30.

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