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

How can i get steamid of this menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Number1
Junior Member
Join Date: Jul 2018
Old 07-25-2018 , 07:38   How can i get steamid of this menu?
Reply With Quote #1

HTML Code:
#include <amxmodx>

public plugin_init()
{
register_clcmd("say !ban", "AwesomeMenu");
}

public AwesomeMenu( id )
{
new menu = menu_create( "Ban players", "SubMenu" )
new rgPlayers[32], szPlayerName[32], szPlayerId[3], iPlayersCount, pevPlayer;
get_players(rgPlayers, iPlayersCount, "ch");
for (new i = 0; i < iPlayersCount; i++)
{
pevPlayer = rgPlayers[i];
get_user_name(pevPlayer, szPlayerName, charsmax(szPlayerName));
num_to_str(pevPlayer, szPlayerId, charsmax(szPlayerId));
menu_additem(menu, szPlayerName, szPlayerId);
}
menu_display( id, menu, 0 );
}

public SubMenu( id )
{
//Note that we will be using a different menu handler
new menu = menu_create( "Player BANMENU", "submenu_handler" )
menu_addtext2( menu, "Selected Player: PLAYER NAME GOES HERE");
menu_addtext2( menu, "Selected Player STEAMID: PLAYER STEAMID GOES HERE");
menu_additem( menu, "Banned for cheating", "", 0 );
menu_additem( menu, "Banned for camping", "", 0 );
menu_display( id, menu, 0 );
}

public submenu_handler( id, menu, item )
{
switch( item )
{
case 2:
{
client_cmd( id, "say Selected reason: Banned for cheating. Player steamid: PLAYER STEAMID GOES HERE" );
}
case 3:
{
client_cmd( id, "say Selected reason: Banned for camping. Player steamid: PLAYER STEAMID GOES HERE" );
}
case MENU_EXIT:
{
//If they are still connected
if ( is_user_connected( id ) )
//Lets send them back to the top menu
AwesomeMenu( id );
}
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}  
I'm trying to make ban reasons menu. How can i get selected player NAME and STEAMID to another menu?

Like in my code:

PHP Code:
menu_addtext2menu"Selected Player: PLAYER NAME GOES HERE");
menu_addtext2menu"Selected Player STEAMID: PLAYER STEAMID GOES HERE"); 
And:
HTML Code:
client_cmd( id, "say Selected reason: Banned for cheating. Player steamid: PLAYER STEAMID GOES HERE" );
I really need this help guys! Thanks everyone who will answer and helping me uderstand how to make menu!

Last edited by Number1; 07-25-2018 at 08:03.
Number1 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-25-2018 , 07:43   Re: How can i get steamid of this menu?
Reply With Quote #2

The least you could do was indent the code and remove blank lines, which you can do with NotePad++ in 5 seconds.

Here's a better looking code:
PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("say !ban""AwesomeMenu");
}

public 
AwesomeMenuid )
{
    new 
menu menu_create"Ban players""menu_handler" )
    new 
rgPlayers[32], szPlayerName[32], szPlayerId[3], iPlayersCountpevPlayer;
    
get_players(rgPlayersiPlayersCount"ch");
    for (new 
0iPlayersCounti++)
    {
        
pevPlayer rgPlayers[i];
        
get_user_name(pevPlayerszPlayerNamecharsmax(szPlayerName));
        
num_to_str(pevPlayerszPlayerIdcharsmax(szPlayerId));
        
menu_additem(menuszPlayerNameszPlayerId);
    }
    
menu_displayidmenu);
}

public 
menu_handleridmenuitem )
{
    switch( 
item )
    {
    case 
0:
        {
            
SubMenuid );
        }
    case 
1:
        {
            
//Send them to the submenu
            
SubMenuid );
        }
    case 
MENU_EXIT:
        {
            
//Do nothing?
        
}
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

SubMenuid )
{
    
//Note that we will be using a different menu handler
    
new menu menu_create"Player BANMENU""submenu_handler" )
    
menu_addtext2menu"Selected Player: PLAYER NAME GOES HERE");
    
menu_addtext2menu"Selected Player STEAMID: PLAYER STEAMID GOES HERE");
    
menu_additemmenu"Banned for cheating""");
    
menu_additemmenu"Banned for camping""");
    
menu_displayidmenu);
}

