Raised This Month: $ Target: $400
 0% 

SQL Get column as cvar.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
XmasterOfficial
Junior Member
Join Date: Oct 2014
Old 12-23-2015 , 03:43   SQL Get column as cvar.
Reply With Quote #1

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)
XmasterOfficial is offline
 



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 18:07.


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