Raised This Month: $51 Target: $400
 12% 

[Help] print_chat menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wEight
BANNED
Join Date: Jan 2015
Old 01-13-2015 , 18:04   [Help] print_chat menu?
Reply With Quote #1

So i was working on a plugin where you select an option from the menu, a message will print on your chat for example: When you select option one in the menu a message diplays in your chat.

So i scripted this in the code box and it wont work, do i have to add something else or what is it?
Ingame the menu displays but the message doesn't when i select one option in the menu

Here's my script:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define PLUGIN "Ads Menu"
#define VERSION "1.0"
#define AUTHOR "wEight"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_clcmd("say /ads", "menu", ADMIN_LEVEL_C)
}
public menu(id)
{
new menu = menu_create("\rAds \yby wEight", "menu_handler")
//Menu items
menu_additem(menu, "Adsample1", "1", 0)
menu_additem(menu, "Adsample2", "2", 0)
menu_additem(menu, "Adsample3", "3", 0)
menu_additem(menu, "Adsample4", "4", 0)
menu_additem(menu, "Adsample5", "5", 0)
menu_additem(menu, "Adsample6", "6", 0)
menu_display(id, menu, 0)
}
public menu_handler(id, menu, item)  
//Chat prints
{
	new data[7];
        new Key = str_to_num(data);
	switch (Key)
	{
		case 1:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}

		case 2:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}

		case 3:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}

		case 4:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}

		case 5:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}
		
		case 6:
		{
			client_print(id, print_chat, "Example AD")
			client_print(id, print_center, "Look at your chat!")
		}
	}
}

Last edited by wEight; 01-13-2015 at 18:06.
wEight is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 01-13-2015 , 18:34   Re: [Help] print_chat menu?
Reply With Quote #2

PHP Code:
switch (Key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Example AD")
            
client_print(idprint_center"Look at your chat!")
        } 
case starts at 0 not 1.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-13-2015 , 19:12   Re: [Help] print_chat menu?
Reply With Quote #3

Quote:
Originally Posted by wickedd View Post
PHP Code:
switch (Key)
    {
        case 
1:
        {
            
client_print(idprint_chat"Example AD")
            
client_print(idprint_center"Look at your chat!")
        } 
case starts at 0 not 1.
No. The cases will start at 1 when using the data as the "key". The problem is that he never gets the data so the value of "Key" is always zero.

@wEight, I highly recommend that you read the tutorial regarding how to use these types of menus and see how it is supposed to be done.
__________________
fysiks is offline
wEight
BANNED
Join Date: Jan 2015
Old 01-27-2015 , 18:06   Re: [Help] print_chat menu?
Reply With Quote #4

Excuse my late respond
I tried to create another menu with the tutorial, this is how it looks like:

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "AdMenu"
#define VERSION "1.0"
#define AUTHOR "wEight"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_dictionary("admenu.txt")
	register_clcmd("say /ads", "AdMenu")
	register_clcmd("say /advertisements", "AdMenu")
}
public AdMenu(id)
{
	new menu = menu_create("\yAdvertisements by \rwEight", menu_handler);
	
	menu_additem(menu, "\yAdvertisement 1", "", 0);
	menu_additem(menu, "\yAdvertisement 2", "", 0);
	menu_additem(menu, "\yAdvertisement 3", "", ADMIN_RCON);
	
	menu_setdrop(menu, MPROT_EXIT, MEXIT_ALL);
	
	menu_display(id, menu, 0);
}
public menu_handler(id, menu, item)
{
	switch(item)
	{
		case 0:
		{
			client_print(id, print_chat, "This is Advertisement 1, for you!");
			
			menu_destroy(menu);
			return PLUGIN_HANDLED;
		}
		case 1:
		{
			client_print(id, print_chat, "This is Advertisement 2, also for you!");
		}
		case 2:
		{
			client_print(id, print_chat, "This is Advertisement 3, only for admins!");
		}
		case MENU_EXIT:
		{
			client_print(id, print_chat, "You exited the menu D:!");
		}
	}
	
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}
Saved it, tried to compile it, got these errors:

Code:
AdMenu.sma(19) : error 076: syntax error in the expression, or invalid function call
AdMenu.sma(25) : error 017: undefined symbol "menu_setdrop"
AdMenu.sma(25) : warning 215: expression has no effect
AdMenu.sma(25) : error 001: expected token: ";", but found ")"
AdMenu.sma(25) : error 029: invalid expression, assumed zero
AdMenu.sma(25) : fatal error 107: too many error messages on one line
Did i miss to include a module, did i typed something wrong (Don't mind the 4th line i can fix that)
wEight is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-27-2015 , 19:14   Re: [Help] print_chat menu?
Reply With Quote #5

Simply take a look at the errors. Find the line (in parentheses) and see what is different about yours compared to the tutorial or other examples.

Some errors are very clear. Undefined symbol means that something is not defined. Look at the line it points to and see what might be wrong, typically from misspellings but might also be missing include files (assume the former first).

Typically you should fix the first error first (especially if you have multiple errors on a single line) because one error can cause many more.
__________________

Last edited by fysiks; 01-27-2015 at 19:15.
fysiks is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 01-28-2015 , 09:11   Re: [Help] print_chat menu?
Reply With Quote #6

Try this:

Your problem was:
You missed adding at the end
"Menu_handler");
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "AdMenu"
#define VERSION "1.0"
#define AUTHOR "wEight"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_dictionary("admenu.txt")
    
register_clcmd("say /ads""AdMenu")
    
register_clcmd("say /advertisements""AdMenu")
}
public 
AdMenu(id)
{
    new 
menu menu_create("\yAdvertisements by \rwEight""menu_handler");
    
    
menu_additem(menu"\yAdvertisement 1"""0);
    
menu_additem(menu"\yAdvertisement 2"""0);
    
menu_additem(menu"\yAdvertisement 3"""ADMIN_RCON);
    
    
menu_display(idmenu0);
}
public 
menu_handler(idmenuitem)
{
    switch(
item)
    {
        case 
0:
        {
            
client_print(idprint_chat"This is Advertisement 1, for you!");
            
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
1:
        {
            
client_print(idprint_chat"This is Advertisement 2, also for you!");
        }
        case 
2:
        {
            
client_print(idprint_chat"This is Advertisement 3, only for admins!");
        }
        case 
MENU_EXIT:
        {
            
client_print(idprint_chat"You exited the menu D:!");
        }
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by Fuck For Fun; 01-28-2015 at 09:12.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Reply



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 17:13.


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