AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Voteban Plugin Help Needed!!!!!!! (https://forums.alliedmods.net/showthread.php?t=133682)

Alb0 07-27-2010 18:49

Voteban Plugin Help Needed!!!!!!!
 
One thing i want changed, is when the menu after /voteban comes up, that the admins names present, are gray. Meaning players won't be able to press them. They still can't voteban them, but the delay time kicks in when it's pressed.

Any help would be appreciated. :]



PHP Code:

#include <amxmodx>
#include <amxmisc>

#define MAX_players 32
#define MAX_menudata 1024

new const g_dont_vote_these_steamids[][] =
{
    
"STEAM_0:1:2345",
    
"STEAM_0:1:23456"
    
// etc.
};

new 
ga_PlayerName[MAX_players][32]
new 
ga_PlayerAuthID[MAX_players][35]
new 
ga_PlayerID[MAX_players]
new 
ga_PlayerIP[MAX_players][16]
new 
ga_MenuData[MAX_menudata]
new 
ga_Choice[2]
new 
gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset 0
new i
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType


public plugin_init()
{
    
register_plugin("Voteban","1.2","hjvl")
    
register_clcmd("say /voteban","SayIt" )
    
register_menucmd(register_menuid("ChoosePlayer"), 1023"ChooseMenu")
    
register_menucmd(register_menuid("VoteMenu"), 1023"CountVotes")
    
    
gi_LastTime=register_cvar("amx_voteban_lasttime","0")
    
gi_DelayTime=register_cvar("amxx_voteban_delaytime","600")
    
gf_Ratio=register_cvar("amxx_voteban_ratio","0.60")
    
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
    
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.40")
    
gi_BanTime=register_cvar("amxx_voteban_bantime","5")
    
gi_Disable=register_cvar("amxx_voteban_disable","0")
    
gi_BanType=register_cvar("amxx_voteban_type","0")
}

public 
SayIt(id)
{
    if(
get_pcvar_num(gi_Disable))
    {
        
client_print(id,print_chat,"[!V!] Voteban has been disabled")
        return 
0
    
}
    
    new 
Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
    new 
Delay=get_pcvar_num(gi_DelayTime)
    
    if((
Delay Elapsed) && get_user_flags(id) != ADMIN_IMMUNITY)
    {
        new 
seconds Delay Elapsed
        client_print
(id,print_chat,"[!V!] You have to wait %d seconds before a new voteban can be started"seconds)
        return 
0
    
}
    
    
get_players(ga_PlayerIDgi_TotalPlayers)
    for(
i=0i<gi_TotalPlayersi++)
    {
        new 
TempID ga_PlayerID[i]
        if(
get_user_flags(TempID) & ADMIN_IMMUNITY)
        {
            if(
get_user_flags(id) & ADMIN_IMMUNITY)
            {
                if(
TempID == id)
                {
                    
gi_VoteStarter=i
                    get_user_name
TempIDga_PlayerName[i], 31 )
                    
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                    
get_user_ipTempIDga_PlayerIP[i], 15)
                }
            }
            else
            {
                
client_print(id,print_chat,"??????,?????")
                return 
0
            
}
        }
        else
        {
            if(
TempID == id)
            {
                
gi_VoteStarter=i
                get_user_name
TempIDga_PlayerName[i], 31 )
                
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                
get_user_ipTempIDga_PlayerIP[i], 15)
            }
        }
        
gi_MenuPosition 0
        ShowPlayerMenu
(id)
        return 
0
    
}
    return 
PLUGIN_HANDLED;
}

