Raised This Month: $ Target: $400
 0% 

SQL Get column as cvar.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-29-2015 , 07:46   Re: SQL Get column as cvar.
Reply With Quote #1

What I gave you works why do you keep changing it
__________________
Bugsy is offline
XmasterOfficial
Junior Member
Join Date: Oct 2014
Old 12-29-2015 , 13:51   Re: SQL Get column as cvar.
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
What I gave you works why do you keep changing it
Because the way you did it doesn't help me. I need it to find if the server IP from get_user_ip 0 is the same as one of the IP-s from table Licenses. So in the table Licenses there would be like 5 columns. The name of every column would be an different IP and the value would be 1. So I need to check if the server ip is in the table Licenses as a column and if it is inside the table then it will server_print something and if not then server_print something else. Later I will change the server_print with a variable. Like if it is licensed then set licensed = 1 and if is not licensed then licensed = 0 and later in the plugin I will use that. If licensed == 1 then do something etc.
Edit: The way you gave me is working but I need to edit the .sma for every server and is not something I want.

Edit 2: I finaly found a way:
Code:
#include <amxmodx>
#include <sqlx>

new const Version[] = "1.0"
new const szHost[] = "HOST"
new const szUser[] = "USER"
new const szPass[] = "PASS"
new const szDB[] = "plugin_licenses"

new Handle:g_SQLTuple

public plugin_init() 
{
register_plugin( "Check IP License" , Version , "XmasterOfficial" )
g_SQLTuple = SQL_MakeDbTuple(szHost, szUser, szPass, szDB)
new error, szError[128]
new Handle:hConn = SQL_Connect(g_SQLTuple, error, szError, 127)
if( hConn == Empty_Handle ){
set_fail_state( szError )
}
new szIP[20]
new Handle:query
get_user_ip( 0 , szIP , charsmax( szIP ) , 1 )
query = SQL_PrepareQuery(hConn,"SELECT * FROM `Licenses` WHERE `%s`=1", szIP)
if(!SQL_Execute(query)){
server_print( "Server license not found!" )
} else {
server_print( "Server license found!" )
SQL_FreeHandle(query)
}
SQL_FreeHandle(hConn)
}

Last edited by XmasterOfficial; 12-29-2015 at 16:46.
XmasterOfficial is offline
Reply



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