Raised This Month: $ Target: $400
 0% 

How to get username from one to another public method


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 05-12-2010 , 12:17   How to get username from one to another public method
Reply With Quote #1

-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 ?
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-12-2010 , 14:38   Re: How to get username from one to another public method
Reply With Quote #2

Put it as the "data" (the third parameter).
__________________

Last edited by fysiks; 05-12-2010 at 14:42.
fysiks is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-12-2010 , 15:09   Re: How to get username from one to another public method
Reply With Quote #3

example, please ?
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-12-2010 , 18:59   Re: How to get username from one to another public method
Reply With Quote #4

Quote:
Originally Posted by reinert View Post
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.
__________________
fysiks is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 05-13-2010 , 09:21   Re: How to get username from one to another public method
Reply With Quote #5

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
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-13-2010 , 16:20   Re: How to get username from one to another public method
Reply With Quote #6

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.
__________________
fysiks 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 03:33.


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