Raised This Month: $51 Target: $400
 12% 

Strange bug about menus in new amxx menu system


Post New Thread Reply   
 
Thread Tools Display Modes
lqlqlq
Senior Member
Join Date: Jan 2008
Old 01-21-2015 , 14:17   Re: Strange bug about menus in new amxx menu system
Reply With Quote #11

If you can help - lets do it, rewrite the plugin to prove your abilities.
This is simplest menu and menu as a menu, what more?
lqlqlq is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-21-2015 , 14:23   Re: Strange bug about menus in new amxx menu system
Reply With Quote #12

Here I fixed up half or all of your code. Now all the menus works 100%
PHP Code:
#include <amxmodx>
#include <amxmisc>
new reason[33][32]
new 
damage[33]
new 
target[33]
new 
type[33]

public 
plugin_init()
{
register_plugin("slap/slay/kick reason""val""1.0");
register_clcmd("amx_kickmenu""cmdKickMenu")
register_clcmd("amx_slapmenu""cmdSlapMenu")
}

/////////////STOCKS
stock KickPlayer(idszBuffer[], any:...)
{
static 
szReason[60]
vformat(szReasoncharsmax(szReason), szBuffer3)
message_begin(MSG_ONESVC_DISCONNECT,_id)
write_string(szReason)
message_end()
}


/////////////////////SLAP MENU////////////////////////////////
public cmdSlapMenu(id) {
    if(!(
get_user_flags(id) & ADMIN_SLAY)) {
    return 
PLUGIN_HANDLED
    
}
    
type[id] = 1;
    
    
//Create a variable to hold the menu
    
new menu menu_create"\rChoose a player!:""menu_handler4" );

    
//We will need to create some variables so we can loop through all the players
    
new players[32], pnum,itempid;

    
//Some variables to hold information about the players
   
new szName [32], sInfo[2]

    
//Fill players with available players
    
get_playersplayerspnum); 

    
//Start looping through all players
    
for ( i=0;i<pnum;i++ )
    {
        
//Save a tempid so we do not re-index
        
tempid players[i];
        
sInfo[0] = tempidsInfo[1] = 0;
        
//Get the players name and userid as strings
        
get_user_nametempidszNamecharsmaxszName ) );

        
//Add the item for this player
        
menu_additemmenu,szNamesInfo);
    }

    
//We now have all players in the menu, lets display the menu
    
menu_displayidmenu);

    return 
PLUGIN_HANDLED
}

public 
menu_handler4idmenuitem )
{
    if ( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
szData4[2], szName[64];
    new 
item,accessitem_callback;
    
menu_item_getinfomenuitem,accessszData4,charsmax(szData4), szName,charsmaxszName ), item_callback );

       
target[id] = str_to_num(szData4)

    
client_print(0,print_chat,"%s player id = #%d",szNameplayer)
    
    
menu_destroymenu );
    
ChooseDamage(id)
    
    return 
PLUGIN_HANDLED;
}

/////////////////////KICK MENU////////////////////////////////
public cmdKickMenu(id) {
    if(!(
get_user_flags(id) & ADMIN_KICK)) {
    return 
PLUGIN_HANDLED
    
}

    
type[id] = 2;
    
//Create a variable to hold the menu
    
new menu menu_create"\rChoose a player!:""menu_handler3" );

    
//We will need to create some variables so we can loop through all the players
    
new players[32], pnumtempidi;

    
//Some variables to hold information about the players
    
new szName[32],szUserId[2];

    
//Fill players with available players
    
get_playersplayerspnum);

    for (
0i<pnum;i++)
    {
        
//Save a tempid so we do not re-index
        
tempid players[i];

        
//Get the players name and userid as strings
        
get_user_nametempidszNamecharsmaxszName ) );
        
szUserId [0] = tempidszUserId [1] = 0;
        
        
//Add the item for this player
        
menu_additemmenuszName,szUserId);
    }

    
//We now have all players in the menu, lets display the menu
    
menu_displayidmenu);

    return 
PLUGIN_HANDLED
}

public 
menu_handler3idmenuitem )
{
    if ( 
item == MENU_EXIT )
    {
        return 
PLUGIN_HANDLED;
    }
    new 
szData3[2], szName[64];
    new 
item,accessitem_callback;
    
menu_item_getinfomenuitem,accessszData3,charsmax(szData3), szName,charsmaxszName ), item_callback );

    
target[id] = str_to_num(szData3)
    
