Raised This Month: $ Target: $400
 0% 

MYSQL Load Fail


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Schwabba
Senior Member
Join Date: Apr 2008
Old 10-24-2010 , 03:17   MYSQL Load Fail
Reply With Quote #1

Sometimes on my server mysql does'nt load the stats of the player and reset them.

PHP Code:
L 10/24/2010 09:03:50Start of error session.
L 10/24/2010 09:03:50Info (map "deathrun_flugsmellav2-b2") (file "addons/amxmodx/logs/error_20101024.log")
L 10/24/2010 09:03:50: [MySQLInvalid info tuple handle0
L 10
/24/2010 09:03:50: [AMXXDisplaying debug trace (plugin "drmanager.amxx")
L 10/24/2010 09:03:50: [AMXXRun time error 10native error (native "SQL_Connect")
L 10/24/2010 09:03:50: [AMXX]    [0drmanager.sma::Load_MySql (line 2540)
L 10/24/2010 09:03:50: [AMXX]    [1drmanager.sma::client_putinserver (line 2623
PHP Code:
public client_putinserver(id)
{
    
Load_MySql(id// This is line 2623
}

public 
Load_MySql(id)
{
    new 
ErrorCode,Handle:SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error)) // This is line 2540

    
if(g_SqlTuple == Empty_Handle)
    {
        
set_fail_state(g_Error)
    }

    new 
szSteamId[32], szTemp[512]
    
get_user_authid(idszSteamIdcharsmax(szSteamId))

    new 
Data[1]
    
Data[0] = id

    
//we will now select from the table `deathrun` where the steamid match
    
format(szTemp,charsmax(szTemp),"SELECT * FROM `deathrun` WHERE (`deathrun`.`steamid` = '%s')"szSteamId)
    
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
    
SQL_FreeHandle(SqlConnection)
}

public 
register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }
    new 
id
    id 
Data[0]
    if(
SQL_NumResults(Query) < 1
    {
        
//.if there are no results found

        
new szSteamId[32], szName[32]
        
get_user_authid(idszSteamIdcharsmax(szSteamId)) // get user's steamid
        
get_user_name(idszName31// get user's name

        //  if its still pending we can't do anything with it
        
if (equal(szSteamId,"ID_PENDING"))
        {
            return 
PLUGIN_HANDLED
        
}
            
        new 
szTemp[512]

        
// now we will insert the values into our table.
        
format(szTemp,charsmax(szTemp),"INSERT INTO `deathrun` ( `steamid` , `name` , `points` , `lives` , `frags` , `model`)VALUES ('%s','%s','0','0','0','0');",szSteamIdszName)
        
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
    } 
    else 
    {
    
// if there are results found
        
iPoints[id]         = SQL_ReadResult(Query2)
        
iLives[id]         = SQL_ReadResult(Query3)
        
iFrags[id]         = SQL_ReadResult(Query4)
        
iModel[id]         = SQL_ReadResult(Query5)
    }
    
Update_Rank(id)
    return 
PLUGIN_HANDLED
}

public 
Update_Rank(id// register cmd to this function
{
    for(new 
i<= maxplayersi++)
    {
        if(
is_user_connected(i))
        {
            
Save_MySql(i// Save all stats to get the correct rank
        
}
    }

    new 
Data[1]
    
Data[0] = id

    
new szTemp[512]
    
format(szTemp,charsmax(szTemp),"SELECT COUNT(*) FROM `deathrun` WHERE `points` >= %d"iPoints[id])
    
// Select the count where the points is matching or higher (Incase of equal points)
    
SQL_ThreadQuery(g_SqlTuple,"Sql_Rank",szTemp,Data,1)

    return 
PLUGIN_CONTINUE
}

public 
Sql_Rank(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
    }
    else if(
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("Load Query failed. [%d] %s"ErrcodeError)
    }

    new 
count 0
    count 
SQL_ReadResult(Query,0)
    if(
count == 0)
    
count 1

    
new id
    id 
Data[0]

    
iRank[id] = count

    
return PLUGIN_HANDLED


Last edited by Schwabba; 10-24-2010 at 03:19.
Schwabba 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 10:27.


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