Raised This Month: $ Target: $400
 0% 

Menu Problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 04-29-2007 , 21:19   Menu Problem
Reply With Quote #1

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 is offline
Send a message via AIM to Dizzy
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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