Code:
#include <sourcemod>
public Plugin:myinfo =
{
name = "GunGiver",
author = "Knate",
description = "Shows a menu and give you the selected weapon",
version = "1.0",
url = "http://www.sourcemod.net/"
};
public OnPluginStart()
{
RegConsoleCmd("guns", Menu1);
}
public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
{
/* If an option was selected, tell the client about the item. */
if (action == MenuAction_Select)
{
new String:info[32];
new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info);
FakeClientCommandEx(param1, "say Test");
}
/* If the menu was cancelled, print a message to the server about it. */
else if (action == MenuAction_Cancel)
{
PrintToServer("Client %d's menu was cancelled. Reason: %d", param1, param2);
}
/* If the menu has ended, destroy it */
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
public Action:Menu1(client, args)
{
new Handle:menu = CreateMenu(MenuHandler1);
SetMenuTitle(menu, "GunGiver 1.0 | Menu");
AddMenuItem(menu, "AWP", "AWP");
AddMenuItem(menu, "M4A1", "M4A1");
SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 20);
return Plugin_Handled;
}