Hello I'm using CSGO Base Builder by boomix (
https://forums.alliedmods.net/showthread.php?t=271363)
But there is a big problem, sometimes when the server is full, when the round is over the server is crashing. I think the problem is in Team Swap, so here is the code ->
PHP Code:
// EditPlus
#include <sourcemod>
#define VERSION "1.0"
#define LoopAllPlayersInGame(%1) for(int %1=1;%1<=MaxClients;++%1)\
if(IsClientInGame(%1) && !IsFakeClient(%1))
public Plugin:myinfo =
{
name = "Name",
author = "boomix",
description = "Description",
version = VERSION,
url = "http://forums.alliedmods.net"
};
public OnPluginStart()
{
CreateConVar("sm_name_version", VERSION, "Name Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
HookEvent("round_end", BB_RoundEnd);
}
public Action BB_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
CreateTimer(6.7, SwapTeams);
}
public Action SwapTeams(Handle tmr)
{
LoopAllPlayersInGame(i)
{
if (g_WasBuilderThisRound[i] )
ChangeClientTeamBetter(i, Zombies);
else if (!g_WasBuilderThisRound[i])
ChangeClientTeamBetter(i, Builders);
else
ChangeClientTeamBetter(i, Zombies);
}
}
void ChangeClientTeamBetter(int client, int team)
{
if (IsClientInGame(client) && !IsFakeClient(client) && team == Builders)
{
EditScore(client);
ChangeClientTeam(client, CS_TEAM_CT);
}
else if (IsClientInGame(client) && !IsFakeClient(client) && team == Zombies)
{
EditScore(client);
ChangeClientTeam(client, CS_TEAM_T);
}
}
void EditScore(int client)
{
int frags = GetClientFrags(client);
int deaths = GetClientDeaths(client);
int newfrags = frags + 1;
int newdeaths = deaths - 1;
SetEntProp(client, Prop_Data, "m_iFrags", newfrags);
SetEntProp(client, Prop_Data, "m_iDeaths", newdeaths);
}
I already tired with CS_TeamSwitch, but server is the same, server go crash again.
Any suggestions ? Thank you!