AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ban the worst player and map end (https://forums.alliedmods.net/showthread.php?t=162541)

lis_16 07-20-2011 06:54

Ban the worst player and map end
 
This is a bet system, if player type /zaklad-zaklad[index]=true for him. I want to ban the worst player who typed /zaklad or every player who has same frags count like the worst (fe. 4 players with frags: 30, 34, 20, 20. 2 players with frags 20 should be banned). Here is the code for banning but it won't work. What's wrong?


PHP Code:

new zaklad[33]
new 
czas
new odj_paka[33]
new 
bool:minely true

PHP Code:

public plugin_end(){
    new 
id_ban[32], pierwszy=falsecount=0ilosc=0
    
for(new id=0id<=32id++)
        if(
is_user_connected(id) && zaklad[id]) ilosc++
    if(
ilosc<2) return PLUGIN_CONTINUE
    
for(new id=0id<=32id++){
        if(
is_user_connected(id) && zaklad[id]){
            if(!
pierwszy){
                
pierwszy=true
                id_ban
[count]=id
                count
++
            }
            if(
id!=id_ban[count-1]){
                new 
fragi_obecnyfragi_nowy
                fragi_obecny
=get_user_frags(id_ban[count-1])-odj_paka[count-1// i subtract frags from plant/defuser a bomb.
                
fragi_nowy=get_user_frags(id)-odj_paka[id]
                if(
fragi_nowy==fragi_obecny){
                    
id_ban[count]=id
                    count
++
                }
                else if(
fragi_nowy<fragi_obecny){
                    
count=0
                    id_ban
[count]=id
                    count
++
                }
            }
        }
    }
    while(--
count>-1){
        
/*new ip[20]
        get_user_ip(id_ban[count], ip, 19, 1)
        server_cmd("addip %i %s", czas, ip)*/
        
new ip[20], authid[32], name[32]
        
get_user_name(countname31)
        
get_user_ip(id_ban[count], ip191)
        
get_user_authid(id_ban[count], authid31)
        if (!
equal(authid"STEAM_0:"8)){
            
server_cmd("amx_ban %i %s ^"ReasonYou suck.^""czasip)
            
log_to_file("logs.log""Zbanowany na ip-%s"name)
        }
        else{
            
server_cmd("amx_ban %i %s ^"ReasonYou suck.^""czasauthid)
            
log_to_file("logs.log","Zbanowany na steam-%s"name)
        }
    }
    return 
PLUGIN_CONTINUE



fysiks 07-20-2011 15:46

Re: Ban the worst player and map end
 
There is no reason to ban by IP since everybody should have a SteamID, BTW. Also, you probably need quotes around the SteamID.

Exolent[jNr] 07-20-2011 15:56

Re: Ban the worst player and map end
 
PHP Code:

public plugin_end()
{
    new 
players[32], pnumplayerfrags[33]
    
get_players(playerspnum)
    
    for(new 
0pnumi++)
    {
        
player players[i]
        
        if(!
zaklad[player])
            
players[i--] = players[--pnum]
        else
            
frags[player] = get_user_frags(player)
    }
    
    if(
pnum 2) return
    
    
SortCustom1D(playerspnum"SortWorstPlayers"fragssizeof(frags))
    
    new 
stop 0
    player 
players[0]
    while(++
stop pnum && frags[players[stop]] == frags[player]) { }
    
    if(
stop == pnum) return
    
    for(new 
0stopi++)
    {
        
player players[i]
        
        
get_user_name(playerfragscharsmax(frags))
        
        
server_cmd("amx_ban %d #%d ^"ReasonYou suck.^""czasget_user_userid(player))
        
log_to_file("logs.log""Zbanowany na %s"frags)
    }
}

public 
SortWorstPlayers(player1player2players[], frags[], frag_size)
{
    return 
clamp((frags[player1] - frags[player2]), -11)



lis_16 07-20-2011 15:58

Re: Ban the worst player and map end
 
Ban code works fine, because i ban when play left game while bet too, so server_cmd works fine. Maybe something is wrong in loops? But it look fine too.

Exolent[jNr] 07-20-2011 16:03

Re: Ban the worst player and map end
 
Did you try mine?

lis_16 07-20-2011 16:06

Re: Ban the worst player and map end
 
Look at posted time, you posted while I was posting. Will try and give you an anserw.

lis_16 07-20-2011 17:03

Re: Ban the worst player and map end
 
I added some logs.

If I comment:

PHP Code:

if(pnum 2) return 

it should ban, but it didn't. I added log after ban comand and log is in log file but ban don't work and it's strange. I tried your's ban command and mine (that work on client_disconnect) with no result.

[PUPPETS] Scooter 07-20-2011 17:18

Re: Ban the worst player and map end
 
Which version of Amxbans are you using?

lis_16 07-21-2011 11:36

Re: Ban the worst player and map end
 
AMXBans 5.0 YoMama/Lux & lan

[PUPPETS] Scooter 07-21-2011 12:21

Re: Ban the worst player and map end
 
Try:
Code:

player = players[i]
new steam_id[34], dumb[130]
get_user_authid(id, steam_id, 33)
format(dumb, 129, "amx_ban %d %s Reason: You suck.", czas, steam_id)
log_to_file("logs.log", "%s", dumb)
server_cmd("%s", dumb)

Using Amxbans 5.0, you don't need quotation marks around the reason.
So take a look into your logfile, if ban command is written right way.


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

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