Hello Everyone,
I have started scripting and reading about scripts almost 3 months ago, I have read from here on how to create menu
Here.
I got the basics a little bit.
I wanted to create a simple survivors bot list > for l4d2, but not necessary since the concept is the same. I read few scripts but they are either old or too complicated for me with more than 800 lines on simple function.
I made this one, which display the bots, but I cant target each of their names, I tried to select for example "Nick", but it showed me I selected the wrong bot. In fact, it only shows me the first survivor bot. I would really appreciate some helps here, thanks
PHP Code:
public void OnPluginStart()
{
RegConsoleCmd("sm_bot", Command_ShowBotsMenu, "Show Bots Menu.");
}
public Action Command_ShowBotsMenu(int client, int args)
{
PrintToChat(client, "Menu Opened");
Create_SurvivorsBotListMenu(client);
return Plugin_Handled;
}
void Create_SurvivorsBotListMenu(int client)
{
Menu menu = new Menu(BotsList, MENU_ACTIONS_ALL);
menu.SetTitle("Select A Bot:");
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i) || !IsFakeClient(i) || !IsPlayerAlive(i) || GetClientTeam(i) != 2)
continue;
char sID[32];
char sName[64];
GetClientName(i, sName, sizeof(sName));
Format(sID, sizeof(sID), "%N", i);
menu.AddItem(sID, sName);
}
menu.Display(client, MENU_TIME_FOREVER);
}
public int BotsList(Menu menu, MenuAction action, int param1, int param2)
{
switch(action)
{
case MenuAction_Select:
{
char sInfo[64];
menu.GetItem(param2, sInfo, sizeof(sInfo));
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i) || !IsFakeClient(i) || !IsPlayerAlive(i) || GetClientTeam(i) != 2 && (StringToInt(sInfo) != i))
continue;
PrintToChatAll("%N has selected %N.", param1, i);
return;
}
}
case MenuAction_End:
{
delete menu;
}
}
}
__________________