Hi! I'm making a plugin that manages the bots on a server in highlander mode.
First of all i created a new array. 1 index = 1 class
Then set that every time a player spawn its client id associates to an index
public Event_PlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
Code:
{
new client = GetClientOfUserId(GetEventInt(event, "userid"))
new TFTeam:team = TFTeam:GetEventInt(event,"team");
new TFClassType:class = TF2_GetPlayerClass(client);
if (class == 1 && team == 3)
{
Players[0] = client
}
else if (class == 1 && team == 2)
{
Players[1] = client
}
else if (class == 3 && team == 3)
{
Players[2] = client
}
else if (class == 3 && team == 2)
{
Players[3] = client
}
else if (class == 7 && team == 3)
{
Players[4] = client
}
else if (class == 7 && team == 2)
{
Players[5] = client
}
else if (class == 4 && team == 3)
{
Players[6] = client
}
else if (class == 4 && team == 2)
{
Players[7] = client
}
else if (class == 6 && team == 3)
{
Players[8] = client
}
else if (class == 6 && team == 2)
{
Players[9] = client
}
else if (class == 9 && team == 3)
{
Players[10] = client
}
else if (class == 9 && team == 2)
{
Players[11] = client
}
else if (class == 5 && team == 3)
{
Players[12] = client
}
else if (class == 5 && team == 2)
{
Players[13] = client
}
else if (class == 2 && team == 3)
{
Players[14] = client
}
else if (class == 2 && team == 2)
{
Players[15] = client
}
else if (class == 8 && team == 3)
{
Players[16] = client
}
else if (class == 8 && team == 2)
{
Players[17] = client
}
}
This way i can recognize and kicks bots by only knowing its class
Players[0] is Blu Scout, 1 is Red Scout, 2 is Blu Soldier, 3 is Red Soldier, 4 is Blu Pyro, etc...
(Maybe there is a way a lot easier to do this. But it's my first plugin, i just started 1.5 weeks ago

)
Now i want that to kick a bot (so only if it is a fake client, else do nothing) through a command in chat / on a menu. I tried a lot of ways but the game does not kick the specified bot.
One of the way i tried is:
*example for the soldier*
Code:
public SoldierMenuHandler(Handle:menu, MenuAction:action, client, param2)
{
if (action == MenuAction_Cancel && param2 == MenuCancel_ExitBack)
{
Menu_Test1(client);
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
else if (action == MenuAction_Select)
{
char info[32];
GetMenuItem(menu, param2, info, sizeof(info));
if (StrEqual(info, "1") && !IsFakeClient (Players[2])) //if i select "Blu Team" and the client on index 2 is not a bot
{
PrintToChat(client,"Slot is not a bot.");
}
else if (StrEqual(info,"1") && IsFakeClient(Players[2]))
{
KickClient (Players[2]);
}
}
}
(Obviously, when a client disconnects the plugin will remove that client number from the array. But i still haven't added it. I'm trying this plugin when the match starts and all the player are in-game without anyone disconnecting.)
But i don't see any message in the console. I just see the bot disappear without any notice.
Also, does not get kicked the bot i want everytime. What's wrong?