Raised This Month: $ Target: $400
 0% 

[Help] Displaying Custom Menu not working...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BlackComb
Junior Member
Join Date: Nov 2010
Old 01-01-2017 , 00:11   [Help] Displaying Custom Menu not working...
Reply With Quote #1

This Menu was working in older version of SM; I don't know what changes.. Can someone help me Thanks


PHP Code:
public Action:CMDPLAYERSTATUS(client,args)
{
    
decl String:line[100];
    
    new 
Handle:menu CreateMenu(MenuHandler_SHOWPLAYERSTATUS);
    
Format(linesizeof(line), "Select Player to view status on:"); //DonateAPTOPlayer[client]);
    
SetMenuTitle(menuline);
    
SetMenuExitBackButton(menutrue);
    
    
AddTargetsToMenu2(menuclientCOMMAND_FILTER_NO_BOTS|COMMAND_FILTER_NO_IMMUNITY);

    
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
}

public 
MenuHandler_SHOWPLAYERSTATUS(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_End)
    {
        
CloseHandle(menu);
    }
    if (
action == MenuAction_Select)
    {
        
//decl String:info[MAX_LINE_WIDTH];
        
decl String:info[MAX_LINE_WIDTH], String:name[MAX_LINE_WIDTH];
        new 
useridtarget;

        
GetMenuItem(menuparam2infosizeof(info), _namesizeof(name));
        
userid StringToInt(info);
        
        
        
target GetClientOfUserId(userid);
        
//new String:name[32];
        
new String:myself[MAX_LINE_WIDTH];
        
GetClientName(targetnamesizeof(name));
        
GetClientName(param1myselfsizeof(myself));
        
GetClientName(param1myselfsizeof(myself));


        
PrintToChat(param1"[SM] %t""Player no longer available");


        new 
Handle:Displaymenu CreatePanel();
        new 
String:pct[MAX_LINE_WIDTH];
        
Format(pctsizeof(pct), "%");
        new 
String:text[MAX_LINE_WIDTH];
        
        
decl String:UserName[MAX_LINE_WIDTH];
        
GetClientName(targetUserNamesizeof(UserName));
        
        
Format(textsizeof(text), "%s Status"UserName);
        
SetPanelTitle(Displaymenutext);

        
Format(textsizeof(text), "_____________________");
        
DrawPanelText(Displaymenutext);
        
        
Format(textsizeof(text), "Level: %d |  Cash: %d"PlayerLevel[target], PlayerCash[target]);
        
DrawPanelText(Displaymenutext);
        

        
SendPanelToClient(Displaymenuparam1DoNothing_InitMENU_TIME_FOREVER);
        
CloseHandle(Displaymenu);
        
PrintToChatAll("%s is viewing %s status"myselfname);
        
//}
    
}

BlackComb is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 01-01-2017 , 04:30   Re: [Help] Displaying Custom Menu not working...
Reply With Quote #2

try instead of
PHP Code:
if (action == MenuAction_Select
this
PHP Code:
else if (action == MenuAction_Select
PHP Code:
        GetClientName(param1myselfsizeof(myself));
        
GetClientName(param1myselfsizeof(myself)); 
I don't understand why this need 2 times
__________________
Grey83 is offline
BlackComb
Junior Member
Join Date: Nov 2010
Old 01-01-2017 , 12:57   Re: [Help] Displaying Custom Menu not working...
Reply With Quote #3

Yea, I just saw the double.. I delete one... Any other suggestion why it not working?
BlackComb is offline
General Lentils
Senior Member
Join Date: Jul 2016
Old 01-01-2017 , 13:40   Re: [Help] Displaying Custom Menu not working...
Reply With Quote #4

Maybe use the New Syntax at first...

new => int

new String:stringname[size] => char stringname[size]


public Action:ActionToDo(client, args) => public Action ActionToDo(int client, int args)

public OnPluginStart() => public void OnPluginStart()

public Handler(Handle:menu, MenuAction:action, param1, param2) => public int Handler(Handle menu, MenuAction action, int param1, int param2)
etc...

If you search "Sourcemod Menu API", you will find more about Menus.....

And so on... If you search on google, You will find more of what you are looking for..
Also, there is no need to use that many spaces..

Now onto the code itself, i suggest you don't really know what you are doing (correct me if i'm wrong)
and that this is a copy-paste from another person's code... So i suggest either using that person's plugin, or keep trying it yourself.. Since you will have to learn on your own... This won't come by just copying- and pasting over codes...

A few useful links that also contain what i said:

https://wiki.alliedmods.net/Menu_API_(SourceMod)

https://forums.alliedmods.net/showthread.php?t=244092


Conclusion: i think you need to rewrite this code... (Correct me if i'm wrong..)
General Lentils is offline
BlackComb
Junior Member
Join Date: Nov 2010
Old 01-01-2017 , 14:40   Re: [Help] Displaying Custom Menu not working...
Reply With Quote #5

I develop this myself.. But since SM change.. I'm trying to learn the new API...

This was working fine on SM 1.4

Now I'm using this code from this site:
https://wiki.alliedmods.net/Menus_St...Action_Display


PHP Code:
public Action CMDPLAYERSTATUS(int clientint args)
{
    
    
    
char user_id[12];
    
char name[MAX_NAME_LENGTH];
    
char display[MAX_NAME_LENGTH+12];
    
    
int num_clients;
    
    
Menu menu = new Menu(MenuHandler_SHOWPLAYERSTATUS);
    
menu.SetTitle("Select Player to view status on:");
        
    for (
int i 1<= MaxClientsi++)
    {
        
        
IntToString(GetClientUserId(i), user_idsizeof(user_id));
        
GetClientName(inamesizeof(name));
        
Format(displaysizeof(display), "%s (%s)"nameuser_id);
        
menu.AddItem(user_iddisplay);
        
//PrintToChat(client, display);
        
num_clients++;
    }
    
menu.ExitButton true;
    
menu.Display(client20);
 
    return 
Plugin_Handled;


Last edited by BlackComb; 01-01-2017 at 15:09.
BlackComb is offline
BlackComb
Junior Member
Join Date: Nov 2010
Old 01-01-2017 , 17:56   Re: [Help] Displaying Custom Menu not working...
Reply With Quote #6

After hours of trying.. I have finally got it working now..

Thank you

Please change this Thread to Solved
BlackComb 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 11:06.


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