public 
submenu_handleridmenuitem )
{
    switch( 
item )
    {
    case 
2:
        {
            
client_cmdid"say Selected reason: Banned for cheating. Player steamid: PLAYER STEAMID GOES HERE" );
        }
    case 
3:
        {
            
client_cmdid"say Selected reason: Banned for camping. Player steamid: PLAYER STEAMID GOES HERE" );
        }
    case 
MENU_EXIT:
        {
            
//If they are still connected
            
if ( is_user_connectedid ) )
            
//Lets send them back to the top menu
            
AwesomeMenuid );
        }
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;

So you want the player name and SteamID to go into another (new) menu, or just into another menu item? These are 2 different things.
__________________
edon1337 is offline
Number1
Junior Member
Join Date: Jul 2018
Old 07-25-2018 , 07:46   Re: How can i get steamid of this menu?
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
The least you could do was indent the code and remove blank lines, which you can do with NotePad++ in 5 seconds.

Here's a better looking code:
PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("say !ban""AwesomeMenu");
}

public 
AwesomeMenuid )
{
    new 
menu menu_create"Ban players""menu_handler" )
    new 
rgPlayers[32], szPlayerName[32], szPlayerId[3], iPlayersCountpevPlayer;
    
get_players(rgPlayersiPlayersCount"ch");
    for (new 
0iPlayersCounti++)
    {
        
pevPlayer rgPlayers[i];
        
get_user_name(pevPlayerszPlayerNamecharsmax(szPlayerName));
        
num_to_str(pevPlayerszPlayerIdcharsmax(szPlayerId));
        
menu_additem(menuszPlayerNameszPlayerId);
    }
    
menu_displayidmenu);
}

public 
menu_handleridmenuitem )
{
    switch( 
item )
    {
    case 
0:
        {
            
SubMenuid );
        }
    case 
1:
        {
            
//Send them to the submenu
            
SubMenuid );
        }
    case 
MENU_EXIT:
        {
            
//Do nothing?
        
}
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;
}

SubMenuid )
{
    
//Note that we will be using a different menu handler
    
new menu menu_create"Player BANMENU""submenu_handler" )
    
menu_addtext2menu"Selected Player: PLAYER NAME GOES HERE");
    
menu_addtext2menu"Selected Player STEAMID: PLAYER STEAMID GOES HERE");
    
menu_additemmenu"Banned for cheating""");
    
menu_additemmenu"Banned for camping""");
    
menu_displayidmenu);
}

public 
submenu_handleridmenuitem )
{
    switch( 
item )
    {
    case 
2:
        {
            
client_cmdid"say Selected reason: Banned for cheating. Player steamid: PLAYER STEAMID GOES HERE" );
        }
    case 
3:
        {
            
client_cmdid"say Selected reason: Banned for camping. Player steamid: PLAYER STEAMID GOES HERE" );
        }
    case 
MENU_EXIT:
        {
            
//If they are still connected
            
if ( is_user_connectedid ) )
            
//Lets send them back to the top menu
            
AwesomeMenuid );
        }
    }
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;

So you want the player name and SteamID to go into another (new) menu, or just into another menu item? These are 2 different things.
Thanks for really fast answer! I need like example:

Ban current player in server:

1) Player1
2) Player2
3) Player3

and etc.

If admin choose on Player1 he get another menu:

1) Ban for 10min
2) Ban for 20min
3) Ban for 30min

and if admin choose option 2, player get banned by admin comand in console: client_cmd amx_ban 10 PlayerID PlayerUsername Reason: 10Minutes

Last edited by Number1; 07-25-2018 at 07:49.
Number1 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-25-2018 , 07:52   Re: How can i get steamid of this menu?
Reply With Quote #4

Quote:
Originally Posted by Number1 View Post
Thanks for really fast answer! I need like example:

Ban current player in server:

1) Player1
2) Player2
3) Player3

and etc.

If admin choose on Player1 he get another menu:

1) Ban for 10min
2) Ban for 20min
3) Ban for 30min

and if admin choose option 2, player get banned by admin comand in console: client_cmd amx_ban 10 PlayerID PlayerUsername Reason: 10Minutes
Well, this menu is nowhere close to what you're requesting. You have to re-do it from 0.
__________________
edon1337 is offline
Number1
Junior Member
Join Date: Jul 2018
Old 07-25-2018 , 08:02   Re: How can i get steamid of this menu?
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
Well, this menu is nowhere close to what you're requesting. You have to re-do it from 0.
Maybe u dont understand me. I need just get STEAMID of selected player into next menu

UPDATED:

