Quote:
Originally Posted by asherkin
Your IsBotIn function is throwing an error, read your error logs.
|
There were two warnings: tag mismatch at line 32 and loose indentation at last "return false;" (line 42)
I resolved the tag mismatch warning by changing the line to this:
Code:
if(_:TF2_GetPlayerClass(i) == iClass && GetClientTeam(i) == iTeam)
I also added brackets after the for cycle.
The loose identation warning is still unsolved, could it be the problem?
Quote:
Originally Posted by luki1412
You are using the post event hook, so the class change already happened. Not sure what exactly are you trying to do here. Are you trying to ignore bots when limiting classes for real players?
My plugins for limiting bots/humans might be able to help you - https://forums.alliedmods.net/showthread.php?t=229369
|
Haven't made yet the other code. For now the plugin does this:
1. Client opens classmenu (,) and chooses a class
2. If the chosen class is already played by someone else do action: if that player is a bot then go to step 3a, else go to step 3b
3a. print to chat ("BOT SI")
3b. print to chat ("BOT NO")
The problem is that the plugin does not print neither BOT SI nor BOT NO.
Why?
Also, i knew sourcemod can't pre-hook game events... :S
This is the modified code:
Code:
#include <sourcemod>
#include <tf2_stocks>
public OnPluginStart()
{
HookEvent ("player_changeclass", Event_ChangeClass);
}
public Event_ChangeClass(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId (GetEventInt (event, "userid")),
iClass = GetEventInt (event, "class"),
iTeam = GetClientTeam (iClient);
PrintToChatAll("Test123 %d",iClass);
if (IsBotIn(iTeam, iClass))
{
PrintToChatAll("BOT SI.");
}
else
{
PrintToChatAll("BOT NO.");
}
}
bool:IsBotIn(iTeam, iClass)
{
int i;
for (i = 0; i <= MaxClients ; i++)
{
if(_:TF2_GetPlayerClass(i) == iClass && GetClientTeam(i) == iTeam)
{
if (IsFakeClient(i))
{
return true;
}
else if (!IsFakeClient(i))
{
return false;
}
}
}
return false;
}
EDIT: Forgot to say that this plugin is meant to be used in highlander mode. This way bots will only fill empty slots during the match. If a real user chooses a class, and that slot is being played by a bot, the plugin will automatically kick it. Else, if a real client is playing that class, there will be a message in chat ("Slot is taken").
However, i won't enable highlander mode on the server, because people will not be able to choose class since all the bots are filling the slots.
This is the reason why during the for cycle there won't be the problem that it will find more than 1 user with a specified class and team. (Except the client, because this is a post hook event... I should add a filter for that)