View Single Post
duce1nik
New Member
Join Date: Jul 2020
Old 07-05-2020 , 02:17   Re: Execute a plugin command from a menu.
Reply With Quote #3

PC Gamer,

Thank you for your reply.

It still not working for me.

My goal is to create a menu and call command for plugin that I installed.

For example, I installed F-18 Airstrike ( https://forums.alliedmods.net/showthread.php?t=187567 ). If I typed sm_strike in the console it will bring up the Air Strike Menu. I would like to call the same command from the my own menu instead of typing it console.


I confirmed the if statement is getting hit becuase ServerCommand("sm_slap Player1"); work in that statement, but ServerCommand("sm_strike"); is not working.


Please see code below.

PHP Code:


public PMenu(Handle:menuMenuAction:actionparam1param2)
{
switch (
action)
    {
    case 
MenuAction_Select:
        {
            new 
String:item[64];
            
GetMenuItem(menuparam2itemsizeof(item));
            if (
StrEqual(item,"Option1"))
            {
                
//this DO NOT work when call from the menu
                
ServerCommand("sm_strike");
                
                
//This work when call from the menu.
                
ServerCommand("sm_slap Player1");
            }
            
        }
        case 
MenuAction_End:
        {
            
delete menu;
        }
    }


duce1nik is offline