It'll work only if the plugin is named as 'teamswitcher', otherwise the code you provided will do nothing, check this:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN "Unknown yet"
#define VERSION "1.0"
#define AUTHOR "EFFEX"
new g_iRoundsWon[CsTeams], CsTeams:g_csTeamWon
new bool:g_bPluginOn, bool:g_bTeamsSwitched, pCvarMinRoundsToSwitch
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
pCvarMinRoundsToSwitch = register_cvar("minrounds_to_switch", "10")
register_concmd("amx_switch", "cmdStopSwitch", ADMIN_KICK, "<1|0> - turn the switch plugin on/off")
register_event("TextMsg", "event_roundRestarted","a", "2&#Game_C", "2&#Game_w")
register_event("SendAudio", "event_TerroristsWin","a", "2&%!MRAD_terwin")
register_event("SendAudio", "event_CTerroristsWin","a", "2&%!MRAD_ctwin")
g_bPluginOn = true
}
public cmdStopSwitch(id, iLevel, iCid)
{
if(!cmd_access(id, iLevel, iCid, 2))
return PLUGIN_HANDLED
new szMode[3]
read_argv(1, szMode, charsmax(szMode))
g_bPluginOn = bool:str_to_num(szMode)
console_print(id, "[AMXX]: The switch teams is now %sativated!", g_bPluginOn ? "" : "de")
return PLUGIN_HANDLED
}
public event_roundRestarted()
{
if(!g_bTeamsSwitched)
{
g_iRoundsWon[CS_TEAM_T] = g_iRoundsWon[CS_TEAM_CT] = 0
}
else g_bTeamsSwitched = false
public event_TerroristsWin()
{
if(!g_bPluginOn)
return
if(++g_iRoundsWon[CS_TEAM_T] >= get_pcvar_num(pCvarMinRoundsToSwitch))
{
g_csTeamWon = CS_TEAM_T
set_task(0.1, "printColoredHudMessage", .flags = "a", .repeat = 30)
set_task(3.5, "switchTeams")
}
}
public event_CTerroristsWin()
{
if(!g_bPluginOn)
return
if(++g_iRoundsWon[CS_TEAM_CT] >= get_pcvar_num(pCvarMinRoundsToSwitch))
{
g_csTeamWon = CS_TEAM_CT
set_task(0.1, "printColoredHudMessage", .flags = "a", .repeat = 30)
set_task(3.5, "switchTeams")
}
}
public printColoredHudMessage()
{
static bool:bTemp
new iRGB[3], bool:bTerrorWon = bool:(g_csTeamWon == CS_TEAM_T)
switch(bTemp)
{
case true:
{
if(bTerrorWon)
{
iRGB = {255, 0, 0}
}
else iRGB = {0, 100, 255}
bTemp = false
}
case false:
{
iRGB = {255, 255, 255}
bTemp = true
}
}
set_hudmessage(iRGB[0], iRGB[1], iRGB[2], -1.0, 0.3, 0, 1.0, 0.1)
show_hudmessage(0, "The %sTerrorist team has won %d rounds!^nSwitching teams...", bTerrorWon ? "" : "Counter-", get_pcvar_num(pCvarMinRoundsToSwitch))
}
public switchTeams()
{
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i, id;i < iNum; i++)
{
if(1 <= get_user_team((id = iPlayers[i])) <= 2)
{
cs_set_user_team(id , cs_get_user_team(id) == CS_TEAM_T ? CS_TEAM_CT : CS_TEAM_T)
}
}
g_bTeamsSwitched = true
new iTemp = g_iRoundsWon[CS_TEAM_T]
g_iRoundsWon[CS_TEAM_T] = g_iRoundsWon[CS_TEAM_CT]
g_iRoundsWon[CS_TEAM_CT] = iTemp
client_print(0, print_center, "Teams successfully swiched!")
server_cmd("sv_restart 1")
}