Raised This Month: $ Target: $400
 0% 

SQL error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
andrzN
Senior Member
Join Date: Jan 2010
Location: Bodø / Norway
Old 05-02-2013 , 17:53   SQL error
Reply With Quote #1

Hi! I have a plugin that counts the total amount of jumps a player performs,
and save all the data on each individual player in a sql database. It works fine,
however I get this error spammed in the serverlog.

Quote:
L 05/02/2013 - 22:44:19: [Jumps.amxx] SQL Error (qh_Player_Save): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0', '')' at line 1
L 05/02/2013 - 22:44:19: [Jumps.amxx] SQL Error (qh_Player_Save): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1
L 05/02/2013 - 22:44:19: [Jumps.amxx] SQL Error (qh_Player_Save): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'D','1686', '')' at line 1
L 05/02/2013 - 239:50: [Jumps.amxx] SQL Error (qh_Player_Save): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '61', '')' at line 1
L 05/02/2013 - 239:50: [Jumps.amxx] SQL Error (qh_Player_Save): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'D','1582', '')' at line 1
The plugin worked for a long time without any errors, and now without any
changes being done in the script it spams this error out of nowhere.
Do any of you guys have a clue what the problem could be?

Here is the plugin code:

PHP Code:
#include < amxmodx >
#include < colorchat >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < sqlx >

native pm_get_user_points(id);
native pm_get_user_totalpoints(id);
native pm_add_user_points(idiPoints);

stock pm_add_user_point(clientpoint)
{
    return 
pm_add_user_points(clientpm_get_user_points(client) + iPoints);
    return 
pm_add_user_points(clientpm_get_user_totalpoints(client) + iPoints);
}

new 
vOrigin[33][3];
new 
vOldOrigin[33][2][3]; // 0 = Crouched ; 1 = Normal

new const Prefix[] = "[Gpark]";

new 
vJump[33];
new 
vJumpRank[256][32];

#define _GenerateUserId() (_pg_last_userid = (_pg_last_userid+1)%0xffffff)
new _pg_last_userid

#define _Set(%1,%2) %1|=1<<%2
#define _UnSet(%1,%2) %1&=~(1<<%2)
#define _Is(%1,%2) (%1&1<<%2)
new _in_server_authed_loaded

new g_max_players
new g_p_local_userid[33
new 
Handle:g_sql_tuple
new g_sql_ready

public plugin_init(  )
{
    
register_plugin"Jump Counter""0.1.3""anderseN" )
    
register_clcmd"say /jumps""Jumpinfo" )
    
    
g_max_players get_maxplayers()
    
set_task(0.2"sql_init")
    
    
RegisterHamHam_Player_Jump"player""Ham_Player_Jump_Post");
}

public 
sql_init()
{
    
g_sql_tuple SQL_MakeStdTuple()
    new 
type[15]
    
get_cvar_string("amx_sql_type"typesizeof(type)-1)
    
SQL_SetAffinity(type)
    new 
cache[] = "CREATE TABLE IF NOT EXISTS `jump_count` (`authid` VARCHAR(35) PRIMARY KEY, `name` VARCHAR(64), `jumps` INTEGER, `title` VARCHAR(64));"
    
SQL_ThreadQuery(g_sql_tuple"qh_create_table"cache)
}

public 
qh_create_table(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState)
    {
        
log_amx("SQL Error (qh_create_table): %s"Error)
        
set_task(10.0"sql_init")
        return
    }
    
    
g_sql_ready true
    
for(new id=1id<=g_max_playersid++)
        if(
_Is(_in_serverid) && _Is(_authedid))
            
Player_Load(id)
}

public 
client_connect(id)
{
    
g_p_local_userid[id] = _GenerateUserId()
    
_UnSet(_authedid)
}

public 
client_authorized(id)
{
    if(
is_user_bot(id) || is_user_hltv(id))
        return
    
_Set(_authedid)
    if(
_Is(_in_serverid))
        
Player_Load(id)
}

public 
client_putinserver(id)
{
    
vJump[id] = 0

    _Set
(_in_serverid)
    if(
_Is(_authedid))
        
Player_Load(id)
}

