Hi Guys, i have a littel problem now.
I saved my top15 in to a temp textfile for loading them into the mysql on the nextmap. But now i get the problem on the plugin_cfg. The Problem is the Plugin_cfg function is not reading the textfile and parsing it to the mysql db.
Code:
public plugin_cfg(){
set_cvar_num("sv_restartround",1)
new pathname[128]
get_cvar_string("amx_climbtimer_path",pathname,127)
new filename[128]
format(filename, 127, "%s/tmptop15.txt", pathname)
if(!file_exists(filename)) return
if(dbc == SQL_FAILED) return //prolly should try to retry later...
new numentries, i
new authids[15][36], names[15][36], times[15], mapname[128]
result = dbi_query(dbc,"SELECT * FROM top15 WHERE map='%s' ORDER BY time",mapname)
if(result != RESULT_OK) return //prolly should try to retry later...
dbi_free_result(result)
new num = dbi_num_rows(result)
if(num > 15) num = 15
for(i = 0; i < num; i++) {
dbi_nextrow(result)
dbi_result(result, "steamid", authids[i],35)
dbi_result(result, "jumper", names[i],31)
times[i] = dbi_result(result, "time")
}
numentries = i
static data[192], len, authid[36], name[32], stime[10], dtime, a
new file = fopen(filename,"rt")
while(!feof(file)) {
len = fgets(file, data,191)-1
if(len < 0) continue
if(data[len] == '^n') data[len--] = 0
parse(data, authid,35, name,31, stime,9)
dtime = str_to_num(stime)
for(i = 0; i < numentries; i++) {
if(dtime > times[i]) continue
if(numentries < 15) numentries++
for(a = numentries-1; a > i; a--) {
format(authids[a],35, authids[a-1])
format(names[a],31, names[a-1])
times[a] = times[a-1]
}
format(authids[i],35, authid)
format(names[i],31, name)
times[i] = dtime
break
}
}
fclose(file)
result = dbi_query(dbc,"DELETE FROM top15 WHERE map='%s'",mapname)
for(i = 0; i < numentries; i++) {
result = dbi_query(dbc,"INSERT INTO top15 (map,steamid,jumper,time) VALUES ('%s','%s','%s',%d)",mapname,authids[i],names[i],times[i])
}
server_print("[Debug] Saved %d entries into database!",numentries)
}
public save_tmptop15() {
new pathname[128]
get_cvar_string("top15temp_path",pathname,127)
new mapname[128]
get_mapname(mapname,127)
new filename[128]
format(filename, 127, "%s/tmptop15.txt", pathname)
if( file_exists(filename) )
delete_file(filename)
write_file(filename, mapname) // save the map name in the firstline
for( new i = 0; i < 15; i++ ) {
if( top15_times[i] == CT_MAX_TIME )
return
new number[192]
num_to_str(top15_times[i],number,191)
write_file(filename, top15_authid[i])
write_file(filename, top15_names[i])
write_file(filename, number)
}
return
}