Okay there are a few things wrong with what you added:
1. "JoinRandomTeam" is a function. You cannot check if it returns true or false.
2. You are checking inside OnPluginStart() which only fires once the plugin loads, so it will not check each time a player uses the command.
3. You are passing the wrong parameters to PrintHintText().
To get what you need, you must remove that whole section and instead put this inside JoinRandomTeam at the very top:
PHP Code:
if (client <= 0 || client > MaxClients || !IsClientInGame(client)) {
return Plugin_Handled;
}
new team = GetClientTeam(client);
if(team > 1) {
PrintHintText(client, "You've already entered the %i team already. don't change team", team);
return Plugin_Handled;
}
It should look like this:
PHP Code:
public Action:JoinRandomTeam(client, args) {
if (client <= 0 || client > MaxClients || !IsClientInGame(client)) {
return Plugin_Handled;
}
new team = GetClientTeam(client);
if(team > 1) {
PrintHintText(client, "You've already entered the %i team already. don't change team", team);
return Plugin_Handled;
}
LogActivity(client, "JoinRandomTeam");
GetMaxValues();
// See how much space is left on the teams
new survslots = MAX_SURVIVORS - TeamCount(TEAM_SURVIVOR);
new infslots = MAX_INFECTED - TeamCount(TEAM_INFECTED);
if (survslots > infslots)
{
PerformSwitch(client, client, TEAM_SURVIVOR, false);
return Plugin_Handled;
}
if (infslots > survslots)
{
PerformSwitch(client, client, TEAM_INFECTED, false);
return Plugin_Handled;
}
// Equal slots if we got here
if (survslots == 0)
{
PrintToChat(client, "There are no open team slots to join.");
return Plugin_Handled;
}
new rndteam = CreateRandomInt(2,3)
PerformSwitch(client, client, rndteam, false);
return Plugin_Handled;
}
__________________