AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menus + Files !! (https://forums.alliedmods.net/showthread.php?t=216081)

An Ark 05-16-2013 06:19

Menus + Files !!
 
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.



Blizzard_87 05-16-2013 06:42

Re: Menus + Files !!
 
use new menu system

An Ark 05-16-2013 07:11

Re: Menus + Files !!
 
Can you please point out the error in the above code.

Blizzard_87 05-16-2013 18:30

Re: Menus + Files !!
 
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.

ConnorMcLeod 05-16-2013 20:36

Re: Menus + Files !!
 
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.



An Ark 05-17-2013 04:16

Re: Menus + Files !!
 
Quote:

Originally Posted by ConnorMcLeod (Post 1953145)
Blizzard hasn't understood anything lol.

:)
Quote:

Originally Posted by ConnorMcLeod (Post 1953145)
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 :D).

ConnorMcLeod 05-17-2013 13:19

Re: Menus + Files !!
 
No, if you want help, post code on public area.

An Ark 05-19-2013 03:03

Re: Menus + Files !!
 
Ok. So what's the problem in the plugin.

ConnorMcLeod 05-19-2013 04:16

Re: Menus + Files !!
 
No plugin, no problem ;)

Seriously, your mistake(s) can be in some code you haven't put here.


All times are GMT -4. The time now is 16:26.

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