AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get username from one to another public method (https://forums.alliedmods.net/showthread.php?t=126695)

reinert 05-12-2010 12:17

How to get username from one to another public method
 
-title-, something like menu:

Players menu:
killer
noob
pro
lamer
baker
etc.

then u select someone, and then appear a new menu:

Do you really want to ban %s ?

Yes
No

If yes then, server_cmd("amx_banip %s" tempid)

How can i get tempid from one menu to another ?

fysiks 05-12-2010 14:38

Re: How to get username from one to another public method
 
Put it as the "data" (the third parameter).

reinert 05-12-2010 15:09

Re: How to get username from one to another public method
 
example, please ?

fysiks 05-12-2010 18:59

Re: How to get username from one to another public method
 
Quote:

Originally Posted by reinert (Post 1178506)
example, please ?

Try it yourself. If it doesn't work change something and try again.

Write the plugin first with both menus (and their handlers) and post here the whole code if you haven't figured it out.

reinert 05-13-2010 09:21

Re: How to get username from one to another public method
 
PHP Code:

#include <amxmodx>
 #include <fun>

 
public plugin_init()
 {
    
register_clcmd"inch_banmenu","BanMenu");
 }
 public 
BanMenu(id)
 {
    new 
menu menu_create("\rSelect a player to ban!:""ban_handler");

    new 
players[32], pnumtempid;

    new 
szName[32], szTempid[10];

    
get_players(playerspnum);

    for( new 
ii<pnumi++ )
    {
        
tempid players[i];

        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);

        
menu_additem(menuszNameszTempid0);

    }

    
menu_display(idmenu0);
 }
public 
ban_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    
BanMenu1(id);

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 }
 
  public 
BanMenu1(id)
 {
    new 
menu menu_create("\rDo you really want to ban this player?:""ban_handler1");
    
    
menu_additem(menu"\wYes, ban player""0"0);
    
menu_additem(menu"\wNo, return to menu""1"0);

    
menu_display(idmenu0);
 }

public 
ban_handler1(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);


    new 
key str_to_num(data);
    switch(
key)
    {
        case 
0:
        {
        new 
tempid str_to_num(data);
            
server_cmd("amx_banip %s 720 Banned for 12 hours"tempid)
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
        case 
1:
        {
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED;
        }
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 } 


Not working

fysiks 05-13-2010 16:20

Re: How to get username from one to another public method
 
PHP Code:

#include <amxmodx>
#include <fun>

public plugin_init()
{
    
register_clcmd"inch_banmenu","BanMenu");
}

public 
BanMenu(id)
{
    new 
menu menu_create("\rSelect a player to ban!:""ban_handler");

    new 
players[32], pnumtempid;
    new 
szName[32], szTempid[10];

    
get_players(playerspnum);

    for( new 
ii<pnumi++ )
    {
        
tempid players[i];

        
get_user_name(tempidszName31);
        
num_to_str(tempidszTempid9);

        
menu_additem(menuszNameszTempid0);

    }

    
menu_display(idmenu0);
}
public 
ban_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    
BanMenu1(iddata);

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

public 
BanMenu1(idszTargetID[])
{
    new 
menu menu_create("\rDo you really want to ban this player?:""ban_handler1");
    
    
menu_additem(menu"\wYes, ban player"szTargetID0);
    
menu_additem(menu"\wNo, return to menu""0"0);

    
menu_display(idmenu0);
}

public 
ban_handler1(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);


    new 
iTargetID str_to_num(data);
    if(
iTargetID)
    {
        
// Ban iTargetID
    
}

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Also, ban by SteamID, it's much more reliable.


All times are GMT -4. The time now is 03:33.

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