#include <amxmodx>
#include <httpdl>
#pragma semicolon 1
// Start: Made these to easily update the plugin
#define MAX 10
new g_CommandList[MAX][] = {
"/wr",
"/cg",
"/fr",
"/sk",
"/lt",
"/ee",
"/ru",
"/no",
"/se",
"/dk"
};
new g_Record[MAX][] = {
"World record",
"German record",
"French record",
"Slovakian record",
"Lithuanian record",
"Estonian record",
"Russin record",
"Norwegian record",
"Swedish record",
"Danish record"
};
new g_DownloadUrl[MAX][] = {
"http://xtreme-jumps.eu/demos.txt",
"http://climbers-germany.de/demos.txt",
"http://kzfr.verygames.net/demos.txt",
"http://kzsk.sk/demos/demos.txt",
"http://kzlt.bentski.lt/demos.txt",
"http://kreedz.pri.ee/demos.txt",
"http://climbers.cpms.ru/records.txt",
"http://kz-scandinavia.com/demos_no.txt",
"http://kz-scandinavia.com/demos_se.txt",
"http://kz-scandinavia.com/demos_dk.txt"
};
// End
new g_flDemoData[MAX][256];
// Hudmessage related variables
new g_iColors[3] = { 255, 0, 255 };
new Float:g_fCoords[2] = { 0.01, 0.2 };
new g_CvarShowTime;
////////////////////////////////////////////////////////////////////////////////////////////////////
// Init
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init( )
{
register_plugin( "Kreedz Records", "1.4", "SchlumPF*" );
g_CvarShowTime = register_cvar( "kz_records_showtime", "5.0" );
register_clcmd( "say", "cmdHookSay" );
register_concmd( "kz_records_pos", "cmdChangePos" );
register_concmd( "kz_records_color", "cmdChangeColor" );
register_srvcmd( "kz_records_update", "cmdUpdate" );
new data[128];
get_localinfo( "amxx_datadir", data, sizeof data - 1 );
for( new i ; i < MAX ; i++ )
format( g_flDemoData[i], 255, "%s/demos_%s.txt", data, g_CommandList[i][1] );
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Hook say
////////////////////////////////////////////////////////////////////////////////////////////////////
public cmdHookSay( plr )
{
static message[512];
read_args( message, sizeof message - 1 );
remove_quotes( message );
if( message[0] )
{
for( new i ; i < MAX ; i++ )
{
if( equali( g_CommandList[i], message, 3 ) )
{
static list[3], mapname[64];
format( list, sizeof list - 1, "%s", message );
if( message[4] )
copy( mapname, sizeof mapname - 1, message[4] ); // maybe i should add some function which does show maps with similar names?!
else
get_mapname( mapname, sizeof mapname - 1 );
if( file_exists( g_flDemoData[i] ) )
{
static line, line_len;
static data[64];
static map[32], kreedzer[32], time_str[16], len, temp[32], ext[16];
new time_num;
while( ( line = read_file( g_flDemoData[i], line, data, sizeof data - 1, line_len ) ) != 0 )
{
parse( data, temp, sizeof temp - 1, time_str, sizeof time_str - 1, kreedzer, sizeof kreedzer - 1 );
if( containi( temp, "[" ) != -1 )
{
replace( temp, sizeof temp - 1, "[", " " );
replace( temp, sizeof temp - 1, "]", " " );
parse( temp, map, sizeof map - 1, ext, sizeof ext - 1 );
format( ext, sizeof ext - 1, "[%s]", ext );
}
else
{
map = temp;
ext = "";
}
if( equali( mapname, map ) )
{
if( !time_num )
{
time_num = str_to_num( time_str );
len = format( message, sizeof message - 1, "%s: %s (%d:%02d) %s", g_Record[i], kreedzer, ( time_num / 60 ), ( time_num % 60 ), ext );
}
else
{
time_num = str_to_num( time_str );
len += format( message[len], sizeof message - len - 1, " %s (%d:%02d) %s", kreedzer, ( time_num / 60 ), ( time_num % 60 ), ext );
}
}
}
if ( !time_num )
format( message, sizeof message - 1, "%s: Author: N/A", g_Record[i]);
}
else
{
format( message, sizeof message - 1, "Cannot view the record, please contact an admin!^n^"%s^" was not found", g_flDemoData[i] );
log_amx( "^"%s^" was not found!", g_flDemoData[i] );
}
/*
set_hudmessage( g_iColors[0], g_iColors[1], g_iColors[2], g_fCoords[0], g_fCoords[1], _, _, get_pcvar_float( g_CvarShowTime ), _, _, -1 );
show_hudmessage( plr, message );
*/
client_print(plr, print_chat, message);
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Updater
////////////////////////////////////////////////////////////////////////////////////////////////////
public cmdUpdate( )
{
for( new i ; i < MAX ; i++ )
download( g_DownloadUrl[i], g_flDemoData[i] );
server_print( "[kz_records.amxx] Updating %i files", MAX );
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Change the hudmessage
////////////////////////////////////////////////////////////////////////////////////////////////////
public cmdChangePos( plr )
{
if( ( get_user_flags( plr ) & ADMIN_KICK ) )
{
if( read_argc( ) == 3 )
{
new x_str[4], y_str[4];
read_argv( 1, x_str, sizeof y_str - 1 );
read_argv( 2, y_str, sizeof x_str - 1 );
new Float:x_num, Float:y_num;
x_num = str_to_float( x_str );
y_num = str_to_float( y_str );
if( -1.0 <= x_num <= 1.0 && -1.0 <= y_num <= 1.0 )
{
g_fCoords[0] = x_num;
g_fCoords[1] = y_num;
client_print( plr, print_console, "kz_records_pos changed to ^"%f %f^"", x_num, y_num );
}
else
client_print( plr, print_console, "<x> and <y> have to be between -1.0 and 1.0" );
}
else
client_print( plr, print_console, "Usage: kz_records_pos <x> <y>" );
}
else
client_print( plr, print_console, "* You have no access to this command" );
}
public cmdChangeColor( plr )
{
if( ( get_user_flags( plr ) & ADMIN_KICK ) )
{
if( read_argc( ) == 4 )
{
new r_str[4], g_str[4], b_str[4];
read_argv( 1, r_str, sizeof r_str - 1 );
read_argv( 2, g_str, sizeof g_str - 1 );
read_argv( 3, b_str, sizeof b_str - 1 );
new r_num, g_num, b_num;
r_num = str_to_num( r_str );
g_num = str_to_num( g_str );
b_num = str_to_num( b_str );
if( 0 <= r_num <= 255 && 0 <= g_num <= 255 && 0 <= b_num <= 255 )
{
g_iColors[0] = r_num;
g_iColors[1] = g_num;
g_iColors[2] = b_num;
client_print( plr, print_console, "kz_records_color changed to ^"%i %i %i^"", r_num, g_num, b_num );
}
else
client_print( plr, print_console, "<red>, <green> and <blue> have to be between 0 and 255" );
}
else
client_print( plr, print_console, "Usage: kz_records_color <red> <green> <blue>" );
}
else
client_print( plr, print_console, "* You have no access to this command" );
}