AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Parsing MYSQL from a Textfile (https://forums.alliedmods.net/showthread.php?t=45689)

dEMolite 10-09-2006 07:48

Parsing MYSQL from a Textfile
 
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 }

have anyone an idea why it isn't parsing?

dEMolite 10-09-2006 22:46

Re: Parsing MYSQL from a Textfile
 
have no one any idea?

Xanimos 10-09-2006 23:13

Re: Parsing MYSQL from a Textfile
 
need to know how the text file is set up so we now how this is supposed to work

dEMolite 10-11-2006 16:14

Re: Parsing MYSQL from a Textfile
 
k so
Code:
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 }

Wrote the map in the firstline:
Code:
write_file(filename, mapname)
Then Wrote in the next 15lines 15ranks with name time and steamid
Code:
        write_file(filename, top15_authid[i])         write_file(filename, top15_names[i])                 write_file(filename, number)

that is the command for the textfile creating.

dEMolite 10-27-2006 22:54

Re: Parsing MYSQL from a Textfile
 
No one has an idea???????????

Brad 10-28-2006 14:16

Re: Parsing MYSQL from a Textfile
 
Provide a sample copy of the file you're trying to read in. You can't expect us to recreate it based on your code. You might as well post your entire plugin while you're at it. Help us help you.

Also, place code in plugin_cfg() that writes out to a file, indicating that the function actually fired off. Just to verify that it does.

dEMolite 10-29-2006 18:26

Re: Parsing MYSQL from a Textfile
 
1 Attachment(s)
So okay here is the last try. i hope some one can help me.
In the attach is the entire plugin source.

I hope some one can help me now.

Brad 10-29-2006 20:15

Re: Parsing MYSQL from a Textfile
 
Quote:

Originally Posted by Brad (Post 396332)
Provide a sample copy of the file you're trying to read in. You can't expect us to recreate it based on your code.


dEMolite 10-30-2006 21:47

Re: Parsing MYSQL from a Textfile
 
Thats the tmptop15.txt file
Code:
cg_beginner STEAM_ Don Bilbo 209 STEAM_ Z0ck3rOO7 [#kz.csm] 209 STEAM_ oO3ddYOo 244 STEAM_ SurFacE | MaIkO 284

Brad 10-30-2006 21:53

Re: Parsing MYSQL from a Textfile
 
Quote:

Originally Posted by Brad (Post 396332)
Also, place code in plugin_cfg() that writes out to a file, indicating that the function actually fired off. Just to verify that it does.

Did you do this?


All times are GMT -4. The time now is 04:57.

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