HTML Code:
#include <amxmodx>

public plugin_init()
{
register_clcmd("say !ban", "AwesomeMenu");
}

public AwesomeMenu( id )
{
new menu = menu_create( "Ban players", "SubMenu" )
new rgPlayers[32], szPlayerName[32], szPlayerId[3], iPlayersCount, pevPlayer;
get_players(rgPlayers, iPlayersCount, "ch");
for (new i = 0; i < iPlayersCount; i++)
{
pevPlayer = rgPlayers[i];
get_user_name(pevPlayer, szPlayerName, charsmax(szPlayerName));
num_to_str(pevPlayer, szPlayerId, charsmax(szPlayerId));
menu_additem(menu, szPlayerName, szPlayerId);
}
menu_display( id, menu, 0 );
}

public SubMenu( id )
{
//Note that we will be using a different menu handler
new menu = menu_create( "Player BANMENU", "submenu_handler" )
menu_addtext2( menu, "Selected Player: PLAYER NAME GOES HERE");
menu_addtext2( menu, "Selected Player STEAMID: PLAYER STEAMID GOES HERE");
menu_additem( menu, "Banned for cheating", "", 0 );
menu_additem( menu, "Banned for camping", "", 0 );
menu_display( id, menu, 0 );
}

public submenu_handler( id, menu, item )
{
switch( item )
{
case 2:
{
client_cmd( id, "say Selected reason: Banned for cheating. Player steamid: PLAYER STEAMID GOES HERE" );
}
case 3:
{
client_cmd( id, "say Selected reason: Banned for camping. Player steamid: PLAYER STEAMID GOES HERE" );
}
case MENU_EXIT:
{
//If they are still connected
if ( is_user_connected( id ) )
//Lets send them back to the top menu
AwesomeMenu( id );
}
}
menu_destroy( menu );
return PLUGIN_HANDLED;
}  

Last edited by Number1; 07-25-2018 at 08:05.
Number1 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-25-2018 , 08:07   Re: How can i get steamid of this menu?
Reply With Quote #6

Great, you killed the indentation again.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-25-2018 , 10:58   Re: How can i get steamid of this menu?
Reply With Quote #7

You can get the SteamID of a player with get_user_authid(), used the same way as get_user_name().
__________________
fysiks is offline
Number1
Junior Member
Join Date: Jul 2018
Old 07-25-2018 , 13:54   Re: How can i get steamid of this menu?
Reply With Quote #8

Ok so i tried from 0 and now works but not everytime. Then i first join in the server and then another player connect to server everyting works fine, but if i joined second and try to ban some player i get banned by myself. Any suggestion? Code:

HTML Code:
#include <amxmodx>
#include <amxmisc>
new reason[32]
new bantime[32]
new target[33];

public plugin_init()
{
register_plugin("Banmenu", "SomeBody", "1.0");
register_clcmd("amx_newbanmenu", "cmdBanMenu")
}

public cmdBanMenu(id) {
if(!(get_user_flags(id) & ADMIN_BAN)) {
return PLUGIN_HANDLED
}
//Create a variable to hold the menu
new menu = menu_create( "Choose player to BAN", "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 AwesomeMenu( id ) {
new menu = menu_create( "Choose player BAN REASON", "menu_handler" );
menu_additem( menu, "Cheating", "", 0 );
menu_additem( menu, "Camping", "", 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),"Cheating")
format(bantime,charsmax(bantime),"4320")
}
case 1:
{
format(reason,charsmax(reason),"Camping")
format(bantime,charsmax(bantime),"518400")
}
}

menu_destroy( menu );
Punish(id)
return PLUGIN_HANDLED;
}

public Punish(id) {
//kick

if (is_user_connected( target[id] ) )
{
new name[32]
get_user_name(id,name,31)
new name2[32]
get_user_name(target[id],name2,31)
client_cmd(id, "amx_ban ^"%s^" ^"%s^" ^"%s^"", name2,bantime,reason)
}
return PLUGIN_HANDLED;
}
Number1 is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 07-25-2018 , 14:56   Re: How can i get steamid of this menu?
Reply With Quote #9

Check if userid is corret
jonatat is offline
jonatat
Senior Member
Join Date: Dec 2017
Old 07-25-2018 , 17:20   Re: How can i get steamid of this menu?
Reply With Quote #10

I dont understand how it works for u? I checked and i think your last posted plugin is totally mess...
jonatat 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 06:25.


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