#include <sourcemod>
public
Plugin myinfo =
{
name =
"sqltest"
,
author =
"Collesss"
,
description =
"sql"
,
version =
"0.1"
,
url =
"url"
};
new
Handle:g_SQL = INVALID_HANDLE, bool:MYSQL;
public
OnPluginStart()
{
if
(!SQL_CheckConfig(
"test"
))
{
SetFailState(
" ne ydalos naiti \"test\" databases.cfg"
);
return
;
}
decl
String
:error[
256
];
g_SQL = SQL_Connect(
"test"
,
true
, error,
256
);
if
(g_SQL == INVALID_HANDLE)
{
LogError(error);
SetFailState(
"SQL erorr connect"
);
return
;
}
new
String
:driver[
15
]; SQL_ReadDriver(g_SQL, driver,
15
);
MYSQL = StrEqual(driver,
"mysql"
,
false
);
LogMessage(
" %s "
, MYSQL ?
"MYSQL"
:
"SQLite"
);
if
(!MYSQL)
{
SQL_TQuery(g_SQL, SQL_DefCallback, "CREATE TABLE IF NOT EXISTS `my_tab` (\
steamid TEXT PRIMARY KEY, \
points NUMERIC, \
nick TEXT)",
0
);
}
else
{
SQL_TQuery(g_SQL, SQL_DefCallback, "CREATE TABLE IF NOT EXISTS `my_tab` (\
`steamid` varchar(
25
) NOT NULL, \
`points`
int
(
20
) NOT NULL, \
`nick` varchar(
32
) NOT NULL, \
PRIMARY KEY (`steamid`))",
0
);
}
}
public
SQL_DefCallback(Handle:owner, Handle:hndl,
const
String
:error[], any:data)
{
if
(hndl == INVALID_HANDLE) LogError(error);
}