public 
ShowPlayerMenu(id)
{
    new 
arrayloc 0
    
new keys = (1<<9)
    
    
arrayloc format(ga_MenuData,(MAX_menudata-1),"Voteban Menu:^n^n")
    for(
i=0i<8i++)
    {
        if( 
gi_TotalPlayers>(gi_MenuPosition+i) )
        {
            
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"%d. %s^n"i+1ga_PlayerName[gi_MenuPosition+i])
            
keys |= (1<<i)
        }
    }
    if( 
gi_TotalPlayers>(gi_MenuPosition+8) )
    {
        
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n9. More")
        
keys |= (1<<8)
    }
    
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Back/Exit")
    
    
show_menu(idkeysga_MenuData20"ChoosePlayer")
    return 
PLUGIN_HANDLED 
}

public 
ChooseMenu(idkey)
{
    switch(
key)
    {
        case 
8:
        {
            
gi_MenuPosition=gi_MenuPosition+8
            ShowPlayerMenu
(id)
        }
        case 
9:
        {
            if(
gi_MenuPosition>=8)
            {
                
gi_MenuPosition=gi_MenuPosition-8
                ShowPlayerMenu
(id)
            }
            else
                return 
0
        
}
        default:
        {
            
gi_Sellection=gi_MenuPosition+key
            
new Now=get_systime(gi_SysTimeOffset)
            
set_pcvar_num(gi_LastTimeNow)
            if((
get_user_flags(ga_PlayerID[gi_Sellection]) & ADMIN_RESERVATION))
            {
                
client_print(id,print_chat,"[!V!] You can't voteban this player")
                return 
PLUGIN_HANDLED;
            }
            
            new 
steamid[35];
            
get_user_authid(ga_PlayerID[gi_Sellection], steamidsizeof(steamid) - 1);
            for( new 
0sizeof(g_dont_vote_these_steamids); i++ )
            {
                if( !
strcmp(steamidg_dont_vote_these_steamids[i]) ) return PLUGIN_HANDLED;
            }
            
run_vote()
            return 
0
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
run_vote()
{    
    
log_amx("[!V!] Voteban started by %s for %s %s"ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
    
format(ga_MenuData,(MAX_menudata-1),"Ban %s for %d minutes?^n^n 1. Yes^n 2. No",ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
    
ga_Choice[0] = 0
    ga_Choice
[1] = 0
    show_menu
0, (1<<0)|(1<<1), ga_MenuData15"VoteMenu" )
    
set_task(15.0,"outcom")
    return 
0
}

public 
CountVotes(idkey)
{
    ++
ga_Choice[key]
    return 
PLUGIN_HANDLED
}

public 
outcom()
{
    new 
TotalVotes ga_Choice[0] + ga_Choice[1]
    new 
Float:result = (float(ga_Choice[0]) / float(TotalVotes))
    
    if( 
get_pcvar_float(gf_MinVoters) >= ( float(TotalVotes) / float(gi_TotalPlayers) ) )
    {
        
client_print(0,print_chat,"[!V!] Not enough voters to ban %s!"ga_PlayerName[gi_Sellection])
        return 
0
    
}
    else
    {
        if( 
result get_pcvar_float(gf_BF_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_VoteStarter)
            
log_amx("[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
        }
        
        if( 
result >= get_pcvar_float(gf_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
            
log_amx("[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerAuthID[gi_Sellection], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_Sellection)
        }
        else
        {
            
client_print(0,print_chat,"[!V!] The vote did not succeed!")
            
log_amx("[AMXX] The voteban did not sucseed.")
        }
    }
    
client_print(0,print_chat,"[!V!] A total of %d players, %d voted Yes."gi_TotalPlayersga_Choice[0])
    
    return 
0
}

public 
ActualBan(Selected)
{
    new 
Type get_pcvar_num(gi_BanType
    switch(
Type)
    {
        case 
1:
            
server_cmd("addip %d %s"get_pcvar_num(gi_BanTime), ga_PlayerIP[Selected])
        case 
2:
            
server_cmd("amx_ban %d %s Voteban"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
        default:
            
server_cmd("banid %d %s kick"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
    }
    return 




fysiks 07-27-2010 19:35

Re: Voteban Plugin Help Needed!!!!!!!
 
If the player is an admin, is_user_admin(), then don't add the key to the 'keys' variable. Also, to make it gray you can add the \d to the begining of the line if that player is an admin, iirc.

Alb0 07-27-2010 19:39

Re: Voteban Plugin Help Needed!!!!!!!
 
Quote:

Originally Posted by fysiks (Post 1253572)
If the player is an admin, is_user_admin(), then don't add the key to the 'keys' variable. Also, to make it gray you can add the \d to the begining of the line if that player is an admin, iirc.

Would you please be so kind, and re-write the php code with it included? :x

fysiks 07-27-2010 20:46

Re: Voteban Plugin Help Needed!!!!!!!
 
Quote:

Originally Posted by Alb0 (Post 1253580)
Would you please be so kind, and re-write the php code with it included? :x

Nope. First of all, this is Scripting Help not "do this for me" and second, that code was painful to read (no offense).

Alb0 07-28-2010 23:10

Re: Voteban Plugin Help Needed!!!!!!!
 
Alright i got that part fixed with one of my friends.. But now im having a different issue.. Players can't see others names.. like it has the number option example: 1. Alb0 2. (blank) 3. (blank) .. It doesn't show the players names... Any idea on that?

nikhilgupta345 07-28-2010 23:15

Re: Voteban Plugin Help Needed!!!!!!!
 
Post the new code?

Alb0 07-28-2010 23:28

Re: Voteban Plugin Help Needed!!!!!!!
 
Quote:

Originally Posted by nikhilgupta345 (Post 1254763)
Post the new code?

PHP Code:

#include <amxmodx>
#include <amxmisc>

#define MAX_players 32
#define MAX_menudata 1024

new const g_dont_vote_these_steamids[][] =
{
    
"STEAM_0:1:2345",
    
"STEAM_0:1:23456"
    
// etc.
};

new 
ga_PlayerName[MAX_players][32]
new 
ga_PlayerAuthID[MAX_players][35]
new 
ga_PlayerID[MAX_players]
new 
ga_PlayerIP[MAX_players][16]
new 
ga_MenuData[MAX_menudata]
new 
ga_Choice[2]
new 
gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset 0
new i
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType


public plugin_init()
{
    
register_plugin("Voteban","1.2","hjvl")
    
register_clcmd("say /voteban","SayIt" )
    
register_menucmd(register_menuid("ChoosePlayer"), 1023"ChooseMenu")
    
register_menucmd(register_menuid("VoteMenu"), 1023"CountVotes")
    
    
gi_LastTime=register_cvar("amx_voteban_lasttime","0")
    
gi_DelayTime=register_cvar("amxx_voteban_delaytime","600")
    
gf_Ratio=register_cvar("amxx_voteban_ratio","0.60")
    
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
    
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.40")
    
gi_BanTime=register_cvar("amxx_voteban_bantime","5")
    
gi_Disable=register_cvar("amxx_voteban_disable","0")
    
gi_BanType=register_cvar("amxx_voteban_type","0")
}

public 
client_connect(id)
{
    
get_user_name(idga_PlayerName[id], 31 )
    
get_user_authididga_PlayerAuthID[id], 34 )
    
get_user_ipidga_PlayerIP[id], 15)
}

public 
SayIt(id)
{
    if(
get_pcvar_num(gi_Disable))
    {
        
client_print(id,print_chat,"[!V!] Voteban has been disabled")
        return 
0
    
}
    
    new 
Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
    new 
Delay=get_pcvar_num(gi_DelayTime)
    
    if((
Delay Elapsed) && get_user_flags(id) != ADMIN_IMMUNITY)
    {
        new 
seconds Delay Elapsed
        client_print
(id,print_chat,"[!V!] You have to wait %d seconds before a new voteban can be started"seconds)
        return 
0
    
}
    
    
get_players(ga_PlayerIDgi_TotalPlayers)
    for(
i=0i<gi_TotalPlayersi++)
    {
        new 
TempID ga_PlayerID[i]
        if(
get_user_flags(TempID) & ADMIN_IMMUNITY)
        {
            if(
TempID == id)
            {
                
gi_VoteStarter=i
                get_user_name
TempIDga_PlayerName[i], 31 )
                
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                
get_user_ipTempIDga_PlayerIP[i], 15)
            }
        }
        else
        {
            if(
TempID == id)
            {
                
gi_VoteStarter=i
                get_user_name
TempIDga_PlayerName[i], 31 )
                
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                
get_user_ipTempIDga_PlayerIP[i], 15)
            }
        }
        
gi_MenuPosition 1
        ShowPlayerMenu
(id)
        return 
0
    
}
    return 
PLUGIN_HANDLED;
}

public 
ShowPlayerMenu(id)
{
    new 
arrayloc 0
    
new keys = (1<<9)
    
    
arrayloc format(ga_MenuData,(MAX_menudata-1),"Voteban Menu:^n^n")
    for(
i=0i<8i++)
    {
        if( 
gi_TotalPlayers>(gi_MenuPosition+i) )
        {
            if(
get_user_flags(gi_MenuPosition+i) & ADMIN_IMMUNITY)
            {
                
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"\d%d. %s^n"i+1ga_PlayerName[gi_MenuPosition+i])
            }
            else
            {
                
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"\w%d. %s^n"i+1ga_PlayerName[gi_MenuPosition+i])
                
keys |= (1<<i)
            }
        }
    }
    if( 
gi_TotalPlayers>(gi_MenuPosition+8) )
    {
        
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n9. More")
        
keys |= (1<<8)
    }
    
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Back/Exit")
    
    
show_menu(idkeysga_MenuData20"ChoosePlayer")
    return 
PLUGIN_HANDLED 
}

public 
ChooseMenu(idkey)
{
    switch(
key)
    {
        case 
8:
        {
            
gi_MenuPosition=gi_MenuPosition+8
            ShowPlayerMenu
(id)
        }
        case 
9:
        {
            if(
gi_MenuPosition>=8)
            {
                
gi_MenuPosition=gi_MenuPosition-8
                ShowPlayerMenu
(id)
            }
            else
                return 
0
        
}
        default:
        {
            
gi_Sellection=gi_MenuPosition+key
            
new Now=get_systime(gi_SysTimeOffset)
            
set_pcvar_num(gi_LastTimeNow)
            if((
get_user_flags(ga_PlayerID[gi_Sellection]) & ADMIN_RESERVATION))
            {
                
client_print(id,print_chat,"[!V!] You can't voteban this player")
                return 
PLUGIN_HANDLED;
            }
            
            new 
steamid[35];
            
get_user_authid(ga_PlayerID[gi_Sellection], steamidsizeof(steamid) - 1);
            for( new 
0sizeof(g_dont_vote_these_steamids); i++ )
            {
                if( !
strcmp(steamidg_dont_vote_these_steamids[i]) ) return PLUGIN_HANDLED;
            }
            
run_vote()
            return 
0
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
run_vote()
{    
    
log_amx("[!V!] Voteban started by %s for %s %s"ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
    
format(ga_MenuData,(MAX_menudata-1),"Ban %s for %d minutes?^n^n 1. Yes^n 2. No",ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
    
ga_Choice[0] = 0
    ga_Choice
[1] = 0
    show_menu
0, (1<<0)|(1<<1), ga_MenuData15"VoteMenu" )
    
set_task(15.0,"outcom")
    return 
0
}

public 
CountVotes(idkey)
{
    ++
ga_Choice[key]
    return 
PLUGIN_HANDLED
}

public 
outcom()
{
    new 
TotalVotes ga_Choice[0] + ga_Choice[1]
    new 
Float:result = (float(ga_Choice[0]) / float(TotalVotes))
    
    if( 
get_pcvar_float(gf_MinVoters) >= ( float(TotalVotes) / float(gi_TotalPlayers) ) )
    {
        
client_print(0,print_chat,"[!V!] Not enough voters to ban %s!"ga_PlayerName[gi_Sellection])
        return 
0
    
}
    else
    {
        if( 
result get_pcvar_float(gf_BF_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_VoteStarter)
            
log_amx("[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
        }
        
        if( 
result >= get_pcvar_float(gf_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
            
log_amx("[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerAuthID[gi_Sellection], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_Sellection)
        }
        else
        {
            
client_print(0,print_chat,"[!V!] The vote did not succeed!")
            
log_amx("[AMXX] The voteban dit not sucseed.")
        }
    }
    
client_print(0,print_chat,"[!V!] A total of %d players, %d voted Yes."gi_TotalPlayersga_Choice[0])
    
    return 
0
}

public 
ActualBan(Selected)
{
    new 
Type get_pcvar_num(gi_BanType
    switch(
Type)
    {
        case 
1:
            
server_cmd("addip %d %s"get_pcvar_num(gi_BanTime), ga_PlayerIP[Selected])
        case 
2:
            
server_cmd("amx_ban %d %s Voteban"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
        default:
            
server_cmd("banid %d %s kick"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
    }
    return 




ARES[ro] 07-28-2010 23:50

Re: Voteban Plugin Help Needed!!!!!!!
 
http://i307.photobucket.com/albums/n...menustatus.jpg
these are the symptoms
and here is the code
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define MAX_players 32
#define MAX_menudata 1024

new const g_dont_vote_these_steamids[][] =
{
    
"STEAM_0:1:2345",
    
"STEAM_0:1:23456"
    
// etc.
};

new 
ga_PlayerName[MAX_players][32]
new 
ga_PlayerAuthID[MAX_players][35]
new 
ga_PlayerID[MAX_players]
new 
ga_PlayerIP[MAX_players][16]
new 
ga_MenuData[MAX_menudata]
new 
ga_Choice[2]
new 
gi_VoteStarter
new gi_MenuPosition
new gi_Sellection
new gi_TotalPlayers
new gi_SysTimeOffset 0
new i
//pcvars
new gi_LastTime
new gi_DelayTime
new gf_Ratio
new gf_MinVoters
new gf_BF_Ratio
new gi_BanTime
new gi_Disable
new gi_BanType


public plugin_init()
{
    
register_plugin("Voteban","1.2","hjvl")
    
register_clcmd("say /voteban","SayIt" )
    
register_menucmd(register_menuid("ChoosePlayer"), 1023"ChooseMenu")
    
register_menucmd(register_menuid("VoteMenu"), 1023"CountVotes")
    
    
gi_LastTime=register_cvar("amx_voteban_lasttime","0")
    
gi_DelayTime=register_cvar("amxx_voteban_delaytime","600")
    
gf_Ratio=register_cvar("amxx_voteban_ratio","0.60")
    
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
    
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.40")
    
gi_BanTime=register_cvar("amxx_voteban_bantime","5")
    
gi_Disable=register_cvar("amxx_voteban_disable","0")
    
gi_BanType=register_cvar("amxx_voteban_type","0")
}

public 
client_connect(id)
{
    for(
i=0i<MAX_playersi++)
    {
        if(
is_user_connected(i))
        {
            
get_user_name(iga_PlayerName[i], 31 )
            
get_user_authidiga_PlayerAuthID[i], 34 )
            
get_user_ipiga_PlayerIP[i], 15)
        }
        else
        {
            
ga_PlayerName[i] = ""
            
ga_PlayerAuthID[i] = ""
            
ga_PlayerIP[i] = ""
        
}
        if(
is_user_bot(id))
        {
            
get_user_name(iga_PlayerName[i], 31 )
            
get_user_authidiga_PlayerAuthID[i], 34 )
            
get_user_ipiga_PlayerIP[i], 15)
        }
    }
}
public 
client_disconnect(id)
{
    for(
i=0i<MAX_playersi++)
    {
        if(
is_user_connected(i))
        {
            
get_user_name(iga_PlayerName[i], 31 )
            
get_user_authidiga_PlayerAuthID[i], 34 )
            
get_user_ipiga_PlayerIP[i], 15)
        }
        else
        {
            
ga_PlayerName[i] = ""
            
ga_PlayerAuthID[i] = ""
            
ga_PlayerIP[i] = ""
        
}
        if(
is_user_bot(id))
        {
            
get_user_name(iga_PlayerName[i], 31 )
            
get_user_authidiga_PlayerAuthID[i], 34 )
            
get_user_ipiga_PlayerIP[i], 15)
        }
    }
}

public 
SayIt(id)
{
    if(
get_pcvar_num(gi_Disable))
    {
        
client_print(id,print_chat,"[!V!] Voteban has been disabled")
        return 
0
    
}
    
    new 
Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
    new 
Delay=get_pcvar_num(gi_DelayTime)
    
    if((
Delay Elapsed) && get_user_flags(id) != ADMIN_IMMUNITY)
    {
        new 
seconds Delay Elapsed
        client_print
(id,print_chat,"[!V!] You have to wait %d seconds before a new voteban can be started"seconds)
        return 
0
    
}
    
    
get_players(ga_PlayerIDgi_TotalPlayers)
    for(
i=0i<gi_TotalPlayersi++)
    {
        new 
TempID ga_PlayerID[i]
        if(
get_user_flags(TempID) & ADMIN_IMMUNITY)
        {
            if(
TempID == id)
            {
                
gi_VoteStarter=i
                get_user_name
TempIDga_PlayerName[i], 31 )
                
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                
get_user_ipTempIDga_PlayerIP[i], 15)
            }
        }
        else
        {
            if(
TempID == id)
            {
                
gi_VoteStarter=i
                get_user_name
TempIDga_PlayerName[i], 31 )
                
get_user_authidTempIDga_PlayerAuthID[i], 34 )
                
get_user_ipTempIDga_PlayerIP[i], 15)
            }
        }
        
gi_MenuPosition 1
        ShowPlayerMenu
(id)
        return 
0
    
}
    return 
PLUGIN_HANDLED;
}

public 
ShowPlayerMenu(id)
{
    new 
arrayloc 0
    
new keys = (1<<9)
    
    
arrayloc format(ga_MenuData,(MAX_menudata-1),"Voteban Menu:^n^n")
    for(
i=0i<8i++)
    {
        if( 
gi_TotalPlayers+1>=(gi_MenuPosition+i) )
        {
            if(
get_user_flags(gi_MenuPosition+i) & ADMIN_IMMUNITY)
            {
                
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"\d%d. %s^n"i+1ga_PlayerName[gi_MenuPosition+i])
            }
            else
            {
                
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"\w%d. %s^n"i+1ga_PlayerName[gi_MenuPosition+i])
                
keys |= (1<<i)
            }
        }
    }
    if( 
gi_TotalPlayers>(gi_MenuPosition+8) )
    {
        
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n9. More")
        
keys |= (1<<8)
    }
    
