View Single Post
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 08-15-2019 , 22:11   Re: [ReQ] teams switch after round 10
Reply With Quote #10

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_bPluginOnbool:g_bTeamsSwitchedpCvarMinRoundsToSwitch

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
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(idiLeveliCid)
{
    if(!
cmd_access(idiLeveliCid2))
        return 
PLUGIN_HANDLED
        
    
new szMode[3]
    
read_argv(1szModecharsmax(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 = {25500}
            }
            else 
iRGB = {0100255}
            
            
bTemp false
        
}
        case 
false:
        {
            
iRGB = {255255255}
            
bTemp true
        
}
    }
    
set_hudmessage(iRGB[0], iRGB[1], iRGB[2], -1.00.301.00.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
(iPlayersiNum)
    for(new 
iid;iNumi++) 
    {
        if(
<= 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
(0print_center"Teams successfully swiched!")
    
server_cmd("sv_restart 1")

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 08-18-2019 at 02:26.
EFFx is offline