|
Senior Member
Join Date: Oct 2007
Location: Vilnius
|

12-26-2007
, 12:36
[REQ] Edit Top15/Pro15
|
#1
|
Hi, can someone edit my top/pro 15.
I wanna make web stats for it, but the reason is i dont know how to count..
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <engine_stocks>
#include <kz>
#define TOP_MAX_TIME 86400
#define PRO_MAX_TIME 86400
#define ACCESS_CLIMBER -1
new top15_authid[15][33]; // the 15 authids of the top 15 climbers
new top15_names[15][33]; // the 15 names of the top 15 climbers
new top15_times[15]; // the 15 times of the top 15 climbers
new top15_cps[15][33];
new top15_gcs[15][33];
new pro15_authid[15][33]; // the 15 authids of the top 15 climbers
new pro15_names[15][33]; // the 15 names of the top 15 climbers
new pro15_times[15]; // the 15 times of the top 15 climbers
new bool:used_unwanted[33];
new bool:used_cp[33];
new bool:used_gc[33];
new bool:started[33];
public plugin_init() {
register_plugin( "KzTop15 & KzPro15", "1.5", "J. Djinn & Isobold" );
register_clcmd( "say /top15", "show_top15_climbers", ADMIN_ALL, " - displays the top 15 climbers" );
register_clcmd( "say /top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say /top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say .top15", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say .top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say .top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team /top15", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team /top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team /top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team .top15", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team .top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say_team .top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "/top15", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "/top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "/top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( ".top15", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( ".top10", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( ".top", "show_top15_climbers", ACCESS_CLIMBER, " - displays the top 15 climbers" );
register_clcmd( "say /pro15", "show_pro15_climbers", ADMIN_ALL, " - displays the pro 15 climbers" );
register_clcmd( "say /pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say /pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say .pro15", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say .pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say .pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team /pro15", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team /pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team /pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team .pro15", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team .pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say_team .pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "/pro15", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "/pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "/pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( ".pro15", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( ".pro10", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( ".pro", "show_pro15_climbers", ACCESS_CLIMBER, " - displays the pro 15 climbers" );
register_clcmd( "say /cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say /check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say /checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say .cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say .check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say .checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team /cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team /check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team /checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team .cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team .check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say_team .checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "/cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "/check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "/checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( ".cp", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( ".check", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( ".checkpoint", "checkpoint", ACCESS_CLIMBER, " - sets checkpoint" );
register_clcmd( "say /tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say /tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say /gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say /gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say .tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say .tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say .gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say .gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team /tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team /tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team /gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team /gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team .tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team .tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team .gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say_team .gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "/tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "/tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "/gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "/gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( ".tele", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( ".tp", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( ".gocheck", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( ".gc", "gocheck", ACCESS_CLIMBER, " - used checkpoint" );
register_clcmd( "say /boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say /toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say .boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say .toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say_team /boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say_team /toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say_team .boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "say_team .toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "/boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "/toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( ".boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( ".toggle_boost", "used_unwanted_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this player in this climb" );
register_clcmd( "+hook", "used_hook_cmd", ACCESS_CLIMBER, " - disable top/pro 15 for this admin in this climb" );
register_cvar( "amx_climbtimer_path", "addons/amxmodx/climbtimer" );
register_cvar( "kz_tops_enabled", "1" );
register_cvar( "kz_rank_by_authid", "0" );
read_top15();
read_pro15();
}
public read_top15() {
for( new i = 0 ; i < 15; ++i) {
top15_names[i] = "";
top15_times[i] = TOP_MAX_TIME;
top15_authid[i] = "";
}
new pathname[128];
get_cvar_string("amx_climbtimer_path",pathname,127);
new mapname[64];
get_mapname(mapname,63);
new filename[128];
format(filename, 127, "%s/%s-top15.txt", pathname, mapname);
if( file_exists(filename) ) {
new number[192], line = 0, txtsize = 0;
for( new i = 0 ; i < 15; i++ ) {
if( (line=read_file(filename,line,top15_authid[i],32,txtsize))!=0 ) {
if( (line=read_file(filename,line,top15_names[i],32,txtsize))!=0 ) {
if( (line=read_file(filename,line,top15_cps[i],33,txtsize))!=0 ) {
if( (line=read_file(filename,line,top15_gcs[i],33,txtsize))!=0 ) {
if( (line=read_file(filename,line,number,191,txtsize))!=0 ) {
top15_times[i] = str_to_num( number );
}
}
}
}
}
else
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public read_pro15() {
for( new i = 0 ; i < 15; ++i) {
pro15_names[i] = "";
pro15_times[i] = PRO_MAX_TIME;
pro15_authid[i] = "";
}
new pathname[128];
get_cvar_string("amx_climbtimer_path",pathname,127);
new mapname[64];
get_mapname(mapname,63);
new filename[128];
format(filename, 127, "%s/%s-pro15.txt", pathname, mapname);
if( file_exists(filename) ) {
new number[192], line = 0, txtsize = 0;
for( new i = 0 ; i < 15; i++ ) {
if( (line=read_file(filename,line,pro15_authid[i],32,txtsize))!=0 ) {
if( (line=read_file(filename,line,pro15_names[i],32,txtsize))!=0 ) {
if( (line=read_file(filename,line,number,191,txtsize))!=0 ) {
pro15_times[i] = str_to_num( number );
}
}
}
else
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
public client_putinserver(id) {
started[id]=false;
used_unwanted[id]=false;
used_gc[id]=false;
used_cp[id]=false;
}
public client_disconnect(id) {
started[id]=false;
used_unwanted[id]=false;
used_gc[id]=false;
used_cp[id]=false;
}
public checkpoint(id) {
if(get_cvar_num("kz_enabled"))
{
new cp_continue = 1;
if(is_user_alive(id) && used_cp[id] == false)
{
if(IsPlayerPause(id) == 1)
{
cp_continue = 0;
}
if(get_cvar_num("kz_cp_price") && started[id] == true)
{
new money = cs_get_user_money(id);
if (!(get_cvar_num("kz_cp_price") <= money))
{
cp_continue = 0;
}
}
if(pev(id, pev_flags) & FL_ONGROUND) {
static entname[33];
pev(pev(id, pev_groundentity), pev_classname, entname, 32);
if(equal(entname, "func_door")) {
cp_continue = 0;
}
}
static vel[3];
pev(id, pev_velocity, vel);
if(vel[2] >= 0 && pev(id, pev_flags) & FL_ONGROUND && cp_continue == 1)
{
used_cp[id]=true;
}
}
}
}
public gocheck(id) {
if (used_cp[id] == true && used_gc[id] == false && used_unwanted[id] == false) {
used_gc[id]=true;
client_print(id, print_chat, "[KZ] Used checkpoint - Pro15 is disabled for you in this climb");
}
}
public used_unwanted_cmd(id) {
if ( used_unwanted[id] == false ) {
used_unwanted[id]=true;
client_print(id, print_chat, "[KZ] Pro15 and Top15 is disabled for you in this climb");
}
}
public used_hook_cmd(id) {
if (get_user_flags(id)&ADMIN_LEVEL_E) {
if ( used_unwanted[id] == false ) {
used_unwanted[id]=true;
client_print(id, print_chat, "[KZ] Pro15 and Top15 is disabled for you in this climb");
}
}
}
public client_PreThink(id) {
if (user_has_weapon(id, CSW_SCOUT) && used_unwanted[id] == false) {
used_unwanted_cmd(id);
}
}
public kz_StartClimb(id) {
used_gc[id]=false;
used_cp[id]=false;
if (user_has_weapon(id, CSW_SCOUT)) {
used_unwanted[id]=true;
client_print(id, print_chat, "[KZ] You must drop your scout and reset the timer to enable tops");
client_print(id, print_chat, "[KZ] Pro15 and Top15 is disabled for you");
} else {
used_unwanted[id]=false;
}
started[id]=true;
}
public save_top15() {
new pathname[128];
get_cvar_string("amx_climbtimer_path",pathname,127);
new mapname[64];
get_mapname(mapname,63);
new filename[128];
format(filename, 127, "%s/%s-top15.txt", pathname, mapname);
if( file_exists(filename) )
delete_file(filename);
for( new i = 0; i < 15; i++ ) {
if( top15_times[i] == TOP_MAX_TIME )
return;
new topnumber[192];
num_to_str(top15_times[i],topnumber,191);
write_file(filename, top15_authid[i]);
write_file(filename, top15_names[i]);
write_file(filename, top15_cps[i]);
write_file(filename, top15_gcs[i]);
write_file(filename, topnumber);
}
return;
}
public save_pro15() {
new pathname[128];
get_cvar_string("amx_climbtimer_path",pathname,127);
new mapname[64];
get_mapname(mapname,63);
new filename[128];
format(filename, 127, "%s/%s-pro15.txt", pathname, mapname);
if( file_exists(filename) )
delete_file(filename);
for( new i = 0; i < 15; i++ ) {
if( pro15_times[i] == PRO_MAX_TIME )
return;
new pronumber[192];
num_to_str(pro15_times[i],pronumber,191);
write_file(filename, pro15_authid[i]);
write_file(filename, pro15_names[i]);
write_file(filename, pronumber);
}
return;
}
public show_top15_climbers( id ) {
if( !get_cvar_num("kz_tops_enabled") )
return PLUGIN_HANDLED;
new buffer[2048];
new line[256];
new len = format( buffer, 2047, "<table cellspacing=0 rules=all border=2 frame=border>" );
len += format( buffer[len], 2047-len, "<tr><th> # <th> Nick <th> Climb time <th> Checkpoints <th> GoChecks" );
for(new i = 0; i < 15; ++i) {
if( top15_times[i] == TOP_MAX_TIME )
format(line, 255, "<tr><td> %d. <td> %s <td> %s <td> %s <td> %s", (i+1), "<---------->", "<not set>", "<0>", "<0>" );
else
format(line, 255, "<tr><td> %d. <td> %s <td> (%d:%02d) <td> %s <td> %s", (i+1), top15_names[i], (top15_times[i]/60) , (top15_times[i]%60), top15_cps[i], top15_gcs[i] );
len += format( buffer[len], 2047-len, line );
}
format(line, 255, "</table>" );
len += format( buffer[len], 2047-len, line );
show_motd( id, buffer, "Top 15 Climbers" );
return PLUGIN_HANDLED;
}
public show_pro15_climbers( id ) {
if( !get_cvar_num("kz_tops_enabled") )
return PLUGIN_HANDLED;
new buffer[2048];
new line[256];
new len = format( buffer, 2047, "<table cellspacing=0 rules=all border=2 frame=border>" );
len += format( buffer[len], 2047-len, "<tr><th> # <th> Nick <th> Climb time" );
for(new i = 0; i < 15; ++i) {
if( pro15_times[i] == PRO_MAX_TIME )
format(line, 255, "<tr><td> %d. <td> %s <td> %s", (i+1), "<---------->", "<not set>" );
else
format(line, 255, "<tr><td> %d. <td> %s <td> (%d:%02d)", (i+1), pro15_names[i], (pro15_times[i]/60) , (pro15_times[i]%60) );
len += format( buffer[len], 2047-len, line );
}
format(line, 255, "</table>" );
len += format( buffer[len], 2047-len, line );
show_motd( id, buffer, "Pro 15 Climbers" );
return PLUGIN_HANDLED;
}
public kz_FinishClimb(id, time, cp_count, gc_count) {
if ( used_unwanted[id] == false ) {
new topfirst, profirst, name[32];
get_user_name( id, name, 31 );
topfirst = check_top15(id, time, cp_count, gc_count);
profirst = check_pro15(id, time, cp_count, gc_count);
if ( topfirst && profirst )
client_print(0, print_chat, "[KZ] %s estableshed new map record in top & pro 15!", name);
else if ( topfirst || profirst )
client_print(0, print_chat, "[KZ] %s estableshed new map record in %s15!", name, (topfirst) ? "top" : "pro");
used_unwanted[id]=true;
}
used_gc[id]=true;
used_cp[id]=true;
started[id]=false;
}
public check_top15(id, time, cp_count, gc_count) {
new name[32];
get_user_name( id, name, 31 );
new authid[32];
if (get_cvar_num("kz_rank_by_authid") == 1) {
get_user_authid( id, authid ,31 );
} else {
get_user_name( id, authid, 31 );
}
if( time < top15_times[14] ) {
for( new i = 0; i < 15; i++ ) {
//new number[192];
//number = str_to_num( top15_gcs[i] );
if( time < top15_times[i] || (time == top15_times[i] && str_to_num( top15_gcs[i] ) > gc_count) ) {
new pos = i;
while( !equal( top15_authid[pos], authid ) && pos < 14 )
pos++ ;
for( new j = pos; j > i; j-- ) {
format( top15_authid[j], 32, top15_authid[j-1] );
format( top15_names[j], 32, top15_names[j-1] );
format( top15_cps[j], 32, top15_cps[j-1] );
format( top15_gcs[j], 32, top15_gcs[j-1] );
top15_times[j] = top15_times[j-1];
}
format( top15_authid[i], 32, authid );
format( top15_names[i], 32, name );
new cpnumber[33], gcnumber[33];
num_to_str(cp_count, cpnumber, 32);
num_to_str(gc_count, gcnumber, 32);
format( top15_cps[i], 32, cpnumber );
format( top15_gcs[i], 32, gcnumber );
top15_times[i] = time;
save_top15();
if ( i == 0 )
return 1;
return 0;
}
if( equal( top15_authid[i], authid ) )
return 0;
}
}
return 0;
}
public check_pro15(id, time, cp_count, gc_count) {
new name[32];
get_user_name( id, name, 31 );
new authid[32];
if (get_cvar_num("kz_rank_by_authid") == 1) {
get_user_authid( id, authid ,31 );
} else {
get_user_name( id, authid, 31 );
}
if( gc_count > 0 && cp_count > 0 ) {
client_print(id,print_chat,"[KZ] Sorry, but you used checkpoints. Your time will not be stored in Pro15.");
client_print(id,print_center,"[KZ] No Pro15 Entry. Checkpoint was used.");
return 0;
}
if( time < pro15_times[14] ) {
for( new i = 0; i < 15; i++ ) {
if( time < pro15_times[i] ) {
new pos = i;
while( !equal( pro15_authid[pos], authid ) && pos < 14 )
pos++ ;
for( new j = pos; j > i; j-- ) {
format( pro15_authid[j], 32, pro15_authid[j-1] );
format( pro15_names[j], 32, pro15_names[j-1] );
pro15_times[j] = pro15_times[j-1];
}
format( pro15_authid[i], 32, authid );
format( pro15_names[i], 32, name );
pro15_times[i] = time;
save_pro15();
if ( i == 0 )
return 1;
return 0;
}
if( equal( pro15_authid[i], authid ) )
return 0;
}
}
return 0;
}
.txt File Output
Code:
16
270
0
16
PaDlA^
125
Maniak
76
Stewie
53
15
406
Thanks.
|
|