Raised This Month: $ Target: $400
 0% 

Solved sql save problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 05-03-2021 , 17:46   Re: sql save problem
Reply With Quote #5

You forgot to check for symbols in the name that will give error in the querie

Quote:
Originally Posted by LondoN View Post
Code:
public client_putinserver(id)
{
	if(is_user_bot(id) || is_user_hltv(id))
		return;

	get_user_name(id, g_iPlayersInfo[id][Name], charsmax(g_iPlayersInfo[][Name]));
	get_user_ip(id, g_iPlayersInfo[id][Address], charsmax(g_iPlayersInfo[][Address]), 1);
	get_user_authid(id, g_iPlayersInfo[id][AuthID], charsmax(g_iPlayersInfo[][AuthID]));


	new query[512];
	formatex(query, charsmax(query), "SELECT * FROM %s WHERE name='%s', g_szONPlayer_Table, g_iPlayersInfo[id][Name]);
	
	new data[1];
	data[0] = id;

	SQL_ThreadQuery(g_SqlTuple, "Load_Data", query, data, sizeof data);
}

public Load_Data(FailState, Handle:Query, szError[], ErrorCode, szData[], iSize)
{
	if(FailState || ErrorCode)
		log_amx("sql.log", szError);

	new id = szData[0];

	if(SQL_NumResults(Query) < 1)
	{
		new query[512];
		formatex(query, charsmax(query), "INSERT INTO `%s` (`name`, `ip`, `steamid`, `frags`, `deaths`) VALUES ('%s', '%s', '%s', '0', '0');",
				g_szONPlayerTable, g_iPlayersInfo[id][Name], g_iPlayersInfo[id][Address], g_iPlayersInfo[id][AuthID]);
		SQL_ThreadQuery(g_SqlTuple, "Data_Ignore", query);
	}
	else
	{
		g_iPlayersInfo[id][Frags] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "frags"));
		g_iPlayersInfo[id][Deaths] = SQL_ReadResult(Query, SQL_FieldNameToNum(Query, "deaths"));
	}
}

public Data_Ignore(FailState, Handle:Query, szError[], ErrorCode, szData[], iSize)
{
	if(FailState || ErrorCode)
		log_amx("sql.log", szError);

	SQL_FreeHandle(Query);
}

public client_disconnect(id)
{
	if(is_user_bot(id) || is_user_hltv(id))
		return;

	new query[512];
	formatex(query, charsmax(query), "UPDATE `ip`, `steamid`, `frags`, `deaths` SET '%s', '%s', '%d', '%d' WHERE `name`='%s');",
		g_iPlayersInfo[id][Address], g_iPlayersInfo[id][AuthID], g_iPlayersInfo[id][Frags], g_iPlayersInfo[id][Deaths], g_iPlayersInfo[id][Name]);
	SQL_ThreadQuery(g_SqlTuple, "Data_Ignore", query);
}
try whis way
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 05-03-2021 at 17:46.
iceeedr is offline
Send a message via Skype™ to iceeedr
 



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 02:39.


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