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

How to add commands ? :D


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cofisx
Junior Member
Join Date: Oct 2012
Old 10-23-2012 , 14:27   How to add commands ? :D
Reply With Quote #1

Hello ! Im newbie in scripting
So i need pros help

I made this (somehove its works)

Code:
public OnPluginStart()
{
    RegAdminCmd("mix",
        Command_mix,
        ADMFLAG_ROOT,
        "Mix meniu");
}
 
public PanelHandler1(Handle:menu, MenuAction:action, param1, param2)
{
    if (action == MenuAction_Select)
    {
        PrintToConsole(param1, "You selected item: %d", param2);
    } else if (action == MenuAction_Cancel) {
        PrintToServer("Client %d's menu was cancelled.  Reason: %d", param1, param2);
    }
}
 
public Action:Command_mix(client, args)
{
    new Handle:panel = CreatePanel();
    SetPanelTitle(panel, "Mix Menu");
    DrawPanelItem(panel, "Yes");
    DrawPanelItem(panel, "No");
 
    SendPanelToClient(panel, client, PanelHandler1, 20);
 
    CloseHandle(panel);
 
    return Plugin_Handled;
}
So what i want is commands if you can see its from wiki

So i whant to add commands but i dont know how.

When i write !mix in chat the menu shows up and there is 2 choises "Yes" and "No"

How to add commands like "Restart" "Live" and more ?

(Sorry for bad english)
cofisx is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 10-24-2012 , 01:22   Re: How to add commands ? :D
Reply With Quote #2

In this case it is done by this two lines:
PHP Code:
DrawPanelItem(panel"Yes");
DrawPanelItem(panel"No"); 
http://docs.sourcemod.net/api/index....d=show&id=219&

But depending on what you are trying to do it would probably be better to use Custom Admon Menus: http://wiki.alliedmods.net/Dynamic_A...28SourceMod%29
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this

www.unterwasserpyromanen.de

Last edited by Sillium; 10-24-2012 at 01:23.
Sillium is offline
cofisx
Junior Member
Join Date: Oct 2012
Old 10-24-2012 , 13:42   Re: How to add commands ? :D
Reply With Quote #3

Yes i know about that But if someone can make what im asking it will be perfect And i will +rep him every day Becose i need this plugin for mixes, and i want disable Admin menu in my server
cofisx is offline
cofisx
Junior Member
Join Date: Oct 2012
Old 10-24-2012 , 13:43   Re: How to add commands ? :D
Reply With Quote #4

I was tryng do it by my self, but after 2 hours i give up
cofisx is offline
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 10-24-2012 , 19:04   Re: How to add commands ? :D
Reply With Quote #5

Are you talking about this?

PHP Code:
public OnPluginStart()
{
    
RegConsoleCmd("sm_mix"Command_mix"Brings Mix Menu");
    
RegConsoleCmd("sm_restart"Command_restart"Brings Restart Menu");
    
RegConsoleCmd("sm_live"Command_live"Brings Live Menu");

__________________

Last edited by InB; 10-24-2012 at 19:10.
InB is offline
cofisx
Junior Member
Join Date: Oct 2012
Old 10-24-2012 , 20:08   Re: How to add commands ? :D
Reply With Quote #6

i think no i need when i write !mix then shows up menu, there you can select 1. Restart 2. Start live and more commands If you cant understand what i want, i can make a photo in photoshop
cofisx is offline
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 10-24-2012 , 20:15   Re: How to add commands ? :D
Reply With Quote #7

Quote:
Originally Posted by cofisx View Post
i think no i need when i write !mix then shows up menu, there you can select 1. Restart 2. Start live and more commands If you cant understand what i want, i can make a photo in photoshop

When you type !mix
it will show a menu like this?

Mix Menu
1. Restart
2. Live
3. Ect

is that what you mean? and also what do u mean by Restart and live?
__________________
InB is offline
cofisx
Junior Member
Join Date: Oct 2012
Old 10-24-2012 , 20:59   Re: How to add commands ? :D
Reply With Quote #8

Yes ! You can understand what im saying But i need more then
1. Restart
and
2. Live
i think my menu has to look like that:
Mix Menu
1. Restart
2. Spectate all
3. Live
4. Reset Mix
cofisx is offline
InB
AlliedModders Donor
Join Date: Aug 2012
Location: Los Angeles
Old 10-24-2012 , 21:38   Re: How to add commands ? :D
Reply With Quote #9

-removed
__________________

Last edited by InB; 10-24-2012 at 21:46.
InB is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 10-24-2012 , 21:45   Re: How to add commands ? :D
Reply With Quote #10

Something like this maybe?

PHP Code:
#include <sourcemod>

new Handle:g_hMenu INVALID_HANDLE;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_mix"OnMixCommandADMFLAG_ROOT"Mix menu");
}

public 
OnMapStart()
{
    
g_hMenu CreateMenu(MenuHandler);
    
SetMenuTitle(g_hMenu"Mix Menu");
    
AddMenuItem(g_hMenu"0""Restart");
    
AddMenuItem(g_hMenu"1""Spectate All");
    
AddMenuItem(g_hMenu"2""Live");
    
AddMenuItem(g_hMenu"3""Reset Mix");
}

public 
OnMapEnd()
{
    if (
g_hMenu != INVALID_HANDLE)
    {
        
CloseHandle(g_hMenu);
        
g_hMenu INVALID_HANDLE;
    }
}

public 
MenuHandler(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select && IsClientInGame(param1))
    {
        switch (
param2)
        {
            case 
0//Restart
            
{
                
PrintToChat(param1"Restart was selected");
            }

            case 
1//Spectate All
            
{
                
PrintToChat(param1"Spectate All was selected");
            }
            case 
2//Live
            
{
                
PrintToChat(param1"Live was selected");
            }
            case 
3//Reset Mix
            
{
                
PrintToChat(param1"Reset Mix was selected");
            }
        }    
    }
}
 
public 
Action:OnMixCommand(clientargs)
{
    if (
client == 0)
    {
        
ReplyToCommand(client"Cannot use command from RCON.");
        return 
Plugin_Handled;
    }
    
    if (
g_hMenu == INVALID_HANDLE)
    {
        
PrintToConsole(client"Unable to open menu!");
    }
    else
    {
        
DisplayMenu(g_hMenuclientMENU_TIME_FOREVER);
    }
 
    return 
Plugin_Handled;

__________________

Last edited by 11530; 10-24-2012 at 21:54.
11530 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 08:35.


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