Raised This Month: $12 Target: $400
 3% 

SQLite


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 05-01-2016 , 13:29   SQLite
Reply With Quote #1

Before I started to learn souremod scripting I was pretty samiliar with Glua for Garry's Mod. I made a little "vip system" which used SQLite database, I wanted to do something similar on csgo for fun.
Is it possible to use SQLite?
Michael Shoe Maker is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 05-01-2016 , 13:59   Re: SQLite
Reply With Quote #2

https://www.google.com/search?q=sourcemod+sql
https://www.google.com/search?q=sourcemod+sqlite
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 05-01-2016 , 15:35   Re: SQLite
Reply With Quote #3

PHP Code:
void DatabaseConnect()
{
    
char Error[60];
    
DB SQL_Connect("Raccoons"trueErrorsizeof(Error));
    
    if(
DB == INVALID_HANDLE)
    {
        
PrintToServer("Failed on connection to raccoons database: %s"Error);
        
CloseHandle(DB);
    } else {
        
char query[60];
        
Format(querysizeof(query), "CREATE TABLE IF NOT EXISTS 'Raccoons' ('name' TEXT, 'steamid64' TEXT UNIQUE)");
        if (!
SQL_Query(DBquery))
        {
            
SQL_GetError(DBErrorsizeof(Error));
            
PrintToServer("Failed to query on connection (error: %s)"Error);
        }
    }

Gives:
Code:
Failed to query on connection (error: unrecognized token: "'steami")
Any ideas?
Michael Shoe Maker is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-01-2016 , 15:58   Re: SQLite
Reply With Quote #4

Your "query" variable isn't long enough, you're truncating your query.
__________________
asherkin is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 05-01-2016 , 16:54   Re: SQLite
Reply With Quote #5

Quote:
Originally Posted by asherkin View Post
Your "query" variable isn't long enough, you're truncating your query.
Thank you my friend.

Another problem has arisen from the depths.
http://pastebin.com/q9ySTZxt (HAD TO USE THIS OTHERWISE I GET BLOCKED)

This function is meant to check if the client's steamid64 is in the database and if so return true and if not return false. It's empty but returns true.
Michael Shoe Maker is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-01-2016 , 17:08   Re: SQLite
Reply With Quote #6

You're just checking if the query is successful, not if it returns any results.
__________________
asherkin is offline
Michael Shoe Maker
Senior Member
Join Date: Apr 2016
Old 05-01-2016 , 17:21   Re: SQLite
Reply With Quote #7

Quote:
Originally Posted by asherkin View Post
You're just checking if the query is successful, not if it returns any results.
How would I check if the value exists within the database?
Michael Shoe Maker is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-02-2016 , 03:15   Re: SQLite
Reply With Quote #8

https://wiki.alliedmods.net/SQL_(Sou...essing_Results

Use SQL_GetRowCount or SQL_FetchRow after SQL_Query. Also don't put single quotes around table and column names, they are not strings.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Reply


Thread Tools
Display Modes

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 09:31.


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