Senior Member
|
01-20-2015
, 15:25
Strange bug about menus in new amxx menu system
|
#1
|
Hello.
I use last hlds with last amxx and metamod 1.21.
I try to overwrite plmenu with some small plugin and i do this.
Now i have strange bug, when i choose player and reopen menu again, last choosen player is 'saved' and all options in menu is overwritten with this information (about last player)
id, item name and etc...
Took me 2 days with work and i dont find the problem. I try everything and nothing working.
I try to get id by name with find_player, i try with cmd_target, and directly to pass id by menu_Additem and get back with num_to_str from menu_item_getinfo.
Noting work. This is hell!
I give the code here and i want some with strong knowledge edit this mess for working fine.
Code:
#include <amxmodx>
#include <amxmisc>
new reason[32]
new damage
new target[33];
new type = 0;
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(id, szBuffer[], any:...)
{
static szReason[60]
vformat(szReason, charsmax(szReason), szBuffer, 3)
message_begin(MSG_ONE, SVC_DISCONNECT,_, id)
write_string(szReason)
message_end()
}
/////////////////////SLAP MENU////////////////////////////////
public cmdSlapMenu(id) {
if(!(get_user_flags(id) & ADMIN_SLAY)) {
return PLUGIN_HANDLED
}
type = 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,i, tempid;
//Some variables to hold information about the players
new szName[32],szUserId[32]
//Fill players with available players
get_players( players, pnum);
//Start looping through all players
for ( i=0;i<pnum;i++ )
{
//Save a tempid so we do not re-index
tempid = players[i];
//Get the players name and userid as strings
get_user_name( tempid, szName, charsmax( szName ) );
//Add the item for this player
menu_additem( menu,szName );
}
//We now have all players in the menu, lets display the menu
menu_display( id, menu);
return PLUGIN_HANDLED
}
public menu_handler4( id, menu, item )
{
if ( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new szData4[6], szName[64];
new item,access, item_callback;
menu_item_getinfo( menu, item,access, szData4,charsmax(szData4), szName,charsmax( szName ), item_callback );
client_print(0,print_chat,"%s",szName)
menu_destroy( menu );
ChooseDamage(id)
return PLUGIN_HANDLED;
}
/////////////////////KICK MENU////////////////////////////////
public cmdKickMenu(id) {
if(!(get_user_flags(id) & ADMIN_KICK)) {
return PLUGIN_HANDLED
}
type = 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], pnum, tempid;
//Some variables to hold information about the players
new szName[32],szUserId[32];
//Fill players with available players
get_players( players, pnum);
//Start looping through all players
for ( --pnum; pnum>=0; pnum-- )
{
//Save a tempid so we do not re-index
tempid = players[pnum];
//Get the players name and userid as strings
get_user_name( tempid, szName, charsmax( szName ) );
formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid))
//Add the item for this player
menu_additem( menu, szName,szUserId, 0 );
}
//We now have all players in the menu, lets display the menu
menu_display( id, menu);
return PLUGIN_HANDLED
}
public menu_handler3( id, menu, item )
{
if ( item == MENU_EXIT )
{
return PLUGIN_HANDLED;
}
new szData3[6], szName[64];
new item,access, item_callback;
menu_item_getinfo( menu, item,access, szData3,charsmax(szData3), szName,charsmax( szName ), item_callback );
target[id] = find_player("k", str_to_num(szData3))
menu_destroy( menu );
AwesomeMenu( id )
return PLUGIN_HANDLED;
}
public ChooseDamage(id) {
new menu = menu_create( "\rChoose Damage!:", "menu_handler5" );
menu_additem( menu, "\w1 DMG", "", 0 );
menu_additem( menu, "\w5 DMG", "", 0 );
menu_additem( menu, "\w10 DMG", "", 0 );
menu_additem( menu, "\w50 DMG", "", 0 );
menu_additem( menu, "\wSLAY", "", 0 );
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, menu, 0 );
}
public menu_handler5( id, menu, item )
{
if ( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new item_access, item_callback;
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
switch( item )
{
case 0:
{
damage = 1;
}
case 1:
{
damage = 5
}
case 2:
{
damage = 10
}
case 3:
{
damage = 50
}
case 4:
{
damage = 999
}
}
menu_destroy( menu );
AwesomeMenu( id )
return PLUGIN_HANDLED;
}
public AwesomeMenu( id ) {
new menu = menu_create( "\rChoose Reason!:", "menu_handler" );
menu_additem( menu, "\wRetry", "", 0 );
menu_additem( menu, "\wAir", "", 0 );
menu_additem( menu, "\wNekanen", "", 0 );
menu_additem( menu, "\wBez baza", "", 0 );
menu_additem( menu, "\wDruga prichina", "", 0 );
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );
menu_display( id, menu, 0 );
}
public menu_handler( id, menu, item )
{
if ( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new szData[6], szName[64];
new item_access, item_callback;
menu_item_getinfo( menu, item, item_access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
switch( item )
{
case 0:
{
format(reason,charsmax(reason),"Retry")
}
case 1:
{
format(reason,charsmax(reason),"Air")
}
case 2:
{
format(reason,charsmax(reason),"Nekanen")
}
case 3:
{
format(reason,charsmax(reason),"Bez baza")
}
case 4:
{
format(reason,charsmax(reason),"Druga prichina")
}
}
menu_destroy( menu );
Punish(id)
return PLUGIN_HANDLED;
}
public Punish(id) {
//slap
if(type == 1) {
if (is_user_alive( target[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 == 2){
if (is_user_connected( target[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)
}
}
//clear
target[id] = 0
type = 0
damage = 0
//end clear
return PLUGIN_HANDLED;
}
|
|