Raised This Month: $ Target: $400
 0% 

Solved MySQL and SQLITE


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 07-05-2021 , 14:12   Re: MySQL and SQLITE
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
here give this a try and show the outputs
Made some minor edits to proceed with the compilation.

PHP Code:
#include <amxmodx>
#include <sqlx>
#pragma defclasslib sqlite sqlite

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

#define CREATE "CREATE TABLE IF NOT EXISTS example (steamid varchar(32), name varchar(32));"
#define CREATE2 "CREATE TABLE IF NOT EXISTS example (steamid TEXT, name TEXT);"
#define CREATE3 "CREATE TABLE IF NOT EXISTS stats (steamid TEXT, name TEXT);"

#define SQLITEFILE "SQLITE"
#define SQLITEFILESTATS "SQLITESTATS"


#define HOST "localhost"
#define USER "user"
#define PASS "PASSWORD"
#define DB_INFO "DB INFO"

new Handle:g_iTuple Empty_HandleQueryNum;
new 
QueryError[512]

public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)

        
set_task(2.0"InitMYSQLQueries")
}

public 
InitMYSQLQueries()
{
        
PrepareTuple();

        
DoBasicInfo("mysql");

        new 
szQuery[128]
        new 
szData[3];

        
formatex(szQuerycharsmax(szQuery), CREATE);
        
server_print("Adding to %i queue at: %f", ++QueryNumget_gametime())
        
szData[0] = QueryNum;
        
SQL_ThreadQuery(g_iTuple,"InitialMySQL_Handler",szQueryszDatasizeof(szData))

        
DoBasicInfo("sqlite");

        
formatexszQuerycharsmax(szQuery), CREATE2)
        
server_print("Adding to %i queue at: %f", ++QueryNumget_gametime())
        
szData[0] = QueryNum;
        
SQL_ThreadQuery(g_iTuple,"InitialMySQL_Handler"szQueryszDatasizeof(szData))

        
formatex(szQuerycharsmax(szQuery), CREATE3)
        
server_print("Adding to %i queue at: %f", ++QueryNumget_gametime())
        
szData[0] = QueryNum;
        
SQL_ThreadQuery(g_iTuple,"InitialMySQL_Handler"szQueryszDatasizeof(szData))
}

DoBasicInfo(const wanted_type[]="mysql")
{
    new 
affinity[12];

    
SQL_GetAffinity(affinitycharsmax(affinity))

    
server_print("SQLX Affinity: %s"affinity)
    
server_print("SQLX Wanted: %s"wanted_type)

    if (!
equal(wanted_typeaffinity))
    {
        if(
g_iTuple != Empty_Handle)
        {
            
SQL_FreeHandle(g_iTuple)
            
g_iTuple Empty_Handle
        
}

        new 
res SQL_SetAffinity(wanted_type)
        
server_print("Setting affinity from %s to %s: %s",
                        
affinity,
                        
wanted_type,
                        
res "Success" "Failed")
        
SQL_GetAffinity(affinity11)
        
PrepareTuple();
        
server_print("Verification: %s"affinity)
    }
}

PrepareTuple()
{
    
g_iTuple SQL_MakeDbTuple(HOST,USER,PASS,DB_INFO);
}

public 
InitialMySQL_Handler(FailStateHandle:QueryError[], ErrcodeData[], DataSizeFloat:queuetime)
{
        
server_print(" --> Resolved query %d, took %f seconds"Data[0], queuetime)

        if(
FailState == TQUERY_CONNECT_FAILED)
                
log_amx("Load - Could not connect to SQL database.  [%d] %s"ErrcodeError)
        else if(
FailState == TQUERY_QUERY_FAILED)
        {
                
SQL_GetQueryString(Query,QueryError,charsmax(QueryError))
                
log_amx("Could not execute query ^"%s^"",QueryError)
        }

        if(!
SQL_NumRows(Query))
        {
                
server_print("No Results.")
        }
        else
                
server_print("Created.")

__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 07-05-2021 at 14:15.
iceeedr is offline
Send a message via Skype™ to iceeedr
 



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 02:32.


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