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

Creating a Donation Menu that executes commands, error related to a variable


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Doodil
Senior Member
Join Date: Mar 2012
Old 08-24-2013 , 11:20   Re: Creating a Donation Menu that executes commands, error related to a variable
Reply With Quote #11

Quote:
Toggles evil trail on me and closes the menu. I'd like it to stay open until you manually close it (by pressing 0).
After a selection was made you have to redisplay the menu:

HTML Code:
public MenuHandler(Handle:menu, MenuAction:action, client, param2)
{
    switch (action)
    {
    case MenuAction_Select:
        {
            switch (param2)    //You can also use ServerCommand to do it directly without the client typing the command themselves.
            {
            case 0:
                {
                    FakeClientCommandEx(client, "say /eviltrail");
                    //ServerCommand("sm_robot #%d", GetClientUserId(client));    <-- Example of server command instead of fake client command.
                }
            case 1:
                {
                    FakeClientCommandEx(client, "say /evilglow");
                }
            case 2:
                {
                    FakeClientCommandEx(client, "say /robot");
                }
            }
            DisplayMenu(menu, client, MENU_TIME_FOREVER);
        }
    case MenuAction_End:
        {
            CloseHandle(menu);
        }
    }
}
________________________________

Quote:
How do I make the text in the menu Toggle.
You should save somewhere which client has activated the trail and who hasn't (by defining a global array of MAXPLAYER size) and changing this value whenever he uses the menu (so right after you call the function for the trail). Once you've done that you just change your
HTML Code:
 AddMenuItem(menu, "sm_robot", "Evil Trail");
to something like:

HTML Code:
if (clientHasTrail[client] == true)
{
	AddMenuItem(menu, "sm_robot", "Evil Trail [ON]");
}
else
{
	AddMenuItem(menu, "sm_robot", "Evil Trail [OFF]");
}
where clientHasTrail[] is a global array of booleans, saving wether or not the trail is already active.


________________________________

Quote:
How can I display commands in the menu (adding commands to the menu) based on which flags the admin has?
try something like:
HTML Code:
if(GetUserFlagBits(client) & ADMFLAG_CHAT)
{
	AddMenuItem(menu, "sm_robot", "Evil Trail");
}
(yes only one &)
to check the AccessFlags of a client against a certain flag. If the client has the ADMFLAG_CHAT in this example, then the if-expression will resolve to a number>0, and therefore will be interpreted as if(true). If you do it this way you kinda work around the override system, so consider using CheckCommandAccess instead.

________________________________

Quote:
Can anyone link me to a tutorial describing how to use sub menus?
Well you basically just draw a second menu after the first one, saving the information about what was selected in the submenu-selection itself or in a global array for the client. Just check out some of the approved plugins that already do that.
Doodil is offline
 



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 01:56.


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