AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]amx_banip #userid does not work. (https://forums.alliedmods.net/showthread.php?t=88014)

Metanabol 03-19-2009 10:50

[HELP]amx_banip #userid does not work.
 
Hello, im trying to fix some bugs with voteban, because i want to make baning player with amx_banip #userid :) but then i try, it says what user not found...
Bug of banning with amx bans amx_banip name is when my name is one letter like: A, B or AB, other player sometimes has equal letters in they nicks. so i prefer banning with userid, who's different :)

PHP Code:

public ActualBan(Selected)

    new 
banned1 get_user_userid(gi_Sellection//getting variable "banned player userid :)"
    
already //some bug fix with vote system, dont care
    
new Type get_pcvar_num(gi_BanType//ban type: all same, because i dont use other :)
    
switch(Type)
    {
        case 
1:
        
server_cmd("amx_banip #%s %s %s"banned1get_pcvar_num(gi_BanTime), get_pcvar_num(gi_Reason))
        case 
2:
        
server_cmd("amx_banip #%s %s %s"banned1get_pcvar_num(gi_BanTime), get_pcvar_num(gi_Reason))
        default:
        
server_cmd("amx_banip #%s %s %s"banned1get_pcvar_num(gi_BanTime), get_pcvar_num(gi_Reason))
    }
    return 



Whats the problem? I cant understand :/

YamiKaitou 03-19-2009 11:03

Re: [HELP]amx_banip #userid does not work.
 
Show full code

Metanabol 03-19-2009 11:18

Re: [HELP]amx_banip #userid does not work.
 
its very long... and is it necessary ? I think that you think (lol.. my "perfect" english.) that get_user_userid(gi_Sellection)
is wrong, because gi_sellection is invalid? no, it works perfect... i think problem is with banning :)
amx_banip nick/userid "time" "reason" :)
normaly then I try it in console, it ban players by userid.

BOYSplayCS 03-19-2009 11:19

Re: [HELP]amx_banip #userid does not work.
 
It doesn't ban the player BY userid, it bans their userid. amx_banip will do exactly what it says, ban ip.

Also, wrap the code around php tags.

EDIT: Put closing brackets when you case:

YamiKaitou 03-19-2009 11:42

Re: [HELP]amx_banip #userid does not work.
 
amx_banip #%d %d %d

Metanabol 03-19-2009 13:48

Re: [HELP]amx_banip #userid does not work.
 
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define MAX_players 32
#define MAX_menudata 1024

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_BanType
new already 1
public plugin_init()
{
    
register_plugin("voteban menu","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","180")
    
gf_Ratio=register_cvar("amxx_voteban_ratio","0.75")
    
gf_MinVoters=register_cvar("amxx_voteban_minvoters","0.0")
    
gf_BF_Ratio=register_cvar("amxx_voteban_bf_ratio","0.0")
    
gi_BanTime=register_cvar("amxx_voteban_bantime","30")
    
gi_BanType=register_cvar("amxx_voteban_type","2")
}

public 
SayIt(id)
{
    if(
already >= 1)
    {
        if(
get_user_flags(id) & ADMIN_SLAY)
        {
            
client_print(id,print_chat,"[KPZ] USER/ADMIN CANT RUN VOTEBAN")
            return 
0
        
}
    }
    else
    {
        
client_print(id,print_chat,"[KPZ] Voteban is already running")
        return 
0
    
}
    new 
Elapsed=get_systime(gi_SysTimeOffset) - get_pcvar_num(gi_LastTime)
    new 
Delay=get_pcvar_num(gi_DelayTime)
    
    if( (
Delay Elapsed))
    {
        new 
seconds Delay Elapsed
        client_print
(id,print_chat,"[KPZ] You have to wait %d seconds before a new voteban can be started"seconds)
        return 
0
    
}
    
    
get_playersga_PlayerIDgi_TotalPlayers )
    for(
i=0i<gi_TotalPlayersi++)
    {
        new 
TempID ga_PlayerID[i]
        if( 
get_user_flags(TempID) & ADMIN_SLAY)
        {
            if(!(
get_user_flags(id) & ADMIN_SLAY))
            {
                
client_print(id,print_chat,"[KPZ] USER/ADMIN in server. Voteban: disabled.")
                return 
0
            
}
        }
        
        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
}

public 
ShowPlayerMenu(id)
{
    new 
arrayloc 0
    
new keys = (1<<9)
    
    
arrayloc format(ga_MenuData,(MAX_menudata-1),"voteban menu ^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)
            
            
run_vote()
            return 
0
        
}
    }
    return 
PLUGIN_HANDLED
}

public 
run_vote()
{
    
already 0
    log_amx
("Vote ban started by %s for %s %s"ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection], ga_PlayerAuthID[gi_Sellection])
    
client_print(0,print_chat,"[KPZ] Player %s started voteban for [%s]"ga_PlayerName[gi_VoteStarter], ga_PlayerName[gi_Sellection])
    
format(ga_MenuData,(MAX_menudata-1),"Ban %s for %d minutes?^n1. Yes^n2. 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,"[VOTEBAN] 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,"[KPZ] 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("[KPZ] 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,"[KPZ] The vote succeeded, %s is banned for %d minutes"ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
            
log_amx("[KPZ] The vote succeeded: %s is banned for %d minutes"ga_PlayerName[gi_Sellection], get_pcvar_num(gi_BanTime))
            
ActualBan(gi_Sellection)
        }
        else
        {
            
client_print(0,print_chat,"[KPZ] The vote did not succeeded!")
            
log_amx("[KPZ] The voteban dit not succeed.")
            
already 1
        
}
    }
    
client_print(0,print_chat,"A total of %d players, %d voted yes."gi_TotalPlayersga_Choice[0])
    return 
0
}

public 
ActualBan(Selected)

    new 
banned1 get_user_userid(gi_Sellection//getting variable "banned player userid :)"
    
already //some bug fix with vote system, dont care
    
new Type get_pcvar_num(gi_BanType//ban type: all same, because i dont use other :)
    
switch(Type)
    {
        case 
1:
        
server_cmd("amx_banip #%d %a [AC]Voteban"banned1get_pcvar_num(gi_BanTime))
        case 
2:
        
server_cmd("amx_banip #%d %a [AC]Voteban"banned1get_pcvar_num(gi_BanTime))
        default:
        
server_cmd("amx_banip #%d %a [AC]Voteban"banned1get_pcvar_num(gi_BanTime))
    }
    return 



server totaly crashes then vote over. wtf is going... i cant understand..

YamiKaitou 03-19-2009 17:41

Re: [HELP]amx_banip #userid does not work.
 
%a is not a valid format option. Change it to %d or %i

Metanabol 03-20-2009 06:49

Re: [HELP]amx_banip #userid does not work.
 
ok fixed. but still wont ban userid (user with this userid not found) ...
PHP Code:

 case 2:
        
server_cmd("amx_banip #%d %i [AC]Voteban"banned1get_pcvar_num(gi_BanTime)) 


YamiKaitou 03-20-2009 09:17

Re: [HELP]amx_banip #userid does not work.
 
Print the server_cmd line to yourself and then verify that that userid is indeed in the server


All times are GMT -4. The time now is 08:53.

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