Perhaps that's how it should be done, that's how I wrote the code correctly
PHP Code:
#include <sourcemod>
#include <sdktools>
public void OnPluginStart()
{
HookEvent("player_disconnect", Event_Disconnect, EventHookMode_Post);
}
public Action Event_Disconnect(Event hEvent, const char[] sName, bool bDontBroadcast)
{
if (GetTeamClientCount(3) == 0 &&GetTeamClientCount(2) >1)
{
for (int i = 1; i <= MaxClients; i++)
{
int iClient = GetRandomInt(1, i);
if (GetClientTeam(iClient) == 2 )
ChangeClientTeam(iClient, 3);
}
}
return Plugin_Continue;
}
that is , if the team "3" zero(0) players , and for the team "2" > 2 players, then "2" teams, threw 1 player randomly.
(I need, if I had no player, then only one player threw me from another. That's what I need . Sorry, it's also difficult for me to understand English and write on it.)
I wanted to ask , did I write it right ?
And this is something like a teambalance, but only when there is no one in one of the teams.
And so anyway thanks for the help with the code.
By the way, I have found the complete code in the source of Hide-and-seek , he below . Strange why he doesn't want to work ...
MinPlayers=2
PHP Code:
public OnClientDisconnect(iClient)
{
if (g_hInfoPanelTimer[iClient] != INVALID_HANDLE)
{
KillTimer(g_hInfoPanelTimer[iClient]);
}
if (g_bModRunning && g_bRoundActive)
{
if (GetTeamClientCount(Team_Seekers) == 0)
{
if (GetTeamClientCount(Team_Hiders) >= GetConVarInt(g_ConVar[MinPlayers]))
{
SelectSeeker();
SetPlayerState(g_iSeeker, PlayerState_ObserverMode);
ChangeClientTeam(g_iSeeker, Team_Seekers);
PrintHintText(g_iSeeker, "You're now the seeker!");
PrintToChatAll("%s Player %N is now the seeker.", HIDENSEEK_PREFIX, g_iSeeker);
}
else
{
RestartRound();
}
}
else
{
CheckWin();
}
}
}
that is , if the player left the server=disconnected zero emotions, the plugin for some reason does not want this code to work out .
add
do you need hookevent for this function
OnClientDisconnect, and then something in the cookies can not find it, maybe because of this and does not want to work this part of the code ?