Raised This Month: $ Target: $400
 0% 

How can I remove my name of the menu?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 12-30-2009 , 23:26   How can I remove my name of the menu?
Reply With Quote #1

i have this code


when someone write "say /players" appears a menu with all names of the players connected, so I want remove the name of the player who write "players"

PHP Code:
#include <amxmodx>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /players""PlayerMenu")
}

public 
PlayerMenu(id)
{
    new 
wMenu menu_create("\yPlayers Menu""Handler")
    new 
Pos[3], Name[32]
    
    for (new 
1<= get_maxplayers(); i++)
    {
        if (!
is_user_connected(i))
            continue;
            
        
num_to_str(iPossizeof(Pos)-1)
        
get_user_name(iNamesizeof(Name)-1)
        
        
menu_additem(wMenuNamePos)
    }
    
menu_setprop(wMenuMPROP_EXITMEXIT_ALL)
    
menu_display(idwMenu0)
}

public 
Handler(idwMenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(wMenu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
Data[6], Name[64]
    new 
AccessCallback
    menu_item_getinfo
(wMenuitemAccessDatasizeof(Data)-1Namesizeof(Name)-1Callback)
    
    
set_hudmessage(255255255, -1.0, -1.006.012.0)
    
show_hudmessage(id"%s is the Pink Pony!"Name)
    
    
menu_destroy(wMenu)
    return 
PLUGIN_HANDLED

I hope you can help me
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-30-2009 , 23:30   Re: How can I remove my name of the menu?
Reply With Quote #2

Modified line is highlighted.

Code:
#include <amxmodx> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say /players", "PlayerMenu") } public PlayerMenu(id) {     new wMenu = menu_create("\yPlayers Menu", "Handler")     new Pos[3], Name[32]         for (new i = 1; i <= get_maxplayers(); i++)     {         if (!is_user_connected(i) || i == id)             continue;                     num_to_str(i, Pos, sizeof(Pos)-1)         get_user_name(i, Name, sizeof(Name)-1)                 menu_additem(wMenu, Name, Pos)     }     menu_setprop(wMenu, MPROP_EXIT, MEXIT_ALL)     menu_display(id, wMenu, 0) } public Handler(id, wMenu, item) {     if (item == MENU_EXIT)     {         menu_destroy(wMenu)         return PLUGIN_HANDLED     }         new Data[6], Name[64]     new Access, Callback     menu_item_getinfo(wMenu, item, Access, Data, sizeof(Data)-1, Name, sizeof(Name)-1, Callback)         set_hudmessage(255, 255, 255, -1.0, -1.0, 0, 6.0, 12.0)     show_hudmessage(id, "%s is the Pink Pony!", Name)         menu_destroy(wMenu)     return PLUGIN_HANDLED }

An optimization that you should do is to store get_maxplayers() in a global variable and initialize it in plugin_ini(). This way it's not calling the native every single time the loop executes.

I don't think you get the name of the player in menu_item_getinfo(). You will have to do
PHP Code:
get_user_name(str_to_num(Data), Namecharsmax(Name)) 
I dont' know what the "name" is for in menu_item_getinfo(). If you look at the tutorial on the newer menu system you will see that he does not use the string "Name" from menu_item_getinfo().
__________________

Last edited by fysiks; 12-30-2009 at 23:43.
fysiks is offline
IneedHelp
Veteran Member
Join Date: Mar 2007
Location: Argentina
Old 12-30-2009 , 23:51   Re: How can I remove my name of the menu?
Reply With Quote #3

Name is the name of the item, so he will get \wPlayerName.
__________________
IneedHelp is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-30-2009 , 23:54   Re: How can I remove my name of the menu?
Reply With Quote #4

Quote:
Originally Posted by IneedHelp View Post
Name is the name of the item, so he will get \wPlayerName.
Oh. Will it have the "\w" if it's not supplied (literally) in the code?
__________________
fysiks is offline
IneedHelp
Veteran Member
Join Date: Mar 2007
Location: Argentina
Old 12-30-2009 , 23:57   Re: How can I remove my name of the menu?
Reply With Quote #5

I don't think so but is the default color, maybe he gets only the player name

going to test ._.

edit: Nope, it doesn't print the color \w, but if you format the name+color (e.g \y[name]) it will print the color too (\y)
__________________

Last edited by IneedHelp; 12-31-2009 at 00:02.
IneedHelp is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 12-31-2009 , 00:30   Re: How can I remove my name of the menu?
Reply With Quote #6

thanks fysiks, works fine
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
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 04:07.


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