Raised This Month: $ Target: $400
 0% 

Getting data from from MySQL row


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
raa
Senior Member
Join Date: Oct 2005
Old 01-11-2007 , 21:58   Re: Writing to csstats (CS 1.6)
Reply With Quote #2

ok so maybe writing to csstats.dat isn't the best to go about it.

What about reading directly from the MySQL database that is already storing the info?

this is what I have so far and it isn't working at all. Please forgive any obvious mistakes, I was trying anything.

Code:
public read_user_stats(id){
	//if(get_cvar_num("sv_ranks")==0)
	//return PLUGIN_HANDLED
	
	//log_amx("[sqlStats] save_user_stats")
	log_amx("[sqlStats] Reading %i Players", g_iMutationcount)
	
	// sql connect
	g_dbc = dbi_connect(g_host,g_user,g_pass,g_dbname,g_error,MAX_NAME_LENGTH)
	
	if (g_dbc == SQL_FAILED)
		log_amx("[sqlStats] SQL Connection Failed")
	else{
		// process all queries
		result = dbi_query(g_dbc,"SELECT * FROM statstable WHERE kills ='%s'")
		new user_kills[32]
		for (new i=1;i<=dbi_num_rows(result);i++) {
			dbi_nextrow(result)
			dbi_result(result,"kills",user_kills[id])
			console_print(id,"Value: %s",user_kills)
			
		}
		dbi_free_result(result)
		return PLUGIN_HANDLED
	}
	// sql close	
	dbi_close(g_dbc)
	
	//reset mutationcount
	g_iMutationcount = 0
	return 0
}
Table is "statstable", Database row is "kills".
__________________
raa is offline
 



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 22:30.


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