AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL_FreeHandle problem (https://forums.alliedmods.net/showthread.php?t=140965)

reinert 10-18-2010 07:36

SQL_FreeHandle problem
 
Hey, why I'm getting this error in my logs:
PHP Code:

L 10/18/2010 15:24:26: [AMXXDisplaying debug trace (plugin "report.amxx")
L 10/18/2010 15:24:26: [AMXXRun time error 10native error (native "SQL_FreeHandle")
L 10/18/2010 15:24:26: [AMXX]    [0report.sma::plugin_end (line 111

here is the plugin code:

PHP Code:

#include <amxmodx>
#include <sqlx>


#define PLUGINNAME    "Report system"
#define VERSION        "1.0"
#define AUTHOR        "addinol"
#define table           "amx_report_log"

new Handle:g_SqlX
new Handle:g_SqlConnection
new g_error[512]

new 
bool:alreadyreported[33] = false;

public 
plugin_init()
{
    
register_plugin(PLUGINNAMEVERSIONAUTHOR)

    
register_clcmd("say""hook_say")
    
register_clcmd("say_team""hook_say")
    
set_task(0.1"check_sql")
    return 
PLUGIN_CONTINUE 
}

public 
check_sql()
{

    new 
host[64], user[64], pass[64], db[64],errorcode

    get_cvar_string
("amx_sql_host"host63)
    
get_cvar_string("amx_sql_user"user63)
    
get_cvar_string("amx_sql_pass"pass63)
    
get_cvar_string("amx_sql_db"db63)

    
g_SqlX SQL_MakeDbTuple(hostuserpassdb)
    
g_SqlConnection SQL_Connect(g_SqlX,errorcode,g_error,511);
  
    if (!
g_SqlConnection) {
        return 
log_amx("Chat log SQL: Could not connect to SQL database.")
    }
    
    new 
query_create[1001]
    
format(query_create,1000,"CREATE TABLE IF NOT EXISTS `%s`(`id` int(11) NOT NULL auto_increment,`name` varchar(100) NOT NULL default '',`authid` varchar(100) NOT NULL default '',`ip` varchar(100) NOT NULL default ''`date` date NOT NULL default '0000-00-00',`time` time NOT NULL default '00:00:00', `message` text NOT NULL,PRIMARY KEY  (`id`));",table)
    
SQL_ThreadQuery(g_SqlX,"QueryHandle",query_create)
    
    return 
PLUGIN_CONTINUE 
}

public 
hook_say(id
{
    if(
is_user_bot(id)){
    return 
PLUGIN_CONTINUE;
    }
    
    static 
datestr[11]
    new 
authid[16],name[32],ip[16],timestr[9]
    new 
cmd[9
    
    if(!
is_user_connected(id)){
    return 
PLUGIN_CONTINUE;
    }
    
    
read_argv(0,cmd,8
    
    new 
message[192
    
read_args(message,191)
    
remove_quotes(message)
    if(
containi(message"/report")){
        if(
alreadyreported[id]){
        
client_print(idprint_chat"Reportinti galima tik kas 5 minutes")
    }else{
        
get_user_authid(id,authid,15)  
        
get_user_name(id,name,31)
        
get_user_ip(idip151)
         
        
get_time("%Y.%m.%d"datestr10)
        
get_time("%H:%M:%S"timestr8)
    
        new 
query[1001]
        
format(query,1000,"INSERT into %s (name,authid,ip,date,time,message) values ('%s','%s','%s','%s','%s','%s')",table,name,authid,ip,datestr,timestr,message
        
SQL_ThreadQuery(g_SqlX,"QueryHandle",query)
        
alreadyreported[id] = true;
        
set_task(300.0"report0"id)
    }
    return 
PLUGIN_HANDLED_MAIN;
    }
    return 
PLUGIN_HANDLED;


public 
report0(id){
    
alreadyreported[id] = false;
}

public 
QueryHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    return 
log_amx("Chat log SQL: Could not connect to SQL database.")
    
    else if(
FailState == TQUERY_QUERY_FAILED)
        return 
log_amx("Chat log SQL: Query failed")
        
    if(
Errcode)
        return 
log_amx("Chat log SQL: Error on query: %s",Error)
    
    return 
PLUGIN_CONTINUE
}

public 
plugin_end() 

    
SQL_FreeHandle(g_SqlConnection)
    return;



Exolent[jNr] 10-18-2010 17:07

Re: SQL_FreeHandle problem
 
PHP Code:

public plugin_end() 

    
SQL_FreeHandle(g_SqlConnection)
    return;


:arrow:
PHP Code:

public plugin_end() 

    if (
g_SqlConnectionSQL_FreeHandle(g_SqlConnection)
    return;




All times are GMT -4. The time now is 10:25.

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