Quote:
Originally Posted by Michael Shoe Maker
I'm using
PHP Code:
AddCommandListener(Listener_JoinTeam, "jointeam")
to check if a team is joinable under certain conditions, however If the team is full as a result of a ratio I have to change the player back to their original team and this spams the chat a bit. Is there an event that handles team join so that you can stop the event and prevent any team changes?
|
Use what you already had, and hook player_team side by side with it, e.g.:
Code:
public void OnPluginStart()
{
AddCommandListener(Listener_JoinTeam, "jointeam");
HookEvent("player_team", Event_PlayerTeam, EventHookMode_Pre);
}
public Action Event_PlayerTeam(Event event, const char[] name, bool:dontBroadcast)
{
if(GetConVarInt(g_bcRatioEnabled))
{
SetEventBroadcast(event, true);
}
return Plugin_Continue;
}
public Action Listener_JoinTeam(int client, const char[] command, int args)
{
if(GetConVarInt(g_bcRatioEnabled))
{
char sArg1[3];
GetCmdArg(1, sArg1, sizeof(sArg1));
int iArg1 = StringToInt(sArg1);
int iTeamCountT = GetTeamClientCount(2);
int iTeamCountCT = GetTeamClientCount(3);
if(iArg1 == 3)
{
if((iTeamCountT / GetConVarInt(g_bcRatio)) > iTeamCountCT) //ratio = 3
{
CPrintToChat(client, "Joined");
} else {
CPrintToChat(client, "Full");
ChangeClientTeam(client, 2);
}
}
}
}
The "simplified" version of the player_team event would be like this:
Code:
public Action Event_PlayerTeam(Event event, const char[] name, bool:dontBroadcast)
{
SetEventBroadcast(event, true);
return Plugin_Continue;
}
I have just included your if () {}, to check whether or not your plugin is currently enabled.
__________________