menu_destroymenu );
    
AwesomeMenuid )
    
    return 
PLUGIN_HANDLED;
}


public 
ChooseDamage(id) {
new 
menu menu_create"\rChoose Damage!:""menu_handler5" );
menu_additemmenu"\w1 DMG""");
menu_additemmenu"\w5 DMG""");
menu_additemmenu"\w10 DMG""");
menu_additemmenu"\w50 DMG""");
menu_additemmenu"\wSLAY""");
menu_setpropmenuMPROP_EXITMEXIT_ALL );
menu_displayidmenu);
}

public 
menu_handler5idmenuitem )
{
if ( 
item == MENU_EXIT )
{
menu_destroymenu );
return 
PLUGIN_HANDLED;
}
    
switch( 
item )
{
                case 
0:
                {
                  
damage[id] = 1;
                }
                case 
1:
                {
                  
damage[id] = 5
                
}
                case 
2:
                {
                  
damage[id] = 10
                
}
                case 
3:
                {
                  
damage[id] = 50
                
}
                case 
4:
                {
                  
damage[id] = 999
                

}    
menu_destroymenu );    
AwesomeMenuid )
return 
PLUGIN_HANDLED;
}

public 
AwesomeMenuid ) {
new 
menu menu_create"\rChoose Reason!:""menu_handler" );
menu_additemmenu"\wRetry""");
menu_additemmenu"\wAir""");
menu_additemmenu"\wNekanen""");
menu_additemmenu"\wBez baza""");
menu_additemmenu"\wDruga prichina""");
menu_setpropmenuMPROP_EXITMEXIT_ALL );
menu_displayidmenu);
}

public 
menu_handleridmenuitem )
{
if ( 
item == MENU_EXIT )
{
menu_destroymenu );
return 
PLUGIN_HANDLED;
}

    
switch( 
item )
{
                case 
0:
                {
                   
format(reason[id],charsmax(reason[]),"Retry")
                }
                case 
1:
                {
                    
format(reason[id],charsmax(reason[]),"Air")
                }
                case 
2:
                {
                     
format(reason[id],charsmax(reason[]),"Nekanen")
                }
                case 
3:
                {
                     
format(reason[id],charsmax(reason[]),"Bez baza")
                }
                case 
4:
                {
                     
format(reason[id],charsmax(reason[]),"Druga prichina")
                }
}

menu_destroymenu );
Punish(id)
return 
PLUGIN_HANDLED;
}

public 
Punish(id) {

//slap
if(type[id] == 1) {

if (
is_user_alivetarget[id] ) )
{
        
user_slap(target[id],damage)
        new 
name[32]
        
get_user_name(id,name,31)
        new 
name2[32]
        
get_user_name(target[id],name2,31)
        
client_print(0,print_chat,"Admin %s has slapped %s with %d damage, Reason: %s",name,name2,damage,reason)
}


//kick
else if(type[id] == 2){

if (
is_user_connectedtarget[id] ) )
{
        
KickPlayer(target[id],reason)
        new 
name[32]
        
get_user_name(id,name,31)
        new 
name2[32]
        
get_user_name(target[id],name2,31)
        
client_print(0,print_chat,"Admin %s has kicked %s, Reason: %s",name,name2,reason[id])
}
    
}

//clear
target[id] = 0
type
[id] = 0
damage
[id] = 0
//end clear
return PLUGIN_HANDLED;


Last edited by Natsheh; 01-21-2015 at 14:28.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lqlqlq
Senior Member
Join Date: Jan 2008
Old 01-21-2015 , 15:29   Re: Strange bug about menus in new amxx menu system
Reply With Quote #13

Not working again...
This is bug with new amxx, definitely.

Arkshine, what a mess you gotten ?

Last edited by lqlqlq; 01-21-2015 at 15:34.
lqlqlq is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-21-2015 , 15:44   Re: Strange bug about menus in new amxx menu system
Reply With Quote #14

Bro use amx version 1.8.2, version 1.8.3 still underdevelopment.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lqlqlq
Senior Member
Join Date: Jan 2008
Old 01-21-2015 , 16:01   Re: Strange bug about menus in new amxx menu system
Reply With Quote #15

I'm happy with amxx 1.83 and this is the first bug I see.
Please, someone in dev team - fix this bug!
lqlqlq is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-21-2015 , 16:04   Re: Strange bug about menus in new amxx menu system
Reply With Quote #16

