I've found a problem with this plugin. the g_round variable get incremented even for the rounds and maps that the plugin is not enabled. On our servers, we only enable this pluging for dod_jagd and dod_strand. We would get messages that the teams will be swapped in -4 rounds, because g_round had been incremented above the value of sm_dod_swapteam.
I've modified one function to fix this:
Code:
public PlayerRoundWinEvent(Handle:event, const String:name[], bool:dontBroadcast)
{
new plugin_rounds=GetConVarInt(g_Cvar_Swapteams);
if(plugin_rounds != 0)
{
//Added by Regor Tejmar -- Only increment g_rounds if plugin is enabled.
g_rounds+=1;
//Added by psychocoder
if (plugin_rounds<=g_rounds) // If g_rounds is too high change too RT
{
new Float:delay = float(GetConVarInt(g_Cvar_BonusRound));
PrintToChatAll("\x01\x04[SM] Teams will be swapped in %i seconds", GetConVarInt(g_Cvar_BonusRound));
g_rounds=0;
if (delay > 0)
{
CreateTimer(delay, DelayedSwitch, 0, 0);
}
else
{
ChangeTeams();
}
}
else
{
PrintToChatAll("\x01\x04[SM] Teams will be swapped in %i round(s)", plugin_rounds-g_rounds);
}
}
else
//Added by Regor Tejmar -- Reset round count if plugin is disabled.
{
g_rounds=0;
}
}
Also, it looks like pschocoders last suggestion was never added.
Quote:
Originally Posted by psychocoder
Ohh very fast edit.
I think you forgot the initialisation of g_round. Or were all declaratet variables 0 ?
Code:
public OnMapStart ()
{
g_rounds=0;
}
|
This is a good change that resets the round count on a map change. without it, it may swap teams one or more rounds early.
I've attached a new source code with these changes.