public 
client_disconnect(id)
{
    
Player_Save(id)
    
_UnSet(_authedid)
    
_UnSet(_in_serverid)
    
_UnSet(_loadedid)
}

public 
Player_Load(id)
{
    if(!
g_sql_ready)
        return   
    new 
authid[36]
    
get_user_authid(idauthidsizeof(authid)-1)
    new 
cache[128]
    
formatex(cachesizeof(cache)-1"SELECT `jumps` FROM `jump_count` WHERE `authid`='%s';"authid)
    new 
data[2]
    
data[0] = id
    data
[1] = g_p_local_userid[id]
    
SQL_ThreadQuery(g_sql_tuple"qh_Player_Load"cachedata2)
}

public 
qh_Player_Load(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    new 
id Data[0]
    if(!
_Is(_in_serverid) || g_p_local_userid[id] != Data[1])
        return
    if(
FailState)
    {
        
log_amx("SQL Error (qh_Player_Load): %s"Error)
        
set_task(10.0"Player_Load"id)
        return
    }
    
_Set(_loadedid)
    if(!
SQL_MoreResults(Query))
        return
    
vJump[id] = SQL_ReadResult(Query0)
}

public 
Player_Save(id)
{
    if(!
_Is(_loadedid)) 
        return
    new 
authid[36]
    
get_user_authid(idauthidsizeof(authid)-1)
    new 
name[36]
    
get_user_name(idnamesizeof(name)-1)
    new 
cache[128]
     
    
formatex(cachesizeof(cache)-1"REPLACE INTO `jump_count` (`authid`,`name`,`jumps`,`title`)VALUES('%s', '%s','%d', '%s');"authidnamevJump[id], vJumpRank[id])
    
SQL_ThreadQuery(g_sql_tuple"qh_Player_Save"cache)
}

public 
qh_Player_Save(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(
FailState)
    {
        
log_amx("SQL Error (qh_Player_Save): %s"Error)
        return
    }
}  

