Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Delete ProKreedz REC"
#define VERSION "1.0"
#define AUTHOR "alliedmods"
new mapname[100]
new bool: poseduje
new bool: time_delete
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd( "kz_delete_rec", "uradjeno" )
}
public uradjeno(id)
{
if( !is_user_admin( id ) )
{
client_print( id, print_console, "You must be an admin to reset someone's record." )
return PLUGIN_HANDLED
}
poseduje = false;
new dir = open_dir("/addons/amxmodx/configs/kz/top15/", mapname, sizeof(mapname)-1)
new file, fname[100]
new readdata[128]
new ptime[20],psteamid[40],pname[32],pdate[20]
new szarg1[32]
read_argv(1,szarg1,31)
remove_quotes(szarg1);
if( !( containi(szarg1, "STEAM") != -1 || strlen( szarg1 ) > 3 ) )
{
client_print( id, print_console, "Moras STEAM:ID ili Nick duzi od 3 slova !" )
return PLUGIN_HANDLED;
}
if(equal(szarg1,"1TIME_DELETE1"))
{
time_delete = true
}
if (dir)
{
while (next_file(dir, mapname, sizeof(mapname)-1))
{
formatex( fname, 99, "/addons/amxmodx/configs/kz/top15/%s", mapname )
file = fopen( fname, "rt" );
if(file)
{
new TempFile[128]; get_configsdir(TempFile, charsmax(TempFile))
new const FileName[] = "tempfile.ini"
format(TempFile, charsmax(TempFile), "/addons/amxmodx/configs/kz/top15/%s", FileName)
new InputFilePointer = fopen(TempFile, "wt")
if(InputFilePointer)
{
//client_print( id, print_console, "MapName^t^t^t^t^t^t^t^t- NICK^t^t^t^t- SteamID^n" ) //ponavlja se na svako brisanje rekorda, nije nesto potrebno
while(!feof(file))
{
fgets(file, readdata, charsmax(readdata))
parse(readdata, ptime, charsmax(ptime), psteamid, charsmax(psteamid), pname, charsmax(pname), pdate, charsmax(pdate))
if((containi(pname, szarg1) != -1 || containi( psteamid, szarg1 ) != -1) && !time_delete )
{
poseduje = true;
client_print( id, print_console, "%s - %s - %s - %s", mapname, pname, ptime, psteamid )
continue;
}
else if( ( containi( ptime, "2." ) != -1 || containi( ptime, "1." ) != -1 || containi( ptime, "0." ) != -1 ) && time_delete && ( strlen( ptime ) == 4 ) )
{
poseduje = true;
time_delete = false
client_print( id, print_console, "TIME_DEL: %s - %s - %s - %s", mapname, pname, ptime, psteamid )
continue;
}
else
fputs(InputFilePointer, readdata)
}
}
fclose(InputFilePointer)
fclose(file)
delete_file(fname)
rename_file(TempFile, fname, 1)
}
}
}
close_dir(dir)
if( !poseduje )
client_print( id, print_console, "[KZ] There was ZERO targets to delete." )
return PLUGIN_CONTINUE;
}