Raised This Month: $ Target: $400
 0% 

Menus + Files !!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
An Ark
Junior Member
Join Date: May 2013
Old 05-16-2013 , 06:19   Menus + Files !!
Reply With Quote #1

I have called a function with a menu. Once the user calls this function for the first time its getting executed correctly. But for the second time the menu just dont appear. The Code Complies without any errors and warnings. No errors about the plugin in console and no error logs. Also the Code contains file handling.

PHP Code:
#define B1    1 << 0;
#define B0    1 << 9;

new gKeyslolMenu B1 B0;

public 
plugin_init()
{
    
register_clcmd("say /lol""lolMenu");
    
register_menucmd(register_menuid("lolMenu"), gKeyslolMenu"handlelolMenu");

}

public 
lolMenu(id)
{    
    
    new 
szMenu[256];
        
    
addszMenu 256 "\r1. \wCall lol Menu Test^n" );
    
    
addszMenu 256 "\r0. \wClose" );

    
show_menuid gKeyslolMenu szMenu , -"lolMenu" );
    
}

public 
handlelolMenu(idnum)
{
    switch (
num)
    {
        case 
N1: { lolProcess; }
        case 
N0: { return; }
    }
    
    if (
num != N1 && num != N9)
    {
        
lolMenu(id);
    }
}

public 
lolProcessid )
{
    
// Sum huge variables
    
    // Big loops
    // File open and get data from file.
    // Use of Cstrike and fun functions.
    // fclose.


Last edited by An Ark; 05-17-2013 at 04:18. Reason: Small Mistake in Example
An Ark is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-16-2013 , 06:42   Re: Menus + Files !!
Reply With Quote #2

use new menu system
__________________
Blizzard_87 is offline
An Ark
Junior Member
Join Date: May 2013
Old 05-16-2013 , 07:11   Re: Menus + Files !!
Reply With Quote #3

Can you please point out the error in the above code.
An Ark is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-16-2013 , 18:30   Re: Menus + Files !!
Reply With Quote #4

Code:
#include < amxmodx > #define B1    1 << 1 #define B0    1 << 10 new gKeyslolMenu = B1 | B0; public plugin_init() {     register_clcmd("say /lol", "lolMenu");     register_menucmd(register_menuid("lolMenu"), gKeyslolMenu, "handlelolMenu"); } public lolMenu(id) {             new szMenu[256];             add( szMenu , 256 , "\r1. \wCall lol Menu Test^n" );         add( szMenu , 256 , "\r0. \wClose" );     show_menu( id , gKeyslolMenu , szMenu , -1 , "lolMenu" );     } public handlelolMenu(id, szMenu, num) {     switch (num)     {         case 1: { lolProcess( id ); }         case 0:         {         menu_destroy( szMenu );         return;         }     }         if (num != 1 && num != 9)     {         lolMenu(id);     } } public lolProcess( id ) {     // Sum huge variables         // Big loops     // File open and get data from file.     // Use of Cstrike and fun functions.     // fclose. }

menu displays as for the number 0 key the second option only works with key 2....
as to howto fix this im not sure ive never worked with old style menu system.
__________________
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-16-2013 , 20:36   Re: Menus + Files !!
Reply With Quote #5

Blizzard hasn't understood anything lol.

Here is corrected code with comments :

PHP Code:
#define B1    1 << 1; // here should be 1<<0 but you can use already defined MENU_KEY_1
#define B0    1 << 10; // here should be 1<<9 but you can use already defined MENU_KEY_0

new const gKeyslolMenu MENU_KEY_1 MENU_KEY_0;

public 
plugin_init()
{
    
register_clcmd("say /lol""lolMenu");
    
register_menucmd(register_menuid("lolMenu"), gKeyslolMenu"handlelolMenu");

}

public 
lolMenu(id)
{    
    
    new 
szMenu[256];
        
    
addszMenu charsmax(szMenu) , "\r1. \wCall lol Menu Test^n" );
    
    
addszMenu charsmax(szMenu) , "\r0. \wClose" );

    
show_menuid gKeyslolMenu szMenu , -"lolMenu" );
    
}

public 
handlelolMenu(idkey)
{
    
// key is 0(for 1), 1(for2), etc.... 9(for0)
    // either you use those values : 0:lolProcess, 9;return
    // either you use this tip to convert to numbers 1,2,3,4,5,6,7,8,9,0
    
new num = (key+1) % 10
    switch (++
num)
    {
        case 
1: { lolProcess; }
        case 
0: { return; }
    }
   
   
// This can't happen since you have not registered keys
    // if (num != 1 && num != 0)
    // {
        // lolMenu(id);
    // }
}

public 
lolProcessid )
{
    
// Sum huge variables
    
    // Big loops
    // File open and get data from file.
    // Use of Cstrike and fun functions.
    // fclose.

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
An Ark
Junior Member
Join Date: May 2013
Old 05-17-2013 , 04:16   Re: Menus + Files !!
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Blizzard hasn't understood anything lol.

Quote:
Originally Posted by ConnorMcLeod View Post
Here is corrected code with comments :
I have set the keys correctly in the Original code. The above given code is just an example how my plugin works.
Also I have said u that the menu appears correctly for the first time and executes "lolProcess (id)" function correctly, if what u have said is correct then the function shouldn't have executed even for the first time. But the actual problem is that it wont appear for the second time.

ConnorMcLeod, if u want to help me i would like to send the original code though Pvt Msg. ( Ignoring ur Signature ).

Last edited by An Ark; 05-17-2013 at 04:17.
An Ark is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-17-2013 , 13:19   Re: Menus + Files !!
Reply With Quote #7

No, if you want help, post code on public area.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
An Ark
Junior Member
Join Date: May 2013
Old 05-19-2013 , 03:03   Re: Menus + Files !!
Reply With Quote #8

Ok. So what's the problem in the plugin.
An Ark 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 16:26.


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