Quote:
Originally Posted by Bugsy
I edited the above code to use get_user_ip( 0 ) and it's working fine for me. Just let the plugin create the table and use it. I don't know what you mean by 'all the columns would be server IP's'. You should have 1 column with rows of IP's.
|
I did this:
Code:
#include <amxmodx>
#include <sqlx>
new const Version[] = "0.1"
new const szHost[] = "host"
new const szUser[] = "user"
new const szPass[] = "pass"
new const szDB[] = "plugin_licenses"
new Handle:g_SQLTuple , g_szBuffer[ 128 ]
public plugin_init()
{
register_plugin( "Check IP License" , Version , "bugsy" )
g_SQLTuple = SQL_MakeDbTuple( szHost , szUser , szPass , szDB )
new szIP[20]
get_user_ip( 0 , szIP , charsmax( szIP ) , 1 )
server_print( "%s",szIP )
formatex( g_szBuffer , charsmax( g_szBuffer ) , "SELECT '%s' FROM Licenses WHERE 1;" , szIP )
ExecuteQuery( g_szBuffer , true )
}
public ExecuteQuery( const szQuery[] , bool:bNeedResults )
{
new szError[ 64 ] , Handle:SqlConnection , ErrorCode
SqlConnection = SQL_Connect( g_SQLTuple , ErrorCode , szError , charsmax( szError ) )
if( SqlConnection == Empty_Handle )
set_fail_state( szError );
new Handle:query = SQL_PrepareQuery( SqlConnection , szQuery )
SQL_Execute( query )
if ( bNeedResults )
{
if ( !SQL_NumResults( query ) )
{
set_fail_state( "License not found!" )
} else {
server_print( "Server license found!" )
}
}
SQL_FreeHandle( query )
SQL_FreeHandle( SqlConnection )
}
But, it allways tells "Server license found!". I edited a little bit so it should detect if the IP of the server is in the table "Licenses". Every column in "Licenses" have the IP of the servers. For example: Name: 192.168.1.2 and Value: 1. What could be the problem?