Raised This Month: $32 Target: $400
 8% 

need help for me !


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 03-07-2011 , 10:23   need help for me !
Reply With Quote #1

Hi man,
few days ago, I have tried to find function can pass the int var in newmenu.inc, but it seem none.
so I start to modify the newmenus.h and the newmenus.cpp

I want to add two native function like this :
PHP Code:
native menu_passint(menu, var);
native menu_get_int(menuitem, &var); 
my code int newmenus.h
Code:
struct menuitem 
{ 
    String name; 
    String cmd; 
 
    int var;
 
    int access; 
    int handler; 
 
    MENUITEM_CALLBACK pfn; 
    size_t id; 
 
    CVector<BlankItem> blanks; 
};
 
class menu
{
    //.....
    menuitem *AddIntVar(int var);
    //.....
}
in newmenus.cpp
Code:
menuitem *Menu::AddIntVar(int var)
{
    menuitem *pItem = new menuitem;
    pItem->var = var;
 
    m_Items.push_back(pItem);
    return pItem;
}
static cell AMX_NATIVE_CALL menu_passint(AMX *amx, cell *params)
{
    int var;
 
    GETMENU(params[1]);
 
    var = param[2];
 
    menuitem *pItem = pMenu->AddIntVar(var);
 
    return 1;
}
 
static cell AMX_NATIVE_CALL menu_get_int(AMX *amx, cell *params)
{
    GETMENU(params[1]);
 
    menuitem *pItem = pMenu->GetMenuItem(static_cast<item_t>(params[2]));
 
    if (!pItem) 
        return 0;
 
    cell *add = get_amxaddr(amx, param[3]);
 
    add[0] = pItem->var;
 
    return 1;
}
any problem ?
if so please point it out !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-07-2011 , 20:15   Re: need help for me !
Reply With Quote #2

Why don't you just pass the variable in the data?
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 03-07-2011 , 21:49   Re: need help for me !
Reply With Quote #3

Code:
menu_additem(menu, name, cmd, access, callback);

I know this function, but I have only a int variable,
then will like this if I use this function to pass the variable

Code:
num_to_str(var, szVar, charsmax(szVar));
menu_additem(menu, "", szVar);
and then you can see a menu that like this:

Menu Title

1.item_one
2.item_two
3.item_three
4.

0.EXIT

isn't it ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-07-2011 , 22:12   Re: need help for me !
Reply With Quote #4

The numbers in the menu are not controlled at all by menu_additem().
The "name" parameter is the only parameter shown in the menu.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 03-07-2011 , 22:27   Re: need help for me !
Reply With Quote #5

so you answer is menu_item is enough ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
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 22:44.


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