View Single Post
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-06-2018 , 14:29   Re: [CS GO] create MySql for game server and web
Reply With Quote #7

PHP Code:
#include <sourcemod> 

char ZLogFile[PLATFORM_MAX_PATH]; 

Database hDatabase null

public 
Plugin myinfo 

    
name "Sql_Test"
    
author "Dr.Mohammad"
    
description "This Plugin Only For Test"
    
version "1.0.0"
    
url "" 
}; 

public 
void OnPluginStart() 

    
Database.Connect(GotDatabase"sqltest"); 
     
    
BuildPath(Path_SMZLogFilesizeof(ZLogFile), "logs/sqltest.log"); 


public 
void GotDatabase(Database db, const char[] errorany data

    if (
db == null
    { 
        
LogToFile(ZLogFile"Database failure: %s"error); 
    } 
    else 
    { 
        
hDatabase db
         
        
db.Query(db_Connect_Callback"CREATE TABLE IF NOT EXISTS sqltest (name TEXT, steamid TEXT);");
        
LogToFile(ZLogFile"Connection Successfull"); 
    } 


public 
void db_Connect_Callback(Database dbDBResultSet rs, const char[] errorany data)
{
    if(
rs == null
    { 
        
LogError(error); 
        
LogToFile(ZLogFile"Database failure: %s"error); 
    } 

Use the new syntax (Database class):
https://sm.alliedmods.net/new-api/dbi/Database
Ilusion9 is offline