Quote:
Originally Posted by Bugsy
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)
}