Thread: help sqlx
View Single Post
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 08-03-2009 , 03:45   Re: help sqlx
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <sqlx>

new Handle:g_sql;
new const 
restrict_msg[] = "Desculpe, mas voce deve estar registrado para entrar no servidor!";

public 
plugin_init()
{
    
register_plugin("kick_unreg""1.0""Radiance");
}

public 
plugin_cfg()
{
    new 
host[32];
    new 
user[32];
    new 
pass[32];
    new 
dtbe[32];
    new 
error[128];
    new 
errcode;

    
get_cvar_string("amx_sql_host"hostsizeof (host));
    
get_cvar_string("amx_sql_user"usersizeof (user));
    
get_cvar_string("amx_sql_pass"passsizeof (pass));
    
get_cvar_string("amx_sql_db"dtbesizeof (dtbe));

    new 
Handle:tpl SQL_MakeDbTuple(hostuserpassdtbe);
    
g_sql SQL_Connect(tplerrcodeerrorsizeof (error));

    if (
g_sql == Empty_Handle)
    {
        
pause("a");
    }
    else
    {
        
server_print("[kick_unreg.amxx] Plugin successfully connected.");
    }
}

public 
client_authorized(id)
{
    new 
auth[32];
    
get_user_authid(idauthsizeof (auth));

    new 
Handle:query SQL_PrepareQuery(g_sql"SELECT `yourcolumn` FROM `yourtable` WHERE `yourcolum` = '%s'"auth);
    
SQL_Execute(query);

    new 
res[32];

    if (
SQL_MoreResults(query))
    {
        
SQL_ReadResult(query0ressizeof (res));
        
SQL_FreeHandle(query);
    }

    if (!
strlen(res))
    {
        
server_cmd("kick #%i %s"get_user_userid(id), restrict_msg);
    }


Last edited by TheRadiance; 08-03-2009 at 03:47.
TheRadiance is offline
Send a message via ICQ to TheRadiance