Grey83,
Thank you for your time, knowledge, and energy to help me.
With this reply you got me to 95% of what I wanted.
I could have been a little clearer on what I wanted.
Here is a simplified version of the requirements.
I want to set the conv mp_humanteam in this way:
1) No humans on the server set
mp_humanteam "any"
2) First human to join the server set
mp_humanteam = The team the first human to join selected = "t"/"ct"
3) For any human that isn't the first to connect DON'T SHOW the choose team screen
and just automatically connect them to the mp_humanteam team.
Everything is working as expected with the following plugin,
except I can't figure out how to implement #3 above...
The Sourcemod community is totally awesome!
Obviously....
Thanks!
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
ConVar mp_humanteam;
bool firstHumanToJoin = true;
public void OnPluginStart()
{
mp_humanteam = FindConVar("mp_humanteam");
HookEvent("player_team", Event_Team);
HookEvent("player_connect_full", Event_PlayerConnectFull);
SetConVarString(mp_humanteam, "any");
firstHumanToJoin = true;
PrintToServer("ABS_CSGO_TeamSelect Loaded");
}
public void Event_PlayerConnectFull(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
// check if the client is valid and not assigned to a team yet
if (client && !GetClientTeam(client))
{
// if they are not the first human to join
// auto place them on the human team
// this also bypasses the team join screen
if(!firstHumanToJoin)
{
char team[64];
GetConVarString(mp_humanteam, team, sizeof(team));
if(StrEqual(team, "t", false))
ChangeClientTeam(client, 2);
else if(StrEqual(team, "ct", false))
ChangeClientTeam(client, 3);
}
}
}
public void Event_Team(Event event, const char[] name, bool dontBroadcast)
{
if(event.GetBool("disconnect"))
return;
int userid = GetClientOfUserId(event.GetInt("userid"));
if(userid &&
IsClientInGame(userid) &&
!IsFakeClient(userid) &&
firstHumanToJoin &&
(event.GetInt("team")) > 1)
{
if (event.GetInt("team") == 2)
SetConVarString(mp_humanteam, "t");
else if (event.GetInt("team") == 3)
SetConVarString(mp_humanteam, "ct");
firstHumanToJoin = false;
}
}
public void OnMapStart()
{
SetConVarString(mp_humanteam, "any");
firstHumanToJoin = true;
}
public void OnPluginEnd()
{
SetConVarString(mp_humanteam, "any");
firstHumanToJoin = true;
}