Yes, i don't know how, i typed "class" instead of "team" in the topic title, i'm sleeping i guess. Sorry!
Hi all. I'm trying to make something simple in Sourcemod that simply prevent a client from switching team when it's reached the limit.
Code:
public OnPluginStart()
{
HookEvent("player_team",Event_PlayerTeam);
}
public Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid")),
oldTeam = GetClientTeam(iClient),
newTeam = GetEventInt(event, "team");
if (fullTeam(newTeam))
{
PrintToChat(iClient, "Full team.");
TF2_SetPlayerClass(iClient, TFClass_Unknown);
ChangeClientTeam(iClient, 1);
}
}
bool:fullTeam(iTeam)
{
if(iTeam < 2)
return false;
else if(GetTeamClientCount(iTeam) >= 2)
{
return true;
}
return false;
}
Plugin is compiled without errors. I run it in my server but when there are (for example) 2 players on team RED and i try to switch to RED team this appears in chat:
cidra has joined team RED
Full team.
cidra has joined team SPECTATORS
This should be normal, but actually my client stays on RED team, not on SPEC.
At the beginning i tried to set the client's team to the old one. Now i also tried to simply switch to spectator team but with the same results (Here the reason why oldTeam is never used)
What could be the problem? Thanks in advance for you availability.