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

add text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MacL
Member
Join Date: May 2021
Old 06-16-2021 , 07:59   add text
Reply With Quote #1

hey, how can i make a menu like this:
PHP Code:
 Title
         Text 1
         Text 2
         Text 3
         Text 4
         Text 5
         Text 6
         1. option 1
         0. 
Exit 
I tried use menu_addtext()but it needs to be an option before that. or itried ^n (\) but I think there is a limit for it.
MacL is offline
Crackhead69
Member
Join Date: Feb 2021
Old 06-16-2021 , 08:25   Re: add text
Reply With Quote #2

You can do that with ^n no problem
PHP Code:
#include <amxmodx>

public plugin_init() {
    
register_clcmd("say /menu","testmenu")
}

public 
testmenu(id){
    new 
menu menu_create("Title^n Text1^n Text2^n Text3^n Text4^n Text5^n Text6","menu_handle")
    
    
menu_additem(menu"Option1","",0)
    
menu_additem(menu"Exit","",0)
    
    
menu_setprop(menu,MPROP_EXIT,MEXIT_NEVER)
    
    
menu_display(idmenu0)
}

public 
menu_handle(id,menu,item){
    if(
item == MENU_EXIT || !is_user_alive(id))
    {
        
menu_cancel(id)
        return
    }
    switch(
item){
        case 
0:client_print(idprint_chat"Option 1")
        case 
1:menu_cancel(id)
    }

Decide for yourself if u want to combine it with formatex or whatever for better understanding for your sake. This is nothing more but a working example i am giving you

Last edited by Crackhead69; 06-16-2021 at 08:28.
Crackhead69 is offline
MacL
Member
Join Date: May 2021
Old 06-16-2021 , 15:02   Re: add text
Reply With Quote #3

Already tried. Limits for large texts.
MacL is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-16-2021 , 16:30   Re: add text
Reply With Quote #4

Use old style menu.
Code:
#include <amxmodx>

#if !defined MAX_MENU_LENGTH
	const MAX_MENU_LENGTH = 512
#endif

/*
 * @note Keys is a bitflag value that represents which keys the user can press
 *       on the menu. If you want to display disabled menu options, or skip
 *       certain number slots, you should exclude that key from the bitflag.
 *       amxconst.inc provides MENU_KEY_* constants for convenience.
 */

 const MY_CUSTOM_MENU_KEYS = -1 // -1 = all keys
 

public plugin_init()
{
	register_plugin("Plugin", "Version", "Author")

	register_menucmd(register_menuid("My Custom Menu"), MY_CUSTOM_MENU_KEYS, "MyCustomMenuHandler")

	register_clcmd("say /menu", "ShowMyCustomMenu")
}


public ShowMyCustomMenu(index)
{
	new body[MAX_MENU_LENGTH], len

	len += copy(body[len], charsmax(body) - len, "\yTitle^n^n\w")
	len += copy(body[len], charsmax(body) - len, "Text 1^n")
	len += copy(body[len], charsmax(body) - len, "Text 2^n")
	len += copy(body[len], charsmax(body) - len, "Text 3^n")
	len += copy(body[len], charsmax(body) - len, "Text 4^n")
	len += copy(body[len], charsmax(body) - len, "Text 5^n")
	len += copy(body[len], charsmax(body) - len, "Text 6^n")
	len += copy(body[len], charsmax(body) - len, "\r1. \woption 1^n")
	len += copy(body[len], charsmax(body) - len, "^n\r0. \wExit^n")

	show_menu(index, MY_CUSTOM_MENU_KEYS, body, -1, "My Custom Menu")
	return PLUGIN_HANDLED
}

public MyCustomMenuHandler(index, key)
{
	switch (key)
	{
		case 9: // exit
		{
			return PLUGIN_HANDLED
		}
	}

	ShowMyCustomMenu(index)
	return PLUGIN_HANDLED
}
If you need formatting, replace "copy" with "formatex".
By the way, that will work only with menus of one page. If you need multiple pages you will have to do it manually. Check out plmenu.sma
__________________









Last edited by CrazY.; 06-16-2021 at 16:34.
CrazY. is offline
sb123
Senior Member
Join Date: Jan 2007
Old 06-16-2021 , 21:51   Re: add text
Reply With Quote #5

create a plmenu.ini text

;Player menu configuration
;Format: the content "corresponding command" displayed in the menu
;For example: M1 "say test 1"

"Server time" "say time"
"Map remaining time" "say timeleft"
"Next map" "say nextmap"
"Top 15" "say /top15"
"Display your own statistics" "say /rankstats"

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

/* Player Menus	*/

#define	MAX_MENU_NUM 40

new g_MenuName[	MAX_MENU_NUM ][32]
new g_MenuCmd[ MAX_MENU_NUM ][32]
new PMenuName[] = "Player menu"
new g_MenuItem[3][] = {
	"Next Page",
	"Back",
	"Exit"
}
new g_cNum
new g_menuPosition[33]

public plugin_init() {
	register_plugin("Player	Menu","0.1","nwb13")
	register_menucmd(register_menuid( PMenuName ),1023,"actionPlMenu")
	register_clcmd("say menu","PlMenu",ADMIN_ALL, "display player menu" )
	new configs[64]
	get_configsdir(configs,	63)
	format(configs,	63, "%s/%s", configs, "plmenu.ini")
	loadSettings(configs)
}

loadSettings(plmenuconfig[]) {
	if (!file_exists(plmenuconfig))
		return 0
	new temp[256]
	new a, pos = 0
	while (	g_cNum < MAX_MENU_NUM && read_file(plmenuconfig,pos++,temp,255,a) ) {	      
	if ( temp[0] ==	';' )
		continue
	if (parse(temp,g_MenuName[g_cNum],31,g_MenuCmd[g_cNum],31) < 2)
		continue
	++g_cNum
	}
	return 1
}

public PlMenu(id){
	if (is_user_connected(id))
		disPlayerMenu(id,g_menuPosition[id] = 0)
	return PLUGIN_HANDLED
}

disPlayerMenu(id,pos)	{
	if (pos	< 0)  return

	new menuBody[512]
	new b =	0
	new start = pos * 8

	if (start >= g_cNum )
		start = pos = g_menuPosition[id] = 0

	new len = format(menuBody,511,"\y%s\R%d/%d^n\w^n",PMenuName,pos+1,( g_cNum / 8 + ((g_cNum % 8) ? 1 : 0 )) )

	new end = start + 8
	new keys = MENU_KEY_0

	if (end > g_cNum )
		end = g_cNum

	for (new a = start; a < end; ++a) {
		keys |= (1<<b)
		len += format(menuBody[len],511-len,"%d. %s^n",++b,g_MenuName[a])
	}

	if (end != g_cNum ) {
    		format(menuBody[len],511-len,"^n9. %s...^n0. %s", g_MenuItem[0], pos ? g_MenuItem[1] : g_MenuItem[2])
		keys |= MENU_KEY_9
	}
	else	format(menuBody[len],511-len,"^n0. %s",pos ? g_MenuItem[1] : g_MenuItem[2])

	show_menu(id,keys,menuBody,-1,PMenuName)
}

public actionPlMenu(id,key){
	switch(key){
		case 8:{
			disPlayerMenu(id,++g_menuPosition[id])
		}
		case 9:{
			disPlayerMenu(id,--g_menuPosition[id])
		}
		default:{
			new menuitem = g_menuPosition[id] * 8 +	key
			client_cmd(id,"%s",g_MenuCmd[menuitem])
		}
	}
	return PLUGIN_HANDLED
}
__________________
sb123 is offline
Send a message via ICQ to sb123 Send a message via MSN to sb123 Send a message via Yahoo to sb123
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 02:22.


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