public 
Jumpinfoid )
{
    if( 
vJump[id] <= 200 
         {
             
vJumpRank[id] = "New Player";
         }
         else if( 
200 vJump[id] <= 500 )
         {
             
vJumpRank[id] = "Newbie";
         }
         else if( 
500 vJump[id] <= 1000 )
         {
             
vJumpRank[id] = "Beginner";
         }
         else if( 
1000 vJump[id] <= 2000 
         {
             
vJumpRank[id] = "Good Luck";
         }
    else if( 
2000 vJump[id] <= 5000 
         {
             
vJumpRank[id] = "Getting Started";
         }
         else if( 
5000 vJump[id] <= 10000 
         {
             
vJumpRank[id] = "Active Jumper";
         }
    else if( 
10000 vJump[id] <= 15000 
         {
             
vJumpRank[id] = "Moderate Jumper";
         }
    else if( 
15000 vJump[id] <= 25000 
         {
             
vJumpRank[id] = "Pro Jumper";
         }
    else if( 
25000 vJump[id] <= 50000 
         {
             
vJumpRank[id] = "Insane Jumper";
         }
    else if( 
50000 vJump[id] <= 100000 
         {
             
vJumpRank[id] = "1337 Jumper";
         }
    else if( 
100000 vJump[id] <= 200000 
         {
             
vJumpRank[id] = "Skilled Jumper";
         }
    else if( 
200000 vJump[id] <= 300000 
         {
             
vJumpRank[id] = "Going Crazy";
         }
    else if( 
300000 vJump[id] <= 500000 
         {
             
vJumpRank[id] = "Rabbit";
         }
    else if( 
500000 vJump[id] <= 1000000 
         {
             
vJumpRank[id] = "Veteran";
         }
    else if( 
1000000 vJump[id] ) 
         {
             
vJumpRank[id] = "Official Gamepark Legend";
         }
    new 
szName33 ];
    
get_user_nameidszName32 );
        
    Print(
0"^1%s^3 has a total of^1 %d^3 Jumps. Rank:^4 %s^3 !"szNamevJump[id], vJumpRank[id])
}  

public 
Ham_Player_Jump_Post( const id )
{
    if( ( 
pevidpev_flags ) & FL_ONGROUND ) && !( pevidpev_oldbuttons ) & IN_JUMP ) )
    {
        if (
get_user_team(id) == 1)
    {
        static 
Distance[2];
        
get_user_originidvOriginid ] );
        
        
Distance[1] = get_distancevOldOrigin[id][1], vOrigin[id] );
        if( 
Distance[1] >= 50 )
        {
            
vJumpid ]++
            new 
szName33 ];
            
get_user_nameidszName32 );
        
            if(
vJump[id] == 200)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 200^3 jumps! Rank^4 Newbie^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
            }
            else if(
vJump[id] == 500)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 500^3 jumps! Rank^4 Beginner^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
            }
            else if(
vJump[id] == 1000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 1000^3 jumps! Rank^4 Good Luck^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
            }
            else if(
vJump[id] == 2000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 2000^3 jumps! Rank^4 Getting Started^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
            }
            else if(
vJump[id] == 5000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 5000^3 jumps! Rank^4 Active Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 80^3 points for reaching^4 5,000^3 jumps !")
        
pm_add_user_points(id80);
            }
            else if(
vJump[id] == 10000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 10,000^3 jumps! Rank^4 Moderate Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
           Print(
id"You received^4 80^3 points for reaching^4 10,000^3 jumps !")
        
pm_add_user_points(id80);
            }
            else if(
vJump[id] == 15000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 15,000^3 jumps! Rank^4 Pro Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 80^3 points for reaching^4 15,000^3 jumps !")
        
pm_add_user_points(id80);
            }
            else if(
vJump[id] == 25000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 25,000^3 jumps! Rank^4 Insane Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 80^3 points for reaching^4 25,000^3 jumps !")
        
pm_add_user_points(id80);
            }
            else if(
vJump[id] == 50000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 50,000^3 jumps! Rank^4 1337 Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 80^3 points for reaching^4 50,000^3 jumps !")
        
pm_add_user_points(id80);
            }
            else if(
vJump[id] == 100000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 100,000^3 jumps! Rank^4 Skilled Jumper^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 100^3 points for reaching^4 100,000^3 jumps !")
        
pm_add_user_points(id100);
            }
            else if(
vJump[id] == 200000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 200,000^3 jumps! Rank^4 Going Crazy^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 100^3 points for reaching^4 200,000^3 jumps !")
        
pm_add_user_points(id100);
            }
            else if(
vJump[id] == 300000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 300,000^3 jumps! Rank^4 Rabbit^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 100^3 points for reaching^4 300,000^3 jumps !")
        
pm_add_user_points(id100);
            }
            else if(
vJump[id] == 500000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 500,000^3 jumps! Rank^4 Veteran^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 100^3 points for reaching^4 500,000^3 jumps !")
        
pm_add_user_points(id100);
            }
            else if(
vJump[id] == 1000000)
            {
                Print(
0"Congratulations to^1 %s^3 who has reached^1 1,000,000^3 jumps! Rank^4 Official Gamepark Legend^3 !"szName)
                
client_cmd(0"spk buttons/button9.waw");
        Print(
id"You received^4 500^3 points for reaching^4 1,000,000^3 jumps !")
        
pm_add_user_points(id500);
            }
            
            
vOldOriginid ][ ][ ] = vOriginid ][ ];
            
vOldOriginid ][ ][ ] = vOriginid ][ ];
            
vOldOriginid ][ ][ ] = vOriginid ][ ];
        }
        else
        {
            
set_hudmessage(2550255, -1.00.7400.82.0)
            
show_hudmessage(id"[Jumps] Do not jump at the same spot")
        }        
    }
    }
    return 
HAM_IGNORED;
}

Print(
id, const szMessage[], any:...) 

    static 
szBuffer[192]; 
    
vformat(szBuffercharsmax(szBuffer), szMessage3); 

    
ColorChat(idGREY"^04%s^03 %s"PrefixszBuffer); 

}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
__________________
Owner of Gamepark.se - Scandinavian Community

#1 - HideNSeek [Easyblocks] IP: eb.gamepark.se
#2 - HideNSeek [Noblocks] IP: nb.gamepark.se
#3 - HideNSeek [HNS Training Blocks] IP: training.gamepark.se
andrzN is offline
Send a message via MSN to andrzN
 



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:55.


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