Raised This Month: $ Target: $400
 0% 

Problem with SQLx


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
huntex
Junior Member
Join Date: Jul 2013
Old 09-04-2013 , 09:40   Problem with SQLx
Reply With Quote #1

Hello. I have a problem. I writing a plugin for CS 1.6, which check messages and nicknames for advertising (regular expressions). RegEx patterns contains in the database and updating one time in the function plugin_cfg ().

There are about 10 tables.
7 contains patterns.
1 log table
2 ban tables

Most SQL read/write requests executes on log and ban tables (if plugin has found advertising at chat message).

Problem: This plugin makes random server's crash only after changelevel.

I tried various versions of amxmodx & server's builds, but it didn't help.

Code (reduced):
Code:
new Handle:SQL_Tuple
new Handle:SQL_Connection

public plugin_init()
{
	register_cvar("ar_sql_host", "127.0.0.1")
	// ...
}

public plugin_end()
{
	SQL_FreeHandle(SQL_Connection)
	SQL_FreeHandle(SQL_Tuple)
}

public plugin_cfg()
{
	get_cvar_string("ar_sql_host",host,30)
	// ...
	
	// SQL CONNECTION ========================================================================================
	SQL_Tuple = SQL_MakeDbTuple(host,user,pass,dbase)
	new err, error[256]
	SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
	
	if(SQL_Connection != Empty_Handle)
	{
		log_amx("[SQLx connect ok]")
	}
	else
	{
		log_amx("[SQLX sql error] %s ",error)
		pause("a")
	}
	// ========================================================================================================
	
	// loading regex pattenrs form tables (one time)
}

// sql function example
public sql_get_ucp_table_id(ucpid[9])
{
	if(SQL_Connection == Empty_Handle) return -1
	
	new Handle:query = SQL_PrepareQuery(SQL_Connection,"SELECT id FROM `%s` WHERE ucp = '%s'", ucps_table, ucpid)
	SQL_Execute(query)
	
	if (SQL_NumResults(query) > 0)
	{
		new result = SQL_ReadResult(query, 0)
		SQL_FreeHandle(query)
		
		return result
	}
	
	SQL_FreeHandle(query)
	return -1
}
huntex 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 19:08.


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