Code:
#define PLUGINNAME "WWW Reg"
#define VERSION "0.2"
#define AUTHOR "JGHG"
#include <amxmodx>
#include <dbi>
#include <amxmisc>
#include <engine>
#define CVAR_WHOST "wwwreg_host"
#define CVAR_WUSER "wwwreg_user"
#define CVAR_WPASS "wwwreg_pass"
#define CVAR_WDB "wwwreg_db"
#define CVAR_KICKNONREGGED "wwwreg_kicknonregged"
#define CVAR_REGURL "wwwreg_regurl"
#define CVAR_PREPEND "wwwreg_prepend"
#define WWWREGTABLE "amxx_register"
// Global vars below
new g_regged[33]
new g_names[33][32] // Max length of name is 31
// Global vars above
public plugin_modules() {
require_module("engine")
require_module("dbi")
}
public client_authorized(id) {
if (is_user_bot(id))
return PLUGIN_CONTINUE
const LEN = 32
new authid[LEN + 1], name[32]
get_user_authid(id, authid, LEN)
get_user_name(id, name, 31)
g_regged[id] = checkreg(id, name)
if (g_regged[id])
server_print("[%s] %s is registered.", PLUGINNAME, name)
else {
new regurl[128]
get_cvar_string(CVAR_REGURL, regurl, 127)
server_cmd("kick #%d Uzsiregistruokite www.gzn.lt.", get_user_userid(id))
server_print("[%s] %s is not registered.", PLUGINNAME, name)
}
return PLUGIN_CONTINUE
}
public client_infochanged(id) {
if (is_user_bot(id) || is_user_connecting(id))
return PLUGIN_CONTINUE
get_user_name(id, g_names[id], 31)
new idd[1]
idd[0] = id
return PLUGIN_CONTINUE
}
bool:checkreg(id,name[])
{
new Sql:sql
if (!connect(sql))
return false
const LONGER = 128
new query[LONGER + 1]
format(query, LONGER, "SELECT `pass` FROM %s WHERE `nick` = ^"%s^" LIMIT 1", WWWREGTABLE, name)
new Result:result = dbi_query(sql, query)
new name[8]
get_user_info(id, "setinfo _pw", name, 7)
new regtime[8]
dbi_field(result, 1, regtime, 7)
if (result == RESULT_NONE) {
dbi_close(sql)
return false
}
if ((regtime[0] == name[0]) &&
(regtime[1] == name[1]) &&
(regtime[2] == name[2]) &&
(regtime[3] == name[3]) &&
(regtime[4] == name[4]) &&
(regtime[5] == name[5]) &&
(regtime[6] == name[6]) &&
(regtime[7] == name[7]))
{
return true
}
return false
}
bool:connect(&Sql:sql) {
const LEN = 128
new host[LEN], user[LEN], pass[LEN], db[LEN], error_msg[LEN]
get_cvar_string(CVAR_WHOST, host, LEN - 1)
get_cvar_string(CVAR_WUSER, user, LEN - 1)
get_cvar_string(CVAR_WPASS, pass, LEN - 1)
get_cvar_string(CVAR_WDB, db, LEN - 1)
sql = dbi_connect(host, user, pass, db, error_msg, LEN - 1)
if (!sql) {
log_amx("ERROR - Can't connect to SQL db: %s", error_msg)
return false
}
return true
}
public plugin_init() {
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_cvar(CVAR_WHOST, "127.0.0.1")
register_cvar(CVAR_WUSER, "root")
register_cvar(CVAR_WPASS, "")
register_cvar(CVAR_WDB, "gzn")
new sqlcfgpath[128]
get_configsdir(sqlcfgpath, 127)
format(sqlcfgpath, 127, "%s/sql.cfg", sqlcfgpath)
server_cmd("exec %s", sqlcfgpath)
server_exec()
new Sql:sql
if (!connect(sql)) {
log_amx("Couldn't connect to SQL database at plugin_init! Pausing plugin.")
pause("a")
return
}
else
server_print("[%s] Connected successfully to SQL database.", PLUGINNAME)
dbi_close(sql)
}
I need help i edited the www reg becouse i need that user register at site with nick and password and then script take from sql pass and users "setinfo _pass password" and values equal then true if note false please help :/