AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to add commands ? :D (https://forums.alliedmods.net/showthread.php?t=199039)

cofisx 10-23-2012 14:27

How to add commands ? :D
 
Hello ! Im newbie in scripting :(
So i need pros help :D

I made this (somehove its works) :D

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 :D

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) :D

Sillium 10-24-2012 01:22

Re: How to add commands ? :D
 
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

cofisx 10-24-2012 13:42

Re: How to add commands ? :D
 
Yes i know about that :) But if someone can make what im asking it will be perfect :) And i will +rep him every day :D Becose i need this plugin for mixes, and i want disable Admin menu in my server :)

cofisx 10-24-2012 13:43

Re: How to add commands ? :D
 
I was tryng do it by my self, but after 2 hours i give up :(

InB 10-24-2012 19:04

Re: How to add commands ? :D
 
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");



cofisx 10-24-2012 20:08

Re: How to add commands ? :D
 
i think no :D 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 :D

InB 10-24-2012 20:15

Re: How to add commands ? :D
 
Quote:

Originally Posted by cofisx (Post 1825119)
i think no :D 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 :D


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?

cofisx 10-24-2012 20:59

Re: How to add commands ? :D
 
Yes ! You can understand what im saying :D 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

InB 10-24-2012 21:38

Re: How to add commands ? :D
 
-removed

11530 10-24-2012 21:45

Re: How to add commands ? :D
 
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;




All times are GMT -4. The time now is 11:42.

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