Raised This Month: $ Target: $400
 0% 

Strange SQLite error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Master53
Veteran Member
Join Date: Dec 2009
Old 11-21-2010 , 13:16   Strange SQLite error
Reply With Quote #1

i have a strange sqlite error for hl2mp. i get an error which says "|DataBase| Sqlite: could not create (Items) Database tables" which is the set fail state of the plugin.

while i look in the code and theres nothing wrong and i dont see how its not actually working.

please note.
the database worked before the update which moved hl2mp to orange box insted of ep1 based.

i have a db logger and it does connect to the database which is set to sqlite.
Code:
L 11/21/2010 - 15:26:23: |DataBase| Connected to Sqlite Database. Version 1.4b
L 11/21/2010 - 15:26:23: |DataBase| SQLite: Creating (Player) Database tables
this is the db logs


PHP Code:
#define DBLOGFILE    "addons/sourcemod/logs/RolePlay_Logging/rp_database.log"

//Initation:
public OnPluginStart()
{
    
//Sql Setup
    
InitMySQL();
    
createdb();
}

public 
InitMySQL() {
    new 
String:error[512],String:SQLDriver[MAX_LINE_WIDTH];
    if(
GetConVarInt(SQLMANAGE) == 1) {
        new 
Handle:kv INVALID_HANDLE;
        
kv CreateKeyValues(""); 
        
KvSetString(kv"driver""sqlite"); 
        
KvSetString(kv"database""RoleplayDB");
        
hSQL SQL_ConnectCustom(kverrorsizeof(error), true);
        if(
hSQL==INVALID_HANDLE) {
            
LogToFileEx(DBLOGFILE,"|DataBase| Error %s"error);
        } else {
            
LogToFileEx(DBLOGFILE,"|DataBase| Connected to Sqlite Database. Version %s",SQLVERSION);
            
DBConnected true;
        } 
CloseHandle(kv);
        
SQLLite true;
    } else if(
GetConVarInt(SQLMANAGE) == 2) {
        if (
SQL_CheckConfig("RoleplayDB")) {
            
hSQL SQL_Connect("RoleplayDB",true,errorsizeof(error));
            if(
hSQL==INVALID_HANDLE) {
                
LogToFileEx(DBLOGFILE,"|DataBase| Error %s"error);
            } 
SQL_ReadDriver(hSQLSQLDriversizeof(SQLDriver));
            if(
strcmp(SQLDriver"sqlite"false)==0) {
                
LogToFileEx(DBLOGFILE,"|DataBase| Connected to Sqlite Database I.e External Config. Version %s",SQLVERSION);
                
DBConnected true;
                
SQLLite true;
            } else if(
strcmp(SQLDriver"mysql"false)==0) {
                
LogToFileEx(DBLOGFILE,"|DataBase| Connected to MySql Database. Version %s",SQLVERSION);
                
DBConnected true;
                
SQLLite false;
            }
        } else {
            
LogToFileEx(DBLOGFILE,"|DataBase| No MySql Configeration Found In database.cfg");
            
SQLLite false;
        }
    } if(!
DBConnected) {
        
LogToFileEx(DBLOGFILE,"|DataBase| Could not create Database tables...");
        
SQLLite false;
        return;
    }
}

public 
createdb() {
    if(!
SQLLite) {
        
CreateTimer(0.2,CreateMySQLdbplayer);
        
CreateTimer(0.4,CreateMySQLdbitems);
    } else {
        
CreateTimer(0.2,CreateSQLitedbplayer);
        
CreateTimer(0.4,CreateSQLitedbitems);
    }
}

public 
Action:CreateSQLitedbitems(Handle:Timer)  {
    new 
len 0;
    new 
String:query[500];
    
len += Format(query[len], sizeof(query)-len"CREATE TABLE IF NOT EXISTS `Items`");
    
len += Format(query[len], sizeof(query)-len" (`STEAMID` TEXT, `ITEMID` INTIGER, `AMOUNT` INTEGER");
    
len += Format(query[len], sizeof(query)-len"  PRIMARY KEY (`STEAMID`));");
    if(!
SQL_FastQuery(hSQLquery)) {
        
SetFailState("|DataBase| SQLite: Could not create (Items) Database tables");
        
LogToFileEx(DBLOGFILE,"|DataBase| SQLite: Could not create (Items) Database tables");
    } else {
        
LogToFileEx(DBLOGFILE,"|DataBase| SQLite: Creating (Items) Database tables");
        
SQL_FastQuery(hSQLquery);
    }    
}

