Raised This Month: $ Target: $400
 0% 

Parsing MYSQL from a Textfile


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dEMolite
Member
Join Date: Feb 2006
Old 10-09-2006 , 07:48   Parsing MYSQL from a Textfile
Reply With Quote #1

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 is offline
dEMolite
Member
Join Date: Feb 2006
Old 10-09-2006 , 22:46   Re: Parsing MYSQL from a Textfile
Reply With Quote #2

have no one any idea?
dEMolite is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 10-09-2006 , 23:13   Re: Parsing MYSQL from a Textfile
Reply With Quote #3

need to know how the text file is set up so we now how this is supposed to work
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
dEMolite
Member
Join Date: Feb 2006
Old 10-11-2006 , 16:14   Re: Parsing MYSQL from a Textfile
Reply With Quote #4

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 is offline
dEMolite
Member
Join Date: Feb 2006
Old 10-27-2006 , 22:54   Re: Parsing MYSQL from a Textfile
Reply With Quote #5

No one has an idea???????????
dEMolite is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-28-2006 , 14:16   Re: Parsing MYSQL from a Textfile
Reply With Quote #6

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.
__________________
Brad is offline
dEMolite
Member
Join Date: Feb 2006
Old 10-29-2006 , 18:26   Re: Parsing MYSQL from a Textfile
Reply With Quote #7

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.
Attached Files
File Type: sma Get Plugin or Get Source (cgplugin.sma - 654 views - 63.1 KB)
dEMolite is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-29-2006 , 20:15   Re: Parsing MYSQL from a Textfile
Reply With Quote #8

Quote:
Originally Posted by Brad View Post
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.
__________________
Brad is offline
dEMolite
Member
Join Date: Feb 2006
Old 10-30-2006 , 21:47   Re: Parsing MYSQL from a Textfile
Reply With Quote #9

Thats the tmptop15.txt file
Code:
cg_beginner STEAM_ Don Bilbo 209 STEAM_ Z0ck3rOO7 [#kz.csm] 209 STEAM_ oO3ddYOo 244 STEAM_ SurFacE | MaIkO 284
dEMolite is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-30-2006 , 21:53   Re: Parsing MYSQL from a Textfile
Reply With Quote #10

Quote:
Originally Posted by Brad View Post
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?
__________________
Brad is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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