Raised This Month: $ Target: $400
 0% 

help sqlx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thallysbar
Junior Member
Join Date: Oct 2007
Old 08-03-2009 , 00:00   help sqlx
Reply With Quote #1

Hello guys need a help with this script.
I will explain, I want the plugin to compare steamid the player in the mysql database if it is not registered is kick.
the original plugin does the same thing but in a file and I need q search the database.
someone help me?
sorry my english

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
 
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
new g_configsdir[64]
new 
steamid_db[64]
new const 
restrict_msg[] = "Desculpe, mas voce deve estar registrado para entrar no servidor!"
public plugin_init() {
 
 
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
plugin_cfg()
{
 
get_configsdir(g_configsdir63 )
 
format(steamid_db,63,"%s/steamid_db.ini",g_configsdir)
 
 if(!
file_exists(steamid_db))
  
write_file(steamid_db,"");
}
public 
client_connect(id)
{
 if(
is_steamid_in_file(id))
  return 
1;
 
 else
  
server_cmd("kick #%i ^"%s^"",get_user_userid(id),restrict_msg)
 
 return 
1;
}
 
stock is_steamid_in_file(id) {
 
 new 
file fopen(steamid_db,"r")
 
 new 
mauthid[30],pauthid[30]
 
get_user_authid(id,pauthid29)
 
 if (!
pauthid[0] )
  return 
0;
 
 while (!
feof(file))
 {
 
  
fgets(filemauthid19);
  new 
len strlen(pauthid);
 
  if (
equali(pauthidmauthidlen))
  {
   
fclose(file)
   return 
1;
  }
 }
 
fclose(file)
 return 
0;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/ 
thallysbar is offline
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
thallysbar
Junior Member
Join Date: Oct 2007
Old 08-07-2009 , 22:11   Re: help sqlx
Reply With Quote #3

Resolved thanks

Last edited by thallysbar; 08-08-2009 at 20:19.
thallysbar 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 11:29.


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