/* Plugin generated by AMXX-Studio */
 
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <fun>
 
#define PLUGIN "[JAIL] Podziel"
#define VERSION "1.0"
#define AUTHOR "MalySzkrab4k"
 
public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        register_clcmd( "say /podziel", "podziel" );
        register_clcmd( "jail_dziel", "podziel" );
}
 
public podziel( id )
{
        if (!is_user_alive(id))
                return PLUGIN_HANDLED;
 
        new szItem[ 128 ];
        formatex( szItem, charsmax( szItem ), "\rPodziel wiezniow na:");
       
        new Menu = menu_create( szItem, "Opcje" );
       
        menu_additem( Menu, "\r2 \wdruzyny", "0");
        menu_additem( Menu, "\r3 \wdruzyny", "1" );
        menu_additem( Menu, "\r4 \wdruzyny", "2");
        menu_additem( Menu, "\r5 \wdruzyn^n","3");
        menu_additem( Menu, "\r**\wRozwiaz druzyny","4");
 
        menu_setprop( Menu, MPROP_NUMBER_COLOR, "\y" );
        menu_setprop( Menu, MPROP_EXITNAME, "Wyjdz" );
        menu_display( id, Menu, 0 );
       
        return PLUGIN_HANDLED;
}
public Opcje(id, Menu, Item )
{
        if (!is_user_alive(id))
                return PLUGIN_HANDLED;
 
        if ( Item == MENU_EXIT )
        {
                menu_destroy( Menu );
                return PLUGIN_HANDLED;
        }
       
        switch ( Item )
        {
                case 0: podziel1(id);
                case 1: podziel2(id);
                case 2: podziel3(id);
                case 3: podziel4(id);
                case 4: rozdziel(id);
        }
       
        menu_destroy( Menu );
        return PLUGIN_HANDLED;
}
public podziel1(id)
{
       
        if (cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
        {
               
                new playerCount
                new Players[32]
               
                get_players(Players, playerCount, "ae", "TERRORIST")
               
                new iExtraPlayers = playerCount % 2
               
                if (iExtraPlayers)
                {
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Liczba wiezniow^x03 nie jest podzielna przez 2.^x04")
                }
                else
                {
                        for(new maxPerSquad = (playerCount / 2), squads[2], squad, player, i = 0; i < playerCount; i++)
                        {
                                player = Players[i]
                                squad = random_num(0, 1)
                               
                                if(squads[squad] >= maxPerSquad)
                                        squad = !squad
                                else
                                        squads[squad]++
                                       
                                if(squad == 0)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 CZERWONYCH.^x04")
                                }
                                else if (squad == 1)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 90, 255, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 NIEBIESKICH.^x04")
                                }
                        }
                        ColorChat(0, RED, "^x04***Jailbreak***^x01 Druzyna wiezniow^x03 zostala podzielona na 2 druzyny.^x04")
                }
        }
}  
public podziel2(id)
{
       
        if (cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
        {
               
                new playerCount
                new Players[32]
               
                get_players(Players, playerCount, "ae", "TERRORIST")
               
                new iExtraPlayers = playerCount % 3
               
                if (iExtraPlayers)
                {
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Liczba wiezniow^x03 nie jest podzielna przez 3.^x04")           
                }
                else
                {
                        for(new maxPerSquad = (playerCount / 3), squads[3], squad, player, i = 0; i < playerCount; i++)
                        {
                                player = Players[i]
                                squad = random_num(0, 2)
                               
                                if(squads[squad] >= maxPerSquad)
                                        squad = !squad
                                else
                                        squads[squad]++
                                       
                                if(squad == 0)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 CZERWONYCH.^x04")
                                }
                                else if (squad == 1)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 90, 255, kRenderNormal, 10)  
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 NIEBIESKICH.^x04")
                                }
                                else if (squad == 2)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 ZIELONYCH.^x04")
                                }
                        }
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Druzyna wiezniow^x03 zostala podzielona na 3 druzyny.^x04")
 
                }
        }
}  
public podziel3(id)
{
       
        if (cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
        {
               
                new playerCount
                new Players[32]
               
                get_players(Players, playerCount, "ae", "TERRORIST")
               
                new iExtraPlayers = playerCount % 4
               
                if (iExtraPlayers)
                {
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Liczba wiezniow^x03 nie jest podzielna przez 4.^x04")
                }
                else
                {
                        for(new maxPerSquad = (playerCount / 4), squads[4], squad, player, i = 0; i < playerCount; i++)
                        {
                                player = Players[i]
                                squad = random_num(0, 3)
                               
                                if(squads[squad] >= maxPerSquad)
                                        squad = !squad
                                else
                                        squads[squad]++
                                       
                                if(squad == 0)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 10)   
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 CZERWONYCH.^x04")
                                }
                                else if (squad == 1)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 90, 255, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 NIEBIESKICH.^x04")
                                }
                                else if (squad == 2)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 ZIELONYCH.^x04")
                                }
                                else if (squad == 3)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 10) 
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 ZOLTYCH.^x04")
                                }
                        }
                        ColorChat(0, RED, "^x04***Jailbreak***^x01 Druzyna wiezniow^x03 zostala podzielona na 4 druzyny.^x04")
                }
        }
}  
public podziel4(id)
{
       
        if (cs_get_user_team(id) == CS_TEAM_CT && is_user_alive(id))
        {
               
                new playerCount
                new Players[32]
               
                get_players(Players, playerCount, "ae", "TERRORIST")
               
                new iExtraPlayers = playerCount % 5
               
                if (iExtraPlayers)
                {
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Liczba wiezniow^x03 nie jest podzielna przez 5.^x04")
                }
                else
                {
                        for(new maxPerSquad = (playerCount / 5), squads[5], squad, player, i = 0; i < playerCount; i++)
                        {
                                player = Players[i]
                                squad = random_num(0, 4)
                               
                                if(squads[squad] >= maxPerSquad)
                                        squad = !squad
                                else
                                        squads[squad]++
                                       
                                if(squad == 0)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 10)   
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 CZERWONYCH.^x04")
                                }
                                else if (squad == 1)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 90, 255, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 NIEBIESKICH.^x04")
                                }
                                else if (squad == 2)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 ZIELONYCH.^x04")
                                }
                                else if (squad == 3)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 255, 0, kRenderNormal, 10) 
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 ZOLTYCH.^x04")
                                }
                                else if (squad == 4)
                                {
                                set_user_rendering(player, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 10)
                                ColorChat(player, RED, "^x04***Jailbreak***^x01 Jestes w druzynie^x03 BIALYCH.^x04")
                                }
                        }
                        ColorChat(id, RED, "^x04***Jailbreak***^x01 Druzyna wiezniow^x03 zostala podzielona na 5 druzyn.^x04")
                }
        }
}  
public rozdziel(id)
{
        if (cs_get_user_team(id) == CS_TEAM_T && is_user_alive(id))
        {
                for(new i = 1; i <= 32; i++)
                {
                        {
                        set_user_rendering(i, kRenderFxGlowShell, 0, 0, 0, kRenderNormal, 10)                  
                        }
                }
               
        }
}