public 
Action:CreateMySQLdbplayer(Handle:Timer) {
    new 
len 0;
    new 
String:query[2000],String:iJob[255],String:iGangName[255];
    
GetConVarString(DEFAULTJOBiJob255);
    
GetConVarString(DEFAULTGANGNAMEiGangName255);
    
len += Format(query[len], sizeof(query)-len"CREATE TABLE IF NOT EXISTS `Player`");
    
len += Format(query[len], sizeof(query)-len" (`STEAMID` varchar(25) NOT NULL, `NAME` varchar(30) NOT NULL,");
    
len += Format(query[len], sizeof(query)-len"  `LASTONTIME` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `Money` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTWAGES));
    
len += Format(query[len], sizeof(query)-len"  `Bank` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTBANK));
    
len += Format(query[len], sizeof(query)-len"  `Credit` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTCREDIT));
    
len += Format(query[len], sizeof(query)-len"  `Wages` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTWAGES));
    
len += Format(query[len], sizeof(query)-len"  `Minutes` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTMINUTES));
    
len += Format(query[len], sizeof(query)-len"  `Crime` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `ExploitJail` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `CopTime` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `CopCuffs` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `Hunger` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTHUNGER));
    
len += Format(query[len], sizeof(query)-len"  `Bounty` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `Paycheck` int(25) NOT NULL DEFAULT %d,"GetConVarInt(PAYCHECKTIMER));
    
len += Format(query[len], sizeof(query)-len"  `IsCuffed` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `Job` varchar(25) NOT NULL DEFAULT '%s',"iJob);
    
len += Format(query[len], sizeof(query)-len"  `Gang` varchar(25) NOT NULL DEFAULT '%s',"iGangName);
    
len += Format(query[len], sizeof(query)-len"  `TimeInJail` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `JailTimerExec` int(25) NOT NULL DEFAULT 0,");
    
len += Format(query[len], sizeof(query)-len"  `JobExperience` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTJOBEXP));
    
len += Format(query[len], sizeof(query)-len"  `JobLevel` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTJOBLEVEL));
    
len += Format(query[len], sizeof(query)-len"  `Stamina` int(25) NOT NULL DEFAULT %d,"GetConVarInt(DEFAULTSTAMINA));
    
len += Format(query[len], sizeof(query)-len"  PRIMARY KEY  (`STEAMID`)");
    
len += Format(query[len], sizeof(query)-len") ENGINE = MyISAM DEFAULT CHARSET = utf8;");
    if(!
SQL_FastQuery(hSQLquery)) {
        
SetFailState("|DataBase| MySQL: Could not create (Player) Database tables");
        
LogToFileEx(DBLOGFILE,"|DataBase| MySQL: Could not create (Player) Database tables");
    } else {
        
LogToFileEx(DBLOGFILE,"|DataBase| MySQL: Creating (Player) Database tables");
        
SQL_FastQuery(hSQLquery);
    }

__________________
Master(d)



Master53 is offline
Mojo142
Junior Member
Join Date: May 2011
Location: Dallas,Tx
Old 06-23-2011 , 13:30   Re: Strange SQLite error
Reply With Quote #2

Bump
__________________
www.UNITServers.com, LLC
Quality Manged Hosting Solutions
HL2DM, CSS, TF2, DODS & Much more!!
Hosting from $0.79/-89 slot

@ www.UNITServers.com


Mojo.
Mojo142 is offline
lokizito
Veteran Member
Join Date: Dec 2010
Location: Brazil
Old 06-23-2011 , 16:00   Re: Strange SQLite error
Reply With Quote #3

Wrong typing. You should always test the query somewhere before using in SM since than you can be sure of the problem. Also, don't bump.
Code:
 len += Format(query[len], sizeof(query)-len, " (`STEAMID` TEXT, `ITEMID` INTIGER, `AMOUNT` INTEGER");
should be
Code:
 len += Format(query[len], sizeof(query)-len, " (`STEAMID` TEXT, `ITEMID` INTEGER, `AMOUNT` INTEGER");
And one tip: use SQL_TQuery since with it you can log the error:
Callback
Code:
SQLTCallback public(Handle:owner, Handle:hndl, const String:error[], any:data);
__________________
[CS:S] RankMe - Why pay for a rank plugin if you can have one for free?
[CS:S] RankMe Connect Announcer - Announce when a player connect
Translation Project - Let's make the plugins to be international
lokizito is offline
Reply



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 20:44.


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