Raised This Month: $ Target: $400
 0% 

scripting and menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-07-2011 , 11:41   scripting and menu
Reply With Quote #1

(I hope I have not made ​​mistakes in this pattern)

In this menu handler 1 key runs some function and opens menu again
(first page).
Last key runs another function, but it must open second page of menu.
I dont know how.


Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)

    register_clcmd("menu_example", "function_menu", ADMIN_ALL,"")
        
    register_clcmd("music_switch" , "my_switch")
}

public my_action(id)
{
    //something here
} 

public my_switch(id)
{
    //something here
} 

public function_menu(id)
{
    new menu = menu_create("My_menu", "menu_handler")
    menu_additem(menu, "first menu item","1")
    menu_additem(menu, "second menu item","2")
    menu_additem(menu, "...", "3")
    menu_additem(menu, "...", "4")
    menu_additem(menu, "...", "5")
    menu_additem(menu, "...", "6")
    menu_additem(menu, "...", "7")
    menu_additem(menu, "...", "8")
    menu_additem(menu, "...", "9")    
    menu_additem(menu, "..." "10")    
    menu_additem(menu, "last menu item" , "11")

    menu_setprop(menu, MPROP_EXIT,MEXIT_ALL)
    menu_display(id,menu,0)

    return PLUGIN_HANDLED
}

public menu_handler(id,menu,item)
{
    if(item == MENU_EXIT)
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }

    new data[6], iName[64], access, callback
    menu_item_getinfo(menu, item, access, data, 5, iName, 63, callback)

    new key = str_to_num(data)
    switch(key)
    {
case 1:
    client_cmd(id, "my_action")
    client_cmd(id, "menu_example")

case 2:
    //something
       
case 3:
    //something
       
case 4:
    //something          

case 5:
    //something

case 6:
    //something  

case 7:
    //something

case 8:
    //something
   
case 9:
    //something
case 10:
{
    //something
}
case 11:
{
    client_cmd(id, "music_switch")
    client_cmd(id, "menu_example")
     

}

    return PLUGIN_CONTINUE
}
ps how set [phpcode] ?

Last edited by neverminde; 04-07-2011 at 13:00.
neverminde is offline
Nyuszy
Senior Member
Join Date: Apr 2009
Old 04-07-2011 , 12:22   Re: scripting and menu
Reply With Quote #2

menu_display ( id, menu, page )
Nyuszy is offline
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-07-2011 , 13:05   Re: scripting and menu
Reply With Quote #3

i have add this
Code:
menu_display( id, "function_menu", "1")
at 11 key
Code:
case 11:
{     
         client_cmd(id, "music_switch")      
         menu_display( id, "function_menu", "1")     
}
1 Error now - error 035: argument type mismatch (argument 2)
neverminde is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-07-2011 , 13:11   Re: scripting and menu
Reply With Quote #4

Don't use client_cmd, call the function.

client_cmd(id, "music_switch")

->

my_switch(id)


Also :

new key = str_to_num(data)
switch(key)

Could be replaced with

switch( item )

but items start from 0 when key start from 1


For php code use [php]
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-07-2011 , 19:38   Re: scripting and menu
Reply With Quote #5

Here ya go, use this as an example:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("say menu""cmdMenu")
}

public 
cmdMenu(id)
{
    
open_menu(id0)
    
client_print(idprint_chat"cmdMenu")
}

open_menu(idpage 0)
{
    
// show menu here
    
client_print(idprint_chat"creating menu")
    new 
menu menu_create("My_menu""menu_handler")
    
menu_additem(menu"first menu item","1")
    
menu_additem(menu"second menu item","2")
    
menu_additem(menu"...""3")
    
menu_additem(menu"...""4")
    
menu_additem(menu"...""5")
    
menu_additem(menu"...""6")
    
menu_additem(menu"...""7")
    
menu_additem(menu"...""8")
    
menu_additem(menu"...""9")    
    
menu_additem(menu"...""10")    
    
menu_additem(menu"last menu item" "11")

    
menu_setprop(menuMPROP_EXIT,MEXIT_ALL)
    
menu_display(id,menu,page)

    return 
PLUGIN_HANDLED
}

public 
menu_handler(id,menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64], _accesscallback
    menu_item_getinfo
(menuitem_accessdata5iName63callback)

    new 
key str_to_num(data)
    switch(
key)
    {
        case 
1:
        {
            
my_action(id)
        }
        case 
2:{}
        case 
3:{}
        case 
4:{}
        case 
5:{}
        case 
6:{}
        case 
7:{}
        case 
8:{}
        case 
9:{}
        case 
10:{}
        case 
11:
        {
            
my_switch(id)
        }
    }
    
menu_destroy(menu)
    
    new 
oldmenunewmenumenupage
    player_menu_info
(idoldmenunewmenumenupage)
    
open_menu(idmenupage)
    return 
PLUGIN_CONTINUE
}

public 
my_action(id)
{
    
//something here
    
client_print(idprint_chat"my_action")


public 
my_switch(id)
{
    
//something here
    
client_print(idprint_chat"my_switch")

__________________
fysiks is offline
neverminde
Senior Member
Join Date: Feb 2011
Location: St.Piter
Old 04-08-2011 , 18:10   Re: scripting and menu
Reply With Quote #6

very cool! that is what i need.
thanks thanks thanks !
neverminde is offline
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 19:54.


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