arrayloc += format(ga_MenuData[arrayloc],(MAX_menudata-1-arrayloc),"^n0. Back/Exit")
    
    
show_menu(idkeysga_MenuData20"ChoosePlayer")
    return 
PLUGIN_HANDLED 
}

public 
ChooseMenu(idkey)
{
    switch(
key)
    {
        case 
8:
        {
            
gi_MenuPosition=gi_MenuPosition+8
            ShowPlayerMenu
(id)
        }
        case 
9:
        {
            if(
gi_MenuPosition>=8)
            {
                
gi_MenuPosition=gi_MenuPosition-8
                ShowPlayerMenu
(id)
            }
            else
                return 
0
        
}
        default:
        {
            
gi_Sellection=gi_MenuPosition+key
            
new Now=get_systime(gi_SysTimeOffset)
            
set_pcvar_num(gi_LastTimeNow)
            if((
get_user_flags(ga_PlayerID[gi_Sellection]) & ADMIN_RESERVATION))
            {
                
client_print(id,print_chat,"[!V!] You can't voteban this player")
                return 
PLUGIN_HANDLED;
            }
            
            new 
steamid[35];
            
get_user_authid(ga_PlayerID[gi_Sellection], steamidsizeof(steamid) - 1);
            for( new 
0sizeof(g_dont_vote_these_steamids); i++ )
            {
                if( !
strcmp(steamidg_dont_vote_these_steamids[i]) ) return PLUGIN_HANDLED;
            }
            
run_vote()
            return 
0
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
run_vote()
{    
    
log_amx("[!V!] Voteban started by %s for %s %s"ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
    
format(ga_MenuData,(MAX_menudata-1),"Ban %s for %d minutes?^n^n 1. Yes^n 2. No",ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
    
ga_Choice[0] = 0
    ga_Choice
[1] = 0
    show_menu
0, (1<<0)|(1<<1), ga_MenuData15"VoteMenu" )
    
set_task(15.0,"outcom")
    return 
0
}

public 
CountVotes(idkey)
{
    ++
ga_Choice[key]
    return 
PLUGIN_HANDLED
}

public 
outcom()
{
    new 
TotalVotes ga_Choice[0] + ga_Choice[1]
    new 
Float:result = (float(ga_Choice[0]) / float(TotalVotes))
    
    if( 
get_pcvar_float(gf_MinVoters) >= ( float(TotalVotes) / float(gi_TotalPlayers) ) )
    {
        
client_print(0,print_chat,"[!V!] Not enough voters to ban %s!"ga_PlayerName[gi_Sellection])
        return 
0
    
}
    else
    {
        if( 
result get_pcvar_float(gf_BF_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_VoteStarter)
            
log_amx("[!V!] The vote back fired at %s, he is banned for %d minutes"ga_PlayerName[gi_VoteStarter], get_pcvar_num(gi_BanTime))
        }
        
        if( 
result >= get_pcvar_float(gf_Ratio) )
        {
            
client_print(0,print_chat,"[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
            
log_amx("[!V!] The vote succeeded: %s is banned for %d minutes"ga_PlayerAuthID[gi_Sellection], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_Sellection)
        }
        else
        {
            
client_print(0,print_chat,"[!V!] The vote did not succeed!")
            
log_amx("[AMXX] The voteban dit not sucseed.")
        }
    }
    
client_print(0,print_chat,"[!V!] A total of %d players, %d voted Yes."gi_TotalPlayersga_Choice[0])
    
    return 
0
}

public 
ActualBan(Selected)
{
    new 
Type get_pcvar_num(gi_BanType
    switch(
Type)
    {
        case 
1:
            
server_cmd("addip %d %s"get_pcvar_num(gi_BanTime), ga_PlayerIP[Selected])
        case 
2:
            
server_cmd("amx_ban %d %s Voteban"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
        default:
            
server_cmd("banid %d %s kick"get_pcvar_num(gi_BanTime), ga_PlayerAuthID[Selected])
    }
    return 




fysiks 07-29-2010 02:30

Re: Voteban Plugin Help Needed!!!!!!!
 
I don't think you understand how player entity IDs work.

This type of menu is done several times in plmenu.sma and you should look at it to see how it is done. I highly suggest you look at the kick menu. The menu is activated on line 478, displayed on line 417, and the menu handler is on line 385. All your answers are in that plugin.

ARES[ro] 07-29-2010 10:32

Re: Voteban Plugin Help Needed!!!!!!!
 
ok ill re-write it


All times are GMT -4. The time now is 00:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.