Start to provide a well indented code. Ideally reducing current code to a simple test plugin and explaining step by step how to reproduce issue.
__________________
Arkshine is offline
lqlqlq
Senior Member
Join Date: Jan 2008
Old 01-21-2015 , 16:40   Re: Strange bug about menus in new amxx menu system
Reply With Quote #17

Maybe you catch me - im not verry good in explanations because im from Bulgaria and my english is not well.

Here is minify version of menu:
PHP Code:
#include <amxmodx>

public plugin_init()
{
register_clcmd("amx_slapmenu""cmdSlapMenu")
}

public 
cmdSlapMenu(id) {
    new 
menu menu_create"Choose:""menu_handler4" );
    new 
players[32], pnum,itempid;

    new 
szName[32]
    
get_playersplayerspnum);
    
    for ( 
i=0;i<pnum;i++ )
    {
    
tempid players[i];
    
get_user_nametempidszNamecharsmaxszName ) );
    
menu_additemmenu,szName);
    }
    
    
menu_displayidmenu);
    return 
PLUGIN_HANDLED
}

public 
menu_handler4idmenuitem )
{
    if ( 
item == MENU_EXIT )
    {
    return 
PLUGIN_HANDLED;
    }
    
    new 
szData4[2], szName[64];
    new 
item,accessitem_callback;
    
menu_item_getinfomenuitem,accessszData4,charsmax(szData4), szName,charsmaxszName ), item_callback );

    
client_print(0,print_chat,"%s ",szName)
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;

When i open the menu for the first time and i choose player - szName (from menu_item_getinfo) gives information about first player in the menu.
I want to bring back name of choosen player, not first in the menu.

Every players in the menu have specific names (their names) and working OK, but any choose of them - bring back information about first player.

I've added client_print for debugging information and if you test - you see the bug.
I put plugin on top in plugins.ini because i try to overwrite plmenu and i use return PLUGIN_HANDLED; for this.

I test with last podbots and real players and still the same. (bug exists)

PS:
I try to pass and their ids - not working.

Last edited by lqlqlq; 01-21-2015 at 18:11.
lqlqlq is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-22-2015 , 06:15   Re: Strange bug about menus in new amxx menu system
Reply With Quote #18

Quote:
I think its a bug in this versions of amxx.
Quote:
This is bug with new amxx, definitely
Quote:
I'm not newbie.
Code:
public menu_handler4( id, menu, item)
{
    new item,access, item_callback;
    menu_item_getinfo( item, item,access, szData4,charsmax(szData4), szName,charsmax( szName ), item_callback );
}
Of course if you recreate the variable "item", value will be always 0. And if you pass 0 in "menu_item_getinfo", you will get always first item.
I suggest you run away somewhere and stay hidden for some years.
__________________

Last edited by Arkshine; 01-22-2015 at 06:17.
Arkshine is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-22-2015 , 07:22   Re: Strange bug about menus in new amxx menu system
Reply With Quote #19

Quote:
Originally Posted by Arkshine View Post
Code:
public menu_handler4( id, menu, item)
{
    new item,access, item_callback;
    menu_item_getinfo( item, item,access, szData4,charsmax(szData4), szName,charsmax( szName ), item_callback );
}
Of course if you recreate the variable "item", value will be always 0. And if you pass 0 in "menu_item_getinfo", you will get always first item.
I suggest you run away somewhere and stay hidden for some years.
Oww... i didn't notice that.., Good observation!

Last edited by Natsheh; 01-22-2015 at 07:22.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lqlqlq
Senior Member
Join Date: Jan 2008
Old 01-22-2015 , 09:49   Re: Strange bug about menus in new amxx menu system
Reply With Quote #20

Quote:
Originally Posted by Arkshine
I suggest you run away somewhere and stay hidden for some years.
to learn the menu functions

I confused from here https://forums.alliedmods.net/showthread.php?t=46364
Code:
new szData[6], szName[64];
    new item_access, item_callback;
    //heres the function that will give us that information ( since it doesnt magicaly appear )
    menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
(its not compiled) and i change to:
Code:
new szData[6], szName[64];
    new item,access, item_callback;
    //heres the function that will give us that information ( since it doesnt magicaly appear )
    menu_item_getinfo( menu, item, access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
Someone can edit the Player Menu (second code)
And this is fault of amxx team

Last edited by lqlqlq; 01-22-2015 at 10:03.
lqlqlq 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 17:24.


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