Raised This Month: $ Target: $400
 0% 

How to make callback with num_to_str() in menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EclipseCP
BANNED
Join Date: Dec 2010
Old 05-15-2011 , 11:17   How to make callback with num_to_str() in menu?
Reply With Quote #1

Hello everyone.

I wanted to do a callback, but I can not because have num_to_str() and prevents me from putting "buffer" to "menu_additem"

PHP Code:

new menu[128],num[8], buffer[128], menuidi

// [...]

num_to_str(inumcharsmax(num))
        
buffer[0] = i
buffer
[1] = 0
menu_additem
(menuidmenunumADMIN_ALLmenu_makecallback("c_menu3")) 
notify me if not well expressed, use translator.

Greetings
EclipseCP is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-15-2011 , 11:32   Re: How to make callback with num_to_str() in menu?
Reply With Quote #2

Show full code.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EclipseCP
BANNED
Join Date: Dec 2010
Old 05-15-2011 , 11:36   Re: How to make callback with num_to_str() in menu?
Reply With Quote #3

Sorry.

PHP Code:
public show_menu_test(id)
{
    new 
menu[128], lang[32], info[32], num[8], buffer[128], menuidi
    
    formatex
(menucharsmax(menu), "\yTest...")
    
    
menuid menu_create(menu"menu_test"

    for (
0sizeof(LANG_MODES); i++) 
    {
        if (
MAX_LIMIT[i] > g_test_count[id][i]) 
            
formatex(infocharsmax(info), "\r[\w%d\r/\w%d\r]"MAX_LIMIT[i] - g_test_count[id][i], MAX_LIMIT[i])
        else
            
formatex(infocharsmax(info), "\r[\y0\r/\w%d\r]"MAX_LIMIT[i])
        
        
formatex(menucharsmax(menu), "%s %s"LANG_MODES[i], info)
        
        
num_to_str(inumcharsmax(num))
        
        
buffer[0] = i
        buffer
[1] = 0
        menu_additem
(menuidmenubufferADMIN_ALLmenu_makecallback("c_menu3")) 
    }
    
    
// Sin exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_EXITNAMEmenu
    
    
menu_display(idmenuid


public 
menu_test(idmenuiditem)
{
    
// Menu was closed
    
if (item == MENU_EXIT)
    {
        
menu_destroy(menuid
        return 
PLUGIN_HANDLED;
    }
    
    new 
buffer[4], dummyitemid
    menu_item_getinfo
(menuiditemdummybuffercharsmax(buffer), __dummy)
    
    
test1 str_to_num(buffer
    
    
menu_destroy(menuid)
    
    
show_menu_player_list(id)
    
    return 
PLUGIN_HANDLED;
}

public 
c_menu3(idmenuiditem)
{
    
// Retrieve itemid
    
new buffer[6]
    new 
_accesscallback
    menu_item_getinfo
(menuiditem_accessbuffercharsmax(buffer), __callback)
    
    new 
buffer[0]
    
    if (
MAX_LIMIT[i] > g_admin_count[id][i]) 
        return 
ITEM_ENABLED
        
    
return ITEM_DISABLED        

EclipseCP is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-15-2011 , 11:51   Re: How to make callback with num_to_str() in menu?
Reply With Quote #4

Are i and 0 the only data put in the buffer that you want transferred to the callback?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EclipseCP
BANNED
Join Date: Dec 2010
Old 05-18-2011 , 02:15   Re: How to make callback with num_to_str() in menu?
Reply With Quote #5

Quote:
Originally Posted by Exolent[jNr] View Post
Are i and 0 the only data put in the buffer that you want transferred to the callback?
yes but I cannot because I have to put "num", and if I put "callback" always it appears as that I selected the option 1 :S
EclipseCP is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-18-2011 , 02:18   Re: How to make callback with num_to_str() in menu?
Reply With Quote #6

The callback works almost the same as the menu handler.

The way you select the option from the callback is the exact same that you could with the menu handler.

Your buffer variable is useless.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EclipseCP
BANNED
Join Date: Dec 2010
Old 06-09-2011 , 07:10   Re: How to make callback with num_to_str() in menu?
Reply With Quote #7

sorry to revive, but the problem remains :/, it's like always choose the first option

PHP Code:
public show_menu_test(id)
{
    new 
menu[128], lang[32], info[32], buffer[128], menuidi
    
    formatex
(menucharsmax(menu), "\yTest...")
    
    
menuid menu_create(menu"menu_test"

    for (
0sizeof(LANG_MODES); i++) 
    {
        if (
MAX_LIMIT[i] > g_test_count[id][i]) 
            
formatex(infocharsmax(info), "\r[\w%d\r/\w%d\r]"MAX_LIMIT[i] - g_test_count[id][i], MAX_LIMIT[i])
        else
            
formatex(infocharsmax(info), "\r[\y0\r/\w%d\r]"MAX_LIMIT[i])
        
        
formatex(menucharsmax(menu), "%s %s"LANG_MODES[i], info)
        
        
num_to_str(ibuffercharsmax(buffer))
        
        
buffer[0] = i
        buffer
[1] = 0
        menu_additem
(menuidmenubufferADMIN_ALLmenu_makecallback("c_menu3")) 
    }
    
    
// Sin exit
    
formatex(menucharsmax(menu), "%L"id"MENU_BACK")
    
menu_setprop(menuidMPROP_EXITNAMEmenu
    
    
menu_display(idmenuid


public 
menu_test(idmenuiditem)
{
    
// Menu was closed
    
if (item == MENU_EXIT)
    {
        
menu_destroy(menuid
        return 
PLUGIN_HANDLED;
    }
    
    new 
buffer[4], dummyitemid
    menu_item_getinfo
(menuiditemdummybuffercharsmax(buffer), __dummy)
    
    switch (
str_to_num(buffer))
   { 
        case 
1client_print(idprint_center"Option 1")
        case 
2client_print(idprint_center"Option 2")
   }
    
    
menu_destroy(menuid)
    
    
show_menu_player_list(id)
    
    return 
PLUGIN_HANDLED;
}

public 
c_menu3(idmenuiditem)
{
    
// Retrieve itemid
    
new buffer[6]
    new 
_accesscallback
    menu_item_getinfo
(menuiditem_accessbuffercharsmax(buffer), __callback)
    
    new 
buffer[0]
    
    if (
MAX_LIMIT[i] > g_admin_count[id][i]) 
        return 
ITEM_ENABLED
        
    
return ITEM_DISABLED        

How should I do then?
EclipseCP is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-09-2011 , 19:22   Re: How to make callback with num_to_str() in menu?
Reply With Quote #8

Remove these:
PHP Code:
        buffer[0] = i
        buffer
[1] = 
Change this:
PHP Code:
    new buffer[0
to this:
PHP Code:
    new str_to_num(buffer
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


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 04:30.


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