Raised This Month: $ Target: $400
 0% 

(help)stats top knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
11naracus
Member
Join Date: Mar 2012
Old 07-02-2014 , 09:59   (help)stats top knife
Reply With Quote #1

I need this orderly ranking please


PHP Code:
#include <amxmodx>
#include <colorchat>
#include <nvault>
#include <amxmisc>

#define MAXENTRIES 1000

new gKnifeKills[33], gKnifeDeaths[33], gKnifeHeadShots[33], gConnect[33], g_cvarRecDir[64];

public 
plugin_init() {
    
register_plugin"KnifeTop""1.0""Tolsty" );
    
register_event("DeathMsg""eventDeathMsg""a""1>0");
    
g_cvar register_cvar("knifetop_topsave""1");
    
register_clcmd("say /knifereset","top_reset",ADMIN_BAN);
    
register_clcmd("say /ranksok","kniferank");
    
register_clcmd("say /topsok","topten_show");
    
register_clcmd("say /knife","info");
    new 
DataDir[64];
    
get_datadir(DataDir63);
    
format(RecDir63"%s/vault"DataDir);

}

public 
client_connect(plr) {
    if(!
get_pcvar_num(g_cvar) ) 
        return 
    
gConnect[plr] = true;
    
update(plr)
    
set_task(15.0,"info"plr);
}
public 
client_disconnect(plr) {
    
gConnect[plr] = false;
}
public 
update(plr) {
    if(!
get_pcvar_num(g_cvar) ) 
        return 
PLUGIN_HANDLED
    
static knifetop[128], szid[32];
    
format(knifetop128"%s/knifetop.vault",RecDir);
    if(
get_pcvar_num(g_cvar) == 1)
        
get_user_name(plr,szid,32);
    else if(
get_pcvar_num(g_cvar) == )
        
get_user_ip(plr,szid,32);
    else if(
get_pcvar_num(g_cvar) == )
        
get_user_authid(plr,szid,32);
    if( 
file_exists(knifetop)) {
        new 
szvault[64];
        
format(szvault,64,"knifetop");
        
        new 
vault nvault_open(szvault);
        if(
vault != -1) {
            new 
szkey[4];
            for(new 
i=1;i<=MAXENTRIES;i++) {
                new 
szreturn[128];
                
format(szkey,4,"%d",i);
                
nvault_get(vault,szkey,szreturn,128);
                new 
arg1[16], arg2[16], arg3[8],  arg4[8],  arg5[8];
                if(
parse(szreturnarg116arg216arg38arg48arg58) != && equal(szid,arg1) ) {
                    
gKnifeKills[plr] = str_to_num(arg3)
                    
gKnifeDeaths[plr] = str_to_num(arg4)
                    
gKnifeHeadShots[plr] = str_to_num(arg5)
                    if( !
gConnect[plr] )
                        
ColorChat(plr RED"[SOK] Estas %s en soktop, con %d muertes !"szkeygKnifeKills[plr]);
                }
            }
            
nvault_close(vault);
        }
    } 
    if(
gConnect[plr])
        
gConnect[plr] = false
    
return PLUGIN_HANDLED

}
public 
info(plr) {
    
ColorChat(plr RED"[SOK] Escribe /topsok para ver el rank de fakas, o /ranksok para tu posicion");
    
}
public 
kniferank(plr) {
    
update(plr)
}
public 
eventDeathMsg() {
    if(!
get_pcvar_num(g_cvar) ) 
        return 
PLUGIN_HANDLED
    
static killerkiller read_data);
    static 
victimvictim read_data) ;      
    static 
szweapon[5];
    
read_dataszweapon );
      
    if ( ( 
szweapon] == 'k' ) && ( szweapon] == 'f' ) ) {   
        
gKnifeKills[killer]++ 
        
gKnifeDeaths[victim]++ 
        if ( 
read_data) ) {
            
gKnifeHeadShots[killer]++
        }   
        
topten_update(killer)
        
topten_update(victim)        
    } 
    return 
PLUGIN_HANDLED
}

