Raised This Month: $ Target: $400
 0% 

Not adding people to the SQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blackops7799
Senior Member
Join Date: May 2006
Old 10-28-2006 , 23:09   Not adding people to the SQL
Reply With Quote #1

This is not adding new users to the sql.

http://ampaste.net/4529
blackops7799 is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 10-29-2006 , 00:57   Re: Not adding people to the SQL
Reply With Quote #2

Quote:
Originally Posted by blackops7799 View Post
This is not adding new users to the sql.

http://ampaste.net/4529
1. make sure you have a 'users' table with fields 'level', 'xp', 'JobID' in existence:
Code:
format(query,255, "SELECT level,xp,JobID FROM users WHERE steamid='%s'", authid);
2.
Code:
#
                level[id] = dbi_field(result,1);
#
                xp[id] = dbi_field(result,2);
#
                JobID3[id] = dbi_field(result,3);
#
                indatabase = 1;
if you don't have those arrays (level, xp, JobID3) declared, you will be screwed.
3.
Code:
#
format(query,255,"INSERT INTO users (steamid,level,xp) VALUES('%s', '1', '0')",authid);
#
                format(query,255,"INSERT INTO money (steamid,money) VALUES('%s', '500')",authid)
#
                format(query,255,"INSERT INTO powerup (steamid,regen,vampire,armor,ammoregen) VALUES('%s', '0', '0', '0', '0')",authid)
#
                dbi_query(dbc,"%s",query);
from the extensive work I've done with small and SQL, it seems that
Code:
format(query,255,"INSERT INTO powerup (steamid,regen,vampire,armor,ammoregen) VALUES('%s', '0', '0', '0', '0')",authid)
will be the ONLY code allocated to "query," multiple queries requires a little more work.

I don't see this code working correctly but maybe there is something I'm not seeing - drop me a line or re-post here and maybe you can clarify more for me.

From reading this code, my conclusion is that you are telling the computer the user is NOT in the database
Code:
new indatabase = 0
, then you get their info. then check the SQL database for their info., then if they DON'T exist, I guess it adds them. A description for what this SHOULD do would be helpful.

Also, make sure your database actually exists and the computer is connecting to it. (Check your logs and/or add debug messages to your code).

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!

Last edited by slmclarengt; 10-29-2006 at 01:01.
slmclarengt is offline
blackops7799
Senior Member
Join Date: May 2006
Old 10-29-2006 , 01:44   Re: Not adding people to the SQL
Reply With Quote #3

Quote:
Originally Posted by slmclarengt View Post
From reading this code, my conclusion is that you are telling the computer the user is NOT in the database
Code:
new indatabase = 0
, then you get their info. then check the SQL database for their info., then if they DON'T exist, I guess it adds them. A description for what this SHOULD do would be helpful.

Also, make sure your database actually exists and the computer is connecting to it. (Check your logs and/or add debug messages to your code).

Slmclarengt
Yes, that is exactly ehat im trying to do. I know its connecting to the database because if i make the code like this

Code:
public client_putinserver(id)
{
	moanon[id] = 0
	if(dbc == SQL_FAILED)
	{
		return PLUGIN_HANDLED;
	}
	
	new indatabase = 0
	new query[256], authid[32], model[33];
	get_user_authid(id,authid,31);
	get_user_info(id,"model",model,32);
	format(query,255, "SELECT level,xp,JobID FROM users WHERE steamid='%s'", authid);
	result = dbi_query(dbc,"%s",query);
	if(dbi_nextrow(result) > 0)
	{
		level[id] = dbi_field(result,1);
		xp[id] = dbi_field(result,2);
		JobID3[id] = dbi_field(result,3);
		indatabase = 1;
	}
	dbi_free_result(result);
	if(indatabase == 0)
	{
		format(query,255,"INSERT INTO users (steamid,level,xp) VALUES('%s', '1', '0')",authid);
		dbi_query(dbc,"%s",query);
		insertmoney(id)
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED;
}
public insertmoney(id) {
	new indatabase = 0
	new query[256], authid[32], model[33];
	get_user_authid(id,authid,31);
	get_user_info(id,"model",model,32);
	format(query,255, "SELECT money FROM money WHERE steamid='%s'", authid);
	result = dbi_query(dbc,"%s",query);
	if(dbi_nextrow(result) > 0)
	{
		indatabase = 1;
	}
	dbi_free_result(result);
	if(indatabase == 0)
	{
		format(query,255,"INSERT INTO money (steamid,money) VALUES('%s', '500')",authid)
		dbi_query(dbc,"%s",query);
		insertpowerup(id)
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED;
}
public insertpowerup(id) {
	new indatabase = 0
	new query[256], authid[32], model[33];
	get_user_authid(id,authid,31);
	get_user_info(id,"model",model,32);
	format(query,255, "SELECT regen,vampire,armor,ammoregen FROM powerup WHERE steamid='%s'", authid);
	result = dbi_query(dbc,"%s",query);
	if(dbi_nextrow(result) > 0)
	{
		indatabase = 1;
	}
	dbi_free_result(result);
	if(indatabase == 0)
	{
		format(query,255,"INSERT INTO powerup (steamid,regen,vampire,armor,ammoregen) VALUES('%s', '0', '0', '0', '0')",authid)
		dbi_query(dbc,"%s",query);
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED;
}
it works fine... So ill just keep it like this for now.
blackops7799 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:52.


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