public void OnPluginStart()
{
RegConsoleCmd("sm_bot", Cmd_ShowBotsMenu, "Show Bots Menu.");
}
public Action Cmd_ShowBotsMenu(int client, int args)
{
if(!client || !IsClientInGame(client))
return Plugin_Handled;
PrintToChat(client, "Menu Opened");
Menu menu = new Menu(BotsList);
menu.SetTitle("Select A Bot:");
char uid[8], sName[MAX_NAME_LENGTH];
for(int i = 1; i <= MaxClients; i++)
if(IsClientInGame(i) && IsFakeClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
{
GetClientName(i, sName, sizeof(sName));
FormatEx(uid, sizeof(uid), "%i", GetClientUserId(i));
menu.AddItem(uid, sName);
}
if(!menu.ItemCount) menu.AddItem("", "Bots not found", ITEMDRAW_DISABLED);
menu.Display(client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int BotsList(Menu menu, MenuAction action, int client, int param)
{
switch(action)
{
case MenuAction_Select:
{
char sInfo[8];
menu.GetItem(param, sInfo, sizeof(sInfo));
int target = StringToInt(sInfo);
if(target && (target = GetClientUserId(target)))
PrintToChatAll("%N has selected %N.", client, target);
else Cmd_ShowBotsMenu(client, 0);
}
case MenuAction_End: delete menu;
}
return 0;
}
参考: