Raised This Month: $ Target: $400
 0% 

[help] i useing wwwREG and i need some help ;]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
leo123
New Member
Join Date: Jun 2007
Old 06-14-2007 , 12:01   [help] i useing wwwREG and i need some help ;]
Reply With Quote #1

ok , hello all i need some help
i want make small script for my club's
i am useing JGHG plug wwwREG
and i want make script for auto change name.

this is script of wwwreg

Code:
#define PLUGINNAME "WWW Reg"
#define VERSION  "0.2"
#define AUTHOR   "JGHG"
 
$ADMINPAGE = true; // Set this to false to have a user's page (else anyone can access admin settings)
USAGE
=====
cvar: wwwreg_kicknonregged (Default 0. Set it to 1 to disallow nonregged people from entering server.)
cvar: wwwreg_regurl (Set this to the URL of your register page. It will be displayed when a player gets booted for not being registered.)
cvar: wwwreg_prepend (Default "Pub:". When wwwreg_kicknonregged is set to 0, nonregistered players will have their names prepended with this tag.)
 
#include <amxmodx>
#include <dbi>
#include <amxmisc>
#include <engine>
// ---------- Adjust below settings to your liking ---------------------------------------
// nothing...
// ---------- Adjust above settings to your liking ---------------------------------------
#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(authid, name)
 if (g_regged[id])
  server_print("[%s] %s (%s) is registered.", PLUGINNAME, name, authid)
 else {
  server_print("[%s] %s (%s) is not registered.", PLUGINNAME, name, authid)
  if (get_cvar_num(CVAR_KICKNONREGGED)) {
   new regurl[128]
   get_cvar_string(CVAR_REGURL, regurl, 127)
   server_cmd("kick #%d Register your Steam ID , For Register Go To www.wSGaming.co.il.", get_user_userid(id), authid, regurl)
  }
 }
 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
 set_task(0.1, "checkname", 0, idd, 1)
 return PLUGIN_CONTINUE
}
localtrim(stringtotrim[], const LEN, charstotrim, const bool:FROMLEFT = true) {
 if (charstotrim <= 0)
  return
 if (FROMLEFT) {
  new maxlen = strlen(stringtotrim)
  if (charstotrim > maxlen)
   charstotrim = maxlen
  format(stringtotrim, LEN, "%s", stringtotrim[charstotrim])
 }
 else {
  new maxlen = strlen(stringtotrim) - charstotrim
  if (maxlen < 0)
   maxlen = 0
  format(stringtotrim, maxlen, "%s", stringtotrim)
 }
}
public checkname(idd[1]) {
 if (is_user_bot(idd[0])) // Somehow some realbots slipped past the bot check in client_infochanged! :-(
  return
 new name[32], prepend[32], prependlength
 get_user_name(idd[0], name, 31)
 get_cvar_string(CVAR_PREPEND, prepend, 31)
 prependlength = strlen(prepend)
 if (g_regged[idd[0]]) {
  // Registered users shouldn't have names starting with CVAR_PREPEND
  // If length of set name is shorter than prepend string, user's name can't be prepend string. :-)
  if (strlen(name) >= prependlength && equali(name, prepend, prependlength)) { // case insensitive...
   // Trim name prependlength chars from left
   localtrim(name, 31, prependlength)
   entity_set_string(idd[0], EV_SZ_netname, name)
   set_user_info(idd[0], "name", name)
   client_print(idd[0], print_console, "Sorry, you can't use the public prefix ^"%s^"in your name because you are registered!", prepend)
  }
  if (!equal(name, g_names[idd[0]])) {
   // Update lastusedname in db if it changed
   update_db_name(idd[0], name)
  }
 }
 else {
  if (!equal(prepend, name, strlen(prepend))) {
   //server_print("Forcing Not_Register: name on %s", name)
   format(name, 31, "%s%s", prepend, name)
   entity_set_string(idd[0], EV_SZ_netname, name)
   set_user_info(idd[0], "name", name)
  }
 }
}
update_db_name(id, name[32]) {
 const LEN = 32
 const LONGER = 128
 new authid[LEN + 1], query[LONGER + 1]
 get_user_authid(id, authid, LEN)
 new Sql:sql
 if (!connect(sql)) {
  log_amx("Error - Couldn't connect to SQL db and thus couldn't update %s to it.", authid)
  return
 }
 format(query, LONGER, "UPDATE `%s` SET `lastactivity` = ^"%d^", `lastusedname` = ^"%s^" WHERE `steamid` = ^"%s^"", WWWREGTABLE, get_systime(), name, authid)
 new Result:result = dbi_query(sql, query)
 if (result <= RESULT_FAILED) {
  new error[256]
  dbi_error(sql, error, 255)
  log_amx("Error while quering SQL server for update of %s: %s", authid, error)
 }
 dbi_close(sql)
}
bool:checkreg(authid[], name[]) {
 new Sql:sql
 if (!connect(sql))
  return false
 const LONGER = 128
 new query[LONGER + 1]
 format(query, LONGER, "SELECT `regtime` FROM %s WHERE `steamid` = ^"%s^" LIMIT 1", WWWREGTABLE, authid)
 new Result:result = dbi_query(sql, query)
 if (result <= RESULT_FAILED) {
  new error[256]
  dbi_error(sql, error, 255)
  log_amx("Error while quering SQL server for %s, can't check registration: %s", authid, error)
  dbi_close(sql)
  return false
 }
 else if (result == RESULT_NONE) {
  dbi_close(sql)
  return false
 }
 if (!dbi_nextrow(result)) {
  dbi_close(sql)
  return false // not regged
 }
 new regtime[64]
 dbi_field(result, 1, regtime, 63)
 format_time(regtime, sizeof regtime - 1, "%y%m%d - %H:%M:%S", str_to_num(regtime))
 server_print("[%s] %s registered at %s", PLUGINNAME, authid, regtime)
 format(query, LONGER, "UPDATE `%s` SET `lastactivity` = ^"%d^", `lastusedname` = ^"%s^" WHERE `steamid` = ^"%s^"", WWWREGTABLE, get_systime(), name, authid)
 dbi_free_result(result)
 result = dbi_query(sql, query)
 if (result <= RESULT_FAILED) {
  new error[256]
  dbi_error(sql, error, 255)
  log_amx("Error while trying to update %s's (%s) reg info to SQL database. User is regged though.", authid, error)
 }
 dbi_close(sql)
 return true
}
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
}
bool:createtable(&Sql:sql) {
 new query[1024] = "CREATE TABLE IF NOT EXISTS `%s` (`steamid` varchar(30) NOT NULL default '', `regtime` int(11) NOT NULL default '0', `lastactivity` int(11) default '0', `lastusedname` varchar(33) NOT NULL default '', PRIMARY KEY  (`steamid`)) TYPE=MyISAM;"
 format(query, 1023, query, WWWREGTABLE)
 new Result:result = dbi_query(sql, query)
 if (result <= RESULT_FAILED) {
  new error[256]
  dbi_error(sql, error, 255)
  log_amx("Error while trying to create tables: %s", error)
  return false
 }
 return true
}
public plugin_init() {
 register_plugin(PLUGINNAME, VERSION, AUTHOR)
 register_cvar(CVAR_WHOST, "127.0.0.1")
 register_cvar(CVAR_WUSER, "NOTSET")
 register_cvar(CVAR_WPASS, "NOTSET")
 register_cvar(CVAR_WDB, "NOTSET")
 register_cvar(CVAR_KICKNONREGGED, "1")
 register_cvar(CVAR_REGURL, "For Register Go To www.wSGaming.co.il")
 register_cvar(CVAR_PREPEND, "Not_Register:")
 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 if (!createtable(sql)) {
  log_amx("Failed creating tables in SQL database at plugin_init! Pausing plugin.")
  pause("a")
  return
 }
 else
  server_print("[%s] Connected successfully to SQL database.", PLUGINNAME)
 dbi_close(sql)
}
i want add\make script for
in game auto change name players by name in DataBase of mysql =] for authid useing
steamid , but i am real noob =\

like that
SELECT `playername` FROM `amxx_register` WHERE `steamid` = '$stamid'

player's connect to the server and server authid by steamid .
script find name in "playrname" in database of mysql.
scrtipt change name of players in game by name in mysql database
some ppl can help me plz =\

and sorry for my bad english
i am russian :]'

big thanks leonid
good day

Last edited by leo123; 06-14-2007 at 12:05.
leo123 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 10:41.


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