AlliedModders

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

Backstabnoob 03-15-2011 14:37

SQLx problem... again.
 
This is completely illogical. I've been creating plugins this way many times and never experienced this error before (happens only on some servers):

Code:

L 03/15/2011 - 18:33:33: [AMXX] Plugin ("propojeni.amxx") is setting itself as failed.
L 03/15/2011 - 18:33:33: [AMXX] Plugin says: Unknown database 'amx'
L 03/15/2011 - 18:33:33: [AMXX] Displaying debug trace (plugin "propojeni.amxx")
L 03/15/2011 - 18:33:33: [AMXX] Run time error 1: forced exit
L 03/15/2011 - 18:33:33: [AMXX]    [0] propojeni.sma::LoadHandle (line 82)

That's pretty wrong. amx_sql_db cvar IS 'amxbans', but it somehow wants to take 'amx' only. Happens not always, only after some restarts.

The code is here:

PHP Code:


/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <sqlx>

#define PLUGIN "Webacc connect"
#define VERSION "1.0"
#define AUTHOR "IdiotStrike"

new Handle:g_SqlTuple
new g_SqlQuery[512]


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("webreg""cmdHook"0"Pouziti: <ID na webu> <heslo> [napr: webreg 15 tomas2] ^nID na webu zjistite tak, ze se prihlasite a podivate se na horni listu pod citace. Tam jej najdete.")

    new 
Host[64],User[64],Pass[64],Db[64]
    
    
get_cvar_string("amx_sql_host",Host,63)
    
get_cvar_string("amx_sql_user",User,63)
    
get_cvar_string("amx_sql_pass",Pass,63)
    
get_cvar_string("amx_sql_db",Db,63)
    
    
g_SqlTuple SQL_MakeDbTuple(HostUserPassDb)
}


    

public 
cmdHook(id)
{
    new 
authid[36]
    
get_user_authid(idauthid35)
    
    if(
equali(authid"STEAM_ID_PENDING"))
    {    
        
client_print(idprint_console"Nebylo vam prirazeno steamID. Prikaz neuspesny.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
buffer[34], buffer1[34]
    new 
pass_cache[128]
    new 
webid_cache[10]
    new 
webid
    
    read_argv
(1webid_cache9)
    
read_argv(2pass_cache127)
    
    if(!
webid_cache[0] || !pass_cache[0])
    {
        
client_print(idprint_console"Pouziti: <ID na webu> <heslo> [napr: webreg 15 tomas2] ^nID na webu zjistite tak, ze se prihlasite a podivate se na horni listu pod citace. Tam jej najdete.")
        return 
PLUGIN_HANDLED
    
}
    
    
remove_quotes(webid_cache)
    
webid str_to_num(webid_cache)
    
remove_quotes(webid_cache)
    
md5(pass_cachebuffer1)
    
md5(buffer1buffer)
    
    
//client_print(id, print_console, "Vlozene: webid=%d, pass=%s, pass_md5=%s", webid, pass_cache, buffer)
    
    
format(g_SqlQuery511"SELECT user_id FROM fusion_users WHERE user_id=%d AND user_password='%s'"webidbuffer)
    
    
    
    new 
Data[2]
    
Data[0] = id
    Data
[1] = webid
    
    SQL_ThreadQuery
(g_SqlTuple"LoadHandle"g_SqlQueryData2)

    return 
PLUGIN_HANDLED
    
}

public 
LoadHandle(FailStateHandle:QueryError[], ErrcodeData[], DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        return 
set_fail_state(Error)
        
    else if(
FailState == TQUERY_QUERY_FAILED)
        return 
set_fail_state(Error)
    
    if(
Errcode)
        return 
set_fail_state(Error)
    
    new 
id Data[0]
    new 
webid Data[1]
    
    if(
SQL_NumResults(Query) > 0)
    {
            
        new 
authid[36]
        
get_user_authid(idauthid35)
        
        
format(g_SqlQuery511"INSERT INTO amx_fusionconnect VALUES ('%d', '%s') ON DUPLICATE KEY UPDATE id=%d, auth='%s'"webidauthidwebidauthid)

        
SQL_ThreadQuery(g_SqlTuple"DummyHandler"g_SqlQuery)
    
        
client_print(idprint_console"Nyni byl vas ucet propojen s webovym uctem. Spravovat jej muzete v uzivatelskem nastaveni na webu www.traxxzone.cz.")
    
    }
    else
        
client_print(idprint_console"Vlozili jste nespravna data. Prosim, zkontrolujte je.")
        
    return 
PLUGIN_HANDLED
    
}


public 
DummyHandler(FailStateHandle:QueryError[], ErrcodeData[], DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
        return 
set_fail_state(Error)
    else if(
FailState == TQUERY_QUERY_FAILED)
        return 
set_fail_state(Error)
    
    if(
Errcode)
        return 
set_fail_state(Error)
    
    
    return 
PLUGIN_CONTINUE
}

public 
plugin_end()
    
SQL_FreeHandle(g_SqlTuple

Anybody knows what the hell is wrong?

minimiller 03-15-2011 16:49

Re: SQLx problem... again.
 
i used to get that alot
i gave up using sql.cfg in the end and just hard coded everything into the plugin

Exolent[jNr] 03-15-2011 16:56

Re: SQLx problem... again.
 
It's because the sql.cfg file has not been executed yet.
Either create the tuple in plugin_cfg(), or force exec the config before you get the cvar values.

Backstabnoob 03-16-2011 08:49

Re: SQLx problem... again.
 
Thank you, plugin_cfg() possibly works (at least it seems like that atm). I'll post again if there will be problems after deeper testing.

Thanks for help.


All times are GMT -4. The time now is 14:41.

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