public 
topten_updateplr ) {
    new 
TopTenVault[64];
    
format(TopTenVault64"knifetop");
    
    new 
vault nvault_open(TopTenVault);

    if(
vault != -1) {

        new 
szkey[8];
        new 
szid[32];
        new 
szname[32];
        new 
cur_place;
        new 
new_place;

        if(
get_pcvar_num(g_cvar) == 1)
            
get_user_name(plr,szid,32);
        else if(
get_pcvar_num(g_cvar) == )
            
get_user_ip(plr,szid,32);
        else if(
get_pcvar_num(g_cvar) == )
            
get_user_authid(plr,szid,32);

        
get_user_name(plr,szname,32);

        for(new 
i=1;i<=MAXENTRIES;i++) {
            new 
szreturn[128], arg1[32] ;
            
format(szkey,8,"%d",i);
            
nvault_get(vault,szkey,szreturn,128);
            if(
parse(szreturnarg132) != && equal(szid,arg1)) {
                
cur_place i;
                break;
            }
        }
        for(new 
i=1;i<=MAXENTRIES;i++) {
            new 
szreturn[256], arg1[32], arg3[32];
            
format(szkey,8,"%d",i);
            
nvault_get(vault,szkey,szreturn,256);
            if (
cur_place == 1) {
                
new_place 1;
                break;
            }
            else if (
cur_place != && cur_place i) {
                
new_place 0;
                break;
            }
            else if(
parse(szreturnarg132) == 0) {
                
new_place i;
                break;
            }
            else if(
gKnifeKills[plr]  > str_to_num(arg3) ) {
                
new_place i;
                break;
            }
        }
        if(
cur_place == && new_place <= 1000 && new_place 0) {
            if(
new_place 1000) {
                new 
sztemp[128], sztempkey[8];
                
                for(new 
i=10;i>new_place;i--) {
                    
format(sztempkey,8,"%d",i-1);
                    
nvault_get(vault,sztempkey,sztemp,128);
                    if(!
equal(sztemp,"")) {
                        
format(sztempkey,8,"%d",i);
                        
nvault_pset(vault,sztempkey,sztemp);
                    }
                }
            }
            
client_print(0print_chat"[SOK] %s now is %d topsok with %d gKnifeKills!"sznamenew_placegKnifeKills[plr]);
            
            new 
sznew[512];
            
format(szkey,8,"%d",new_place);
            
format(sznew,512,"^"%s^" ^"%s^" ^"%d^" ^"%d^" ^"%d^" "szidsznamegKnifeKills[plr], gKnifeDeaths[plr], gKnifeHeadShots[plr]);    
            
nvault_pset(vault,szkey,sznew);
        }
        else if(
cur_place == new_place && cur_place 0) {
                     
                new 
sznew[512], szkey[8];
                new 
szreturn[128], arg1[32], arg3[32], arg5[32];
                
format(szkey,8,"%d",cur_place);
                
nvault_get(vault,szkey,szreturn,128);
                    
                if(
parse(szreturnarg132arg332) != 0) {
                    
format(sznew,512,"^"%s^" ^"%s^" ^"%d^" ^"%d^" ^"%d^" "szidszname,  gKnifeKills[plr] > str_to_num(arg3) ? gKnifeKills[plr] : str_to_num(arg3), gKnifeDeaths[plr], gKnifeHeadShots[plr] > str_to_num(arg5) ? gKnifeHeadShots[plr] : str_to_num(arg5));    
                    
nvault_pset(vault,szkey,sznew);
                }
        }
        else if (
new_place cur_place && new_place 0) {
            new 
sznew[512];
            new 
szreturn[128], arg1[32], arg2[32];
            
format(szkey,8,"%d",cur_place);
            
nvault_get(vault,szkey,szreturn,128);
            if(
parse(szreturn,arg1,32,arg2,32) != 0) {
                
format(sznew,512,"^"%s^" ^"%s^" ^"%d^" ^"%d^" ^"%d^" "szidszname,  gKnifeKills[plr] , gKnifeDeaths[plr], gKnifeHeadShots[plr]);
                for(new 
i=cur_place;i>=new_place;i--) {
                    new 
szreturn[128], arg1[32], arg2[32];
                    
format(szkey,8,"%d",i);
                    
nvault_get(vault,szkey,szreturn,128);
                    
                    if(
parse(szreturn,arg1,32,arg2,32) != 0){
                        new 
sztemp [128], sztempkey[8];
                        
format(sztempkey,8,"%d",i-1);
                        
nvault_get(vault,sztempkey,sztemp,128);
                        
                        if(!
equal(sztemp,"")) {
                            
format(sztempkey,8,"%d",i);
                            
nvault_pset(vault,sztempkey,sztemp);
                        }
                    }
                    else break;
                }
                
                
client_print(0print_chat"............" );
                
nvault_pset(vault,szkey,sznew);
            }
        }
        
nvault_close(vault);
    }
}





