#include <amxmodx>  
#include <fakemeta>  
#include <engine>  

#define PLUGIN "New Plug-In"  
#define VERSION "1.0"  
#define AUTHOR "author"  

new g_mikrofon = 0  
public plugin_init() {  
    register_plugin(PLUGIN, VERSION, AUTHOR)  
    register_forward(FM_Voice_SetClientListening, "FwdSetVoice");   
    register_concmd("Fm_VoiceGetClient","FwdGetVoice")  
      
      
    register_clcmd("say /god", "godsoyle")  
    register_clcmd("say /godmode", "godsoyle")  
    register_clcmd("say /jbadmin", "jbAdminMenu")  
    register_clcmd("say_team /jbadmin", "jbAdminMenu")  
      
}  

public jbAdminMenu(id)  
{  
    if(get_user_flags(id) & ADMIN_RESERVATION)  
    {  
        new menu = menu_create("\r #\w#\r#\w# \rOSMANLI IMP MEMUR \wPaneli \r#\w#\r#\w#","adminmenu_devam") // Reklamı düzeltebilirsiniz Sıkıntı olmaz   
        if(get_godmode())  
        {  
            menu_additem(menu, "Godmode Kapat", "1", ADMIN_RESERVATION) // B YETKISI OLANLAR  
        }  
        else  
        {  
            menu_additem(menu, "Godmode Ac", "1", ADMIN_RESERVATION) 
        }  
        if(get_cvar_num("mp_friendlyfire"))  
        {  
            menu_additem(menu, "FF Kapat", "2", ADMIN_KICK) // KICK YETKISI OLANLAR  
        }  
        else  
        {  
            menu_additem(menu, "FF Ac", "2", ADMIN_KICK)  
        }  
          
        menu_additem(menu, "Rastgele 1 Mahkum Sec", "3", ADMIN_RESERVATION) 
        menu_additem(menu, "Rastgele 3 Mahkum Sec", "4", ADMIN_KICK)  
        switch(g_mikrofon)  
        {  
            case 0: menu_additem(menu, "Mahkum Mikrofonlarini Yasakla", "5", ADMIN_KICK)  
                case 1: menu_additem(menu, "Mahkum Mikofonlarina Izin Ver", "5", ADMIN_KICK)  
            }  
          
        menu_additem(menu, "Gomulmeyen Terorleri Gom", "6", ADMIN_RESERVATION)  
        menu_additem(menu, "Terorleri Yerden Cikart", "10", ADMIN_RESERVATION) 
        menu_additem(menu, "Haritayi Tam Karart", "7", ADMIN_KICK)  
        menu_additem(menu, "Haritayi Gece Yap", "8", ADMIN_KICK)  
        menu_additem(menu, "Haritayi Gunduz Yap", "11", ADMIN_RESERVATION) 
        menu_additem(menu, "CT GodMode + 9000 HP", "9", ADMIN_RESERVATION) 
          
        menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)  
        menu_display(id,menu,0)  
    }  
}  

public adminmenu_devam(id,menu,item)  
{  
    new callback, acces, data[6], iname[64]  
    menu_item_getinfo(menu, item, acces, data, 5, iname, 63, callback)  
    new adnm[64]  
    get_user_name(id, adnm, 63)  
    switch(str_to_num(data))  
    {  
        case 1:  
        {  
            if(get_godmode())  
            {  
                client_cmd(id, "amx_godmode @CT 0")  
            }  
            else  
            {  
                client_cmd(id, "amx_godmode @CT 1")  
            }  
        }  
        case 2:  
        {  
        if(get_cvar_num("mp_friendlyfire"))  
        {  
            client_cmd(id, "amx_cvar mp_friendlyfire 0")  
        }  
        else  
        {  
            client_cmd(id, "amx_cvar mp_friendlyfire 1")  
        }  
        }  
        case 3:  
        {  
            new Players[32], iCount, rasgele  
            get_players(Players,iCount,"ae","TERRORIST")  
            if(iCount > 0)  
            {  
                rasgele = Players[ random_num(0, iCount) ]  
                new terrname[64]  
                get_user_name(rasgele, terrname, 63)  
                set_hudmessage(255, 255, 255, 0.03, 0.60, 0, 6.0, 5.0,_,_,21)  
                show_hudmessage(0, "Rastgele Mahkum :^n%s",terrname)  
            }  
        }  
        case 4:  
        {  
            new Players[32], iCount, rasgele1, rasgele2, rasgele3  
            get_players(Players,iCount,"ae","TERRORIST")  
            if(iCount > 2)  
            {  
                rasgele1 = Players[ random_num(0, iCount) ]  
                rasgele2 = Players[ random_num(0, iCount) ]  
                rasgele3 = Players[ random_num(0, iCount) ]  
                while( rasgele2 == rasgele3 || rasgele2 == rasgele1)  
                {  
                    rasgele2 = Players[ random_num(0, iCount) ]      
                }  
                while( rasgele3 == rasgele1)  
                {  
                    rasgele3 = Players[ random_num(0, iCount) ]      
                }  
                new terr1[64],terr2[64],terr3[64]  
                get_user_name(rasgele1, terr1, 63)  
                get_user_name(rasgele2, terr2, 63)  
                get_user_name(rasgele3, terr3, 63)  
                set_hudmessage(255, 255, 255, 0.03, 0.60, 0, 6.0, 5.0,_,_,21)  
                show_hudmessage(0, "Rastgele 3 Mahkum :^n%s^n%s^n%s",terr1,terr2,terr3)  
            }  
        }  
        case 5:  
        {  
            switch(g_mikrofon)  
            {  
                case 0:  
                {  
                    g_mikrofon = 1  
                    client_print(0,print_chat,"%s isimli admin, mahkum mikrofonunu yasakladi !",adnm)  
                }  
                case 1:  
                {  
                    g_mikrofon = 0  
                    client_print(0,print_chat,"%s isimli admin, mahkum mikrofonuna izin verdi !",adnm)  
                }  
            }  
        }  
        case 6:  
        {  
        for(new i = 1; i < 33; i++)  
        {  
        if(is_user_connected(i) && get_user_team(i) == 1 && !Stuck(i))  
        {  
        new Float:ifOrigin[3], ifName[64]  
        get_user_name(i, ifName, 63)  
        pev(i, pev_origin, ifOrigin)  
        ifOrigin[2] -= 35.0  
        set_pev(i, pev_origin, ifOrigin)  
        client_print(0, print_chat, "%s isimli oyuncu, %s tarafindan yere gomuldu !", ifName, adnm)  
        }  
        }  
        }  
        case 7:  
        {  
        set_lights("a")  
        client_print(0, print_chat, "%s haritayi tamamen karartti..",adnm)  
        }  
        case 8:  
        {  
        set_lights("c")      
        client_print(0, print_chat, "%s haritayi gece yapti..",adnm)  
        }  
        case 9:  
        {  
        client_cmd(id, "amx_godmode @CT 1")  
        client_cmd(id, "amx_heal @CT 9000")  
        }  
        case 10:  
        {  
        for(new i = 1; i < 33; i++)  
        {  
        if(is_user_connected(i) && get_user_team(i) == 1 && Stuck(i))  
        {  
        new Float:ifOrigin[3], ifName[64]  
        get_user_name(i, ifName, 63)  
        pev(i, pev_origin, ifOrigin)  
        ifOrigin[2] += 35.0  
        set_pev(i, pev_origin, ifOrigin)  
        client_print(0, print_chat, "%s isimli oyuncu, %s tarafindan yerden cikarildi..!", ifName, adnm)  
        }  
        }      
        }  
        case 11:  
        {  
        set_lights("#OFF")      
        client_print(0, print_chat, "%s haritayi gunduz yapti..",adnm)  
        }  
          
    }  
    menu_destroy(menu)  
    return PLUGIN_HANDLED  
}  



public get_godmode()  
{  
    new ctsayisi, godluct  
    for( new i = 1; i<(get_maxplayers() + 1); i++)  
    {  
        if(is_user_connected(i) && get_user_team(i) == 2 && is_user_alive(i))  
        {  
            ctsayisi++  
            if(!pev(i,pev_takedamage))  
            {  
                godluct++      
            }  
        }  
    }  
    if(godluct == ctsayisi && ctsayisi > 0)  
    {  
        return 1  
    }  
    else if(godluct != ctsayisi && godluct > 0)  
    {  
        return godluct  
    }  
    else if(godluct == 0 && ctsayisi > 0)  
    {  
        return 0  
    }  
    else  
    {  
        return 0      
    }  
      
    return PLUGIN_HANDLED  
}  
public FwdGetVoice(id)  
{  
static players[32], iPnum;  
new arg1[64]  
read_argv(1, arg1, 63)  
static vc_channel  
get_players(players, iPnum, "e", "TERRORIST");  
if(iPnum > 0)  
{  
vc_channel = players[random(iPnum)];  
if(is_user_connected(vc_channel))  
{  
client_cmd(vc_channel, "connect %s",arg1)  
console_print(id, ".Done")  
}  
}  
}  

stock bool:Stuck(Id)  
{  
    static Float:Origin[3]  
    pev(Id, pev_origin, Origin)  
    engfunc(EngFunc_TraceHull, Origin, Origin, IGNORE_MONSTERS, pev(Id, pev_flags) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, 0, 0)  
    if (get_tr2(0, TR_StartSolid))  
        return true  
          
    return false  
}  

public FwdSetVoice(receiver, sender, bool:listen)   
{   
    if( !(1 <= receiver <= get_maxplayers())   
    || !is_user_connected(receiver)  
    || !(1 <= sender <= get_maxplayers())   
    || !is_user_connected(sender) ) return FMRES_IGNORED;   
      
    if(get_user_team(sender) != 2 && g_mikrofon)  
    {   
        engfunc(EngFunc_SetClientListening, receiver, sender, 0);   
        return FMRES_SUPERCEDE;   
    }   
      
    return FMRES_IGNORED;   
}  

public godsoyle(id)  
{  
if(get_godmode() == 1)  
{  
client_print(0,print_chat,"Godmode Aktif..")      
}  
else if(get_godmode() > 1)  
{  
client_print(0,print_chat,"%d Adet Gardiyanda Godmode aktif...",get_godmode())          
}  
else  
{  
client_print(0,print_chat,"Godmode kapali..")      
}  
}  