Raised This Month: $ Target: $400
 0% 

Can anyone change this sql plugin to non sql.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 11-15-2010 , 05:41   Can anyone change this sql plugin to non sql.
Reply With Quote #1

Here is the sql version, I dont know how to change to be a non sql version.
Can sb help me to change it.
I want save the stuff in amxmodx\data.
Code:
//-----------------// Funname
new fun_name[33][32];
new steam_id[33][35];
//-----------------// Funname


// Funname System
register_cvar("amx_funname","0");						// Enable/Disable Funname System
register_cvar("amx_funname_save","0");					// Enable/Disable Funname Save System


// Funname System
setting_funname				= get_cvar_num("amx_funname");				// Enable/Disable Funname System
setting_funname_save		= get_cvar_num("amx_funname_save");			// Enable/Disable Funname Save System


register_clcmd("say","allchat")






public client_putinserver(id) 
{
	if(setting_sqlserver_open && setting_funname && setting_funname_save)
	{
		sql_load_data(id)
	}
	return PLUGIN_CONTINUE
}


public sql_load_data(id)
{
	new NetAddr[32]
	get_user_ip(id, NetAddr, 31, 1)

	new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
	new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
	
	get_user_authid(id, steam_id[id], 34)
	if(equal(steam_id[id],"VALVE_ID_LAN"))
	{
		new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE name_ip= '%s';",hkcs_tab,NetAddr);
		SQL_Execute(hkcs_query_acc)
			
		if(SQL_NumResults(hkcs_query_acc))
		{
			SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30)		// Set Funname
		}
		else
		if(!SQL_NumResults(hkcs_query_acc))
		{
			new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`name_ip`,`name`) VALUES ('%s','%s');",hkcs_tab,NetAddr,default_name);
			SQL_Execute(query)			// Set Up Funaname
			format(fun_name[id], 12, "%s",default_name)
		}
	}
	else
	{
		new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE steam_id= '%s';",hkcs_tab,steam_id[id]);
		SQL_Execute(hkcs_query_acc)
			
		if(SQL_NumResults(hkcs_query_acc))
		{
			SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30)
		}
		else
		if(!SQL_NumResults(hkcs_query_acc))
		{
			new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`steam_id`,`name_ip`) VALUES ('%s','%s');",hkcs_tab,steam_id[id],NetAddr);
			SQL_Execute(query)
			format(fun_name[id], 12, "%s",default_name)
		}
	}
	SQL_FreeHandle(hkcs_sql)
}


public allchat(id)
{
	if(!is_user_connected(id))
	{
		return PLUGIN_HANDLED
	}
	new system_msg[150]	
	new all_msg[200]
	new name[32]
	get_user_name(id, name, 31)
	
	read_args(all_msg, 200)
	remove_quotes(all_msg)

	replace_all(all_msg, 200, "%", "%") 
	format(all_msg, 200, " %s", all_msg)			// Get Say Message

	new check_name[32]
	new send_msg[192],get_msg[256]
	format(get_msg, 200, "%s", all_msg)			// Copy Message
	strtok(get_msg[1],check_name,30,send_msg,170,' ')	// Separate Message

	if(containi(check_name,"/fun_name") != -1 && setting_funname)
	{
		if(!send_msg[0])
		{
			format(system_msg, 149, "%s^x04 Funname must long than 1 word", setting_plugin_name)
			client_color(id, id, system_msg)
			return PLUGIN_HANDLED
		}
		new fun_len = strlen(send_msg);
		if(fun_len > 15)
		{
			format(system_msg, 149, "%s^x04 Funname must less then 15 words", setting_plugin_name)
			client_color(id, id, system_msg)
			return PLUGIN_HANDLED
		}
		format(fun_name[id], 30, "%s",send_msg)
		format(system_msg, 149, "%s^x04 Funname change to^x03 %s", setting_plugin_name,fun_name[id])
		client_color(id, id, system_msg)
		if(setting_sqlserver_open && setting_funname_save)
		{
			if(equal(steam_id[id],"VALVE_ID_LAN"))
			{
				new NetAddr[32]
				get_user_ip(id, NetAddr, 31, 1)
				new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
				new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
				new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s' WHERE ( `name_ip` = '%s');",hkcs_tab,fun_name[id],NetAddr)
				SQL_Execute(query)
				SQL_FreeHandle(hkcs_sql)
			}
			else
			{
				new NetAddr[32]
				get_user_ip(id, NetAddr, 31, 1)
				new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
				new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
				new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s',`name_ip` = '%s' WHERE ( `steam_id` = '%s');",hkcs_tab,fun_name[id],NetAddr,steam_id[id])
				SQL_Execute(query)
				SQL_FreeHandle(hkcs_sql)
			}
		}
		return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-15-2010 , 07:40   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #2

You can save stuff in amxmodx\data and still use sql. Enable sqlite module in your modules.ini instead of mysql and set sql host to "127.0.0.1".
__________________
Impossible is Nothing
Sylwester is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 11-15-2010 , 08:18   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #3

But my server is work without use mysql
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-15-2010 , 10:33   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #4

You don't need mysql server, just do what I said and it should work.
__________________
Impossible is Nothing
Sylwester is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-15-2010 , 11:41   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #5

Quote:
Originally Posted by Sylwester View Post
You don't need mysql server, just do what I said and it should work.
without mysql server and just enable the sqlite in module.ini ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 11-15-2010 , 11:32   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #6

Don't forget to also set the affinity to sqlite if you want to use it.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 11-15-2010 , 11:45   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #7

To work in sqlite , you only need modify / add a line . (SQL_SetAffinity)
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-15-2010 , 11:54   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #8

and where i can edit the data file ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-15-2010 , 12:18   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #9

You don't need to set affinity if you enable only sqlite module. Since you are not using mysql server then you can disable mysql module. The only thing you need to do is to set sql host in your plugin to "127.0.0.1" (database user and database password don't matter).
Data is saved in: addons\amxmodx\data\sqlite3\<database_name>.s q3
You can edit it using sqlite database editor. For example this one: http://sqlitebrowser.sourceforge.net/
__________________
Impossible is Nothing
Sylwester is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 11-15-2010 , 21:09   Re: Can anyone change this sql plugin to non sql.
Reply With Quote #10

Thx Sylwester,
work fine !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Reply


Thread Tools
Display Modes

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 11:19.


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