public 
topten_showplr) {
    
    
    static 
knifetop[128];
    
    
format(knifetop128"%s/knifetop.vault",RecDir);
    
    if( 
file_exists(knifetop)) {
        
        new 
motd[2500];
        new 
szvault[64];

        
format(szvault,64,"knifetop");
        
        new 
vault nvault_open(szvault);
        if(
vault != -1) {
        
            
add(motd,2500,"<html><style>");
            
add(motd,2500,"body { background-color:#000000; }");
            
add(motd,2500,".tabel { color:#FFFFFF; }");
            
add(motd,2500,".header { background-color:#00BFFF; color:#000000;}");
            
add(motd,2500,"</style><body>");
            
add(motd,2500,"<br><br><table align=center border=1 width=90% class=tabel>");
            
add(motd,2500,"<tr><td class=header width=5% align=center><strong>Rank</strong></td><td class=header width=24%><strong>Name</strong></td><td class=header width=24%><strong>KnifeKills</strong></td><td class=header width=24%><strong>KnifeDeaths</strong></td><td class=header width=24%><strong>KnifeHeadShots</strong></td></tr>");
            new 
szkey[4];
            for(new 
i=1;i<=10;i++) {
                new 
szreturn[128];
                
format(szkey,4,"%d",i);
                
nvault_get(vault,szkey,szreturn,128);
                
                new 
arg1[16], arg2[16], arg3[8],  arg4[8],  arg5[8];
                if(
parse(szreturnarg115arg215arg37arg47arg57) != 0) {
                    while (
containi(arg2"<") != -1replace(arg263"<""&lt")
                    while (
containi(arg2">") != -1replace(arg263">""&gt")
                    
add(motd,2048,"<tr><td>");
                    
add(motd,2048,szkey);
                    
add(motd,2048,"</td><td>");
                    
add(motd,2500,arg2);
                    
add(motd,2500,"</td><td>");
                    
add(motd,2500,arg3);
                    
add(motd,2500,"</td><td>");
                    
add(motd,2500,arg4);
                    
add(motd,2500,"</td><td>");
                    
add(motd,2500,arg5);
                    
add(motd,2500,"</td><td>");
                    
add(motd,2500,"</td></tr>");
                    
                    
                }
            }
            
            
nvault_close(vault);
            
            
add(motd,2500,"</table></body></html>");
            
show_motd(plr ,motd,"KnifeTop");
        }
    } else {
        
ColorChat(plr RED"No records in topfile");
    }
}

public 
top_reset(plr,level,cid) {
    if(!
cmd_access(plr,level,cid,0)) {
        return 
PLUGIN_HANDLED;
    }
    
    new 
name[32];
    
get_user_name(plrname32);
    
    
    static 
knifetop[128];
    
format(knifetop128"%s/knifetop.vault",RecDir);
    if( 
file_exists(knifetop)) {
        
delete_file(knifetop);
        
ColorChat(0GREEN"[SOK] ADMIN %s reseted the KnifeTop top"name);
        }
    return 
PLUGIN_HANDLED;
    

11naracus is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-02-2014 , 16:32   Re: (help)stats top knife
Reply With Quote #2

...
What's wrong with it now?
__________________
Black Rose is offline
11naracus
Member
Join Date: Mar 2012
Old 07-03-2014 , 09:31   Re: (help)stats top knife
Reply With Quote #3

rank 1 to coco 21kill
rank 2 Ju4n 4 kill
rank 5 dqt 11kill

should be well

rank 1 to coco 21kill
rank 2 dqt 11kill
etc

please solution
11naracus is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-03-2014 , 09:33   Re: (help)stats top knife
Reply With Quote #4

its ok, the top makes the % of all

ej : KinifeKills | KinifeDeaths | Kinife HeadShoot

it makes the % and then it show the rank
Porta0123 is offline
11naracus
Member
Join Date: Mar 2012
Old 07-03-2014 , 11:20   Re: (help)stats top knife
Reply With Quote #5

FIXME please the plugin.

I do not understand :S
11naracus is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:58.


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