AlliedModders

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

Dizzy 04-29-2007 21:19

Menu Problem
 
Hey guys, I have this menu for my Nade Giver plugin

Code:

//////////////////////////////////
//AMXMOD[X]                    //
//Nade Giver v1.5              //
//By: Dizzy                    //
//(©)All rights reserved        //
//                              //
//Cvars:                        //
// amx_nadegiver (0|1) (off|on) //
//                              //
//Client Commands:              //
// nademenu                    //
//                              //
//Description:                  //
//                              //
//  When a new round begins    //
//  you can type the client    //
//  commands to obtain two    //
//  flashes, one he grenade    //
//  ,and one smoke per round.  //
//////////////////////////////////

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fun>

#define PLUGIN  "Nade Giver"
#define VERSION "1.5"
#define AUTHOR  "Dizzy"
#define DISPLAY_MSG

new flash[33]
new he[33]
new smoke[33]

//////////////////////
//  REGISTRATION  //
//////////////////////
public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR);

        register_cvar("amx_nadegiver","1");

        register_clcmd("say nademenu","showMENU");
        register_clcmd("say_team nademenu","showMENU");

        register_concmd("nademenu","showMENU");

        register_menucmd(register_menuid("Nade Menu"), 1023, "menu");

        register_event("ResetHUD","roundchange","b");

}

//////////////////////
//  CLIENT CONNECT  //
//////////////////////
public client_connect(id)
{
        flash[id] = 2
        he[id] = 1
        smoke[id] = 1
}

/////////////////////////
//  CLIENT DISCONNECT  //
/////////////////////////
public client_disconnect(id)
{
        flash[id] = 2
        he[id] = 1
        smoke[id] = 1
}

//////////////////////
//      INFORM      //
//////////////////////
#if defined DISPLAY_MSG
public client_putinserver(id)
{
        if (is_user_bot(id))
                return;
       
        set_task(25.0, "inform", id);
}
#endif

#if defined DISPLAY_MSG
public inform(id)
{
        client_print(id, print_chat, "[Nade Giver]: This server is running Nade Giver v1.5 -- By: Dizzy");
        client_print(id, print_chat, "[Nade Giver]: Type nademenu to start!");
        return PLUGIN_HANDLED;
}
#endif

//////////////////////
//    SHOWMENU      //
//////////////////////
public showMENU(id)
{
        new menu[192];
        new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;

        format(menu, 191, "Nade Giver Menu:^n^n1. Flash Bang Grenade^n2. Highly Explosive Grenade^n3. Smoke Grenade^n^n0. Exit");
        show_menu(id,keys,menu);
        return PLUGIN_HANDLED;
}

//////////////////////
//      MENU      //
//////////////////////
public menu(id, key)
{
        if(!get_cvar_num("amx_nadegiver"))
        {
                client_print(id, print_chat, "[Nade Giver]: Sorry, the plugin is off!");
                return PLUGIN_HANDLED;
        }
        if(!is_user_alive(id))
        {
                client_print(id, print_chat, "[Nade Giver]: You must be alive to get grenades!");
                return PLUGIN_HANDLED;
        }
        switch(key)
        {
                case 0:
                {
                        if (flash[id] == 2)
                        {
                                give_item(id,"weapon_flashbang")
                                flash[id]--
                                client_print (id, print_center, "[Nade Giver]: You Used A Flash Bang! You Have 1 Flash Bangs Remaining!")
                        }

                        if (flash[id] == 1)
                        {
                                give_item(id,"weapon_flashbang")
                                flash[id]--
                                client_print (id, print_center, "[Nade Giver]: You Used A Flash Bang! You Have 0 Flash Bangs Remaining!")
                        }

                        if (flash[id] == 0)
                        {
                                client_print (id, print_center, "[Nade Giver]: You Have 0 Flash Bangs Remaining!")
                        }
                }

                case 1:
                {
                        if (he[id] == 1)
                        {
                                give_item(id,"weapon_hegrenade")
                                he[id]--
                                client_print (id, print_center, "[Nade Giver]: You Used A HE Grenade! You Have 0 HE Grenades Remaining!")
                        }

                        if (he[id] == 0)
                        {
                                client_print (id, print_center, "[Nade Giver]: You Have 0 HE Grenades Remaining!")
                        }
                }

                case 2:
                {
                        if (smoke[id] == 1)
                        {
                                give_item(id,"weapon_smokegrenade")
                                smoke[id]--
                                client_print (id, print_center, "[Nade Giver]: You Used A Smoke Grenade! You Have 0 Smoke Grenades Remaining!")
                        }

                        if (smoke[id] == 0)
                        {
                                client_print (id, print_center, "[Nade Giver]: You Have 0 Smoke Grenades Remaining!")
                        }
                }
        }
        return PLUGIN_CONTINUE;
}
///////////////////////
//    ROUNDCHANGE    //
///////////////////////
public roundchange(id)
{
        flash[id] = 2
        he[id] = 1
        smoke[id] = 1

        client_print (id, print_center, "[Nade Giver]: You Have 2 Flash Bangs, 1 Smoke Grenade and 1 HE Grenade Remaining!")

        return PLUGIN_CONTINUE
}

Now the issue is that when the menu is up it doesn't actually function.

I think the if commands are what is screwing it up. How can I make the switch work properly?

Thanks sooo much in advance!

Dizzy 04-30-2007 20:56

Re: Menu Problem
 
*bump*

Please help :(

Drak 04-30-2007 21:06

Re: Menu Problem
 
Code:
///////////////////////////////// //AMXMOD[X]                     // //Nade Giver v1.5               // //By: Dizzy                     // //(©)All rights reserved        // //                              // //Cvars:                        // // amx_nadegiver (0|1) (off|on) // //                              // //Client Commands:              // // nademenu                     // //                              // //Description:                  // //                              // //   When a new round begins    // //   you can type the client    // //   commands to obtain two     // //   flashes, one he grenade    // //   ,and one smoke per round.  // ////////////////////////////////// #include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> #include <fun> #define PLUGIN  "Nade Giver" #define VERSION "1.5" #define AUTHOR  "Dizzy" #define DISPLAY_MSG new flash[33] new he[33] new smoke[33] ////////////////////// //   REGISTRATION   // ////////////////////// public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_nadegiver","1");     register_clcmd("say nademenu","showMENU");     register_clcmd("say_team nademenu","showMENU");     register_concmd("nademenu","showMENU");     register_menucmd(register_menuid("Nade Giver Menu"), 1023, "_nademenu");     register_event("ResetHUD","roundchange","b"); } ////////////////////// //  CLIENT CONNECT  // ////////////////////// public client_connect(id) {     flash[id] = 2     he[id] = 1     smoke[id] = 1 } ///////////////////////// //  CLIENT DISCONNECT  // ///////////////////////// public client_disconnect(id) {     flash[id] = 2     he[id] = 1     smoke[id] = 1 } ////////////////////// //      INFORM      // ////////////////////// #if defined DISPLAY_MSG public client_putinserver(id) {     if (is_user_bot(id))         return;         set_task(25.0, "inform", id); } #endif #if defined DISPLAY_MSG public inform(id) {     client_print(id, print_chat, "[Nade Giver]: This server is running Nade Giver v1.5 -- By: Dizzy");     client_print(id, print_chat, "[Nade Giver]: Type nademenu to start!");     return PLUGIN_HANDLED; } #endif ////////////////////// //    SHOWMENU      // ////////////////////// public showMENU(id) {     new menu[192];     //new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3;         new keys = (1<<0|1<<1|1<<2|1<<3)     format(menu, 191, "Nade Giver Menu:^n^n1. Flash Bang Grenade^n2. Highly Explosive Grenade^n3. Smoke Grenade^n^n0. Exit");     show_menu(id,keys,menu);     return PLUGIN_HANDLED; } ////////////////////// //       MENU       // ////////////////////// public _nademenu(id, key) {     if(!get_cvar_num("amx_nadegiver"))     {         client_print(id, print_chat, "[Nade Giver]: Sorry, the plugin is off!");         return PLUGIN_HANDLED;     }     if(!is_user_alive(id))     {         client_print(id, print_chat, "[Nade Giver]: You must be alive to get grenades!");         return PLUGIN_HANDLED;     }     switch(key)     {         case 0:         {             if (flash[id] == 2)             {                 give_item(id,"weapon_flashbang")                 flash[id]--                 client_print (id, print_center, "[Nade Giver]: You Used A Flash Bang! You Have 1 Flash Bangs Remaining!")             }             if (flash[id] == 1)             {                 give_item(id,"weapon_flashbang")                 flash[id]--                 client_print (id, print_center, "[Nade Giver]: You Used A Flash Bang! You Have 0 Flash Bangs Remaining!")             }             if (flash[id] == 0)             {                 client_print (id, print_center, "[Nade Giver]: You Have 0 Flash Bangs Remaining!")             }         }         case 1:         {             if (he[id] == 1)             {                 give_item(id,"weapon_hegrenade")                 he[id]--                 client_print (id, print_center, "[Nade Giver]: You Used A HE Grenade! You Have 0 HE Grenades Remaining!")             }             if (he[id] == 0)             {                 client_print (id, print_center, "[Nade Giver]: You Have 0 HE Grenades Remaining!")             }         }         case 2:         {             if (smoke[id] == 1)             {                 give_item(id,"weapon_smokegrenade")                 smoke[id]--                 client_print (id, print_center, "[Nade Giver]: You Used A Smoke Grenade! You Have 0 Smoke Grenades Remaining!")             }             if (smoke[id] == 0)             {                 client_print (id, print_center, "[Nade Giver]: You Have 0 Smoke Grenades Remaining!")             }         }     }     return PLUGIN_CONTINUE; } /////////////////////// //    ROUNDCHANGE    // /////////////////////// public roundchange(id) {     flash[id] = 2     he[id] = 1     smoke[id] = 1     client_print (id, print_center, "[Nade Giver]: You Have 2 Flash Bangs, 1 Smoke Grenade and 1 HE Grenade Remaining!")     return PLUGIN_CONTINUE }
You had "show_menu(id,key,menu)" which is a function, plus you mis-named the "register_menuid".
I also recommend you change "client_connect" to "client_putinserver" since I think connect is to early.


All times are GMT -4. The time now is 06:44.

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