AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I remove my name of the menu? (https://forums.alliedmods.net/showthread.php?t=113881)

gladius 12-30-2009 23:26

How can I remove my name of the menu?
 
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 :)

fysiks 12-30-2009 23:30

Re: How can I remove my name of the menu?
 
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().

IneedHelp 12-30-2009 23:51

Re: How can I remove my name of the menu?
 
Name is the name of the item, so he will get \wPlayerName.

fysiks 12-30-2009 23:54

Re: How can I remove my name of the menu?
 
Quote:

Originally Posted by IneedHelp (Post 1037293)
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?

IneedHelp 12-30-2009 23:57

Re: How can I remove my name of the menu?
 
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)

gladius 12-31-2009 00:30

Re: How can I remove my name of the menu?
 
thanks fysiks, works fine


All times are GMT -4. The time now is 04:07.

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