So I tryed for like one day and one night without figuring this how it works:
Code:
public MySql_Init()
{
g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)
new ErrorCode,Handle:g_SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
if(g_SqlConnection == Empty_Handle)
{
set_fail_state(g_Error)
}
new szIP[20]
get_user_ip(0, szIP, charsmax(szIP), false)
new Handle:query = SQL_PrepareQuery(g_SqlConnection,"SELECT '%s' FROM `licenses` WHERE 1", szIP, szIP)
if (!SQL_Execute(query) || !SQL_NumResults(query))
{
unlicensed = 1
SQL_FreeHandle(query)
return PLUGIN_HANDLED
}
SQL_FreeHandle(query)
unlicensed = 0
SQL_FreeHandle(g_SqlConnection)
return PLUGIN_CONTINUE
}
I have this in plugin_init:
Code:
set_task(1.0, "MySql_Init")
So what I try to do is to get a column that is an server ip from my DB and compare it with the server ip and if the server ip is the same with the ip from the column then it will set unlicensed to 0 else it will set it to 1 (no matter if is an SQL error) My database tree would be like:
Code:
public_licenses
licenses = 192.168.1.3:27015 (type varchar 60)