| p4rp4d30 |
03-23-2011 18:31 |
Help Script Register/Login
Hello such.
I wanted to know the solution to this script and created ... the console gives me error
Code:
FATAL ERROR (shutting down): MSG_ONE or MSG_ONE_UNRELIABLE with no target entity
PHP Code:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> #include <fakemeta> #include <sqlx>
#define PLUGIN "Creacion cuenta + pw" #define VERSION "1.1" #define AUTHOR "p4rp4d30" #define AUTO_TEAM_JOIN_DELAY 0.1
new Connected[33] new cvar_password_prefijo
new szPath[128]; new szFilename[136]; /*================================================================================ [MySQLx Vars, other] =================================================================================*/ new Handle:g_hTuple; new LogeadoUSR[33]; new passwordSQl[33]; new NickSQL[33]; new passwordNEW[32] new mysqlx_host, mysqlx_user, mysqlx_db, mysqlx_pass;
/*================================================================================ [Iniciacion Plugin] =================================================================================*/ public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR)
// Comandos en say register_clcmd("ingresar_password", "LoadCuenta") register_clcmd("_password", "crear_cuenta") register_message(get_user_msgid("ShowMenu"), "message_show_menu") register_clcmd("jointeam","cmdtopin") register_clcmd("chooseteam","cmdtopin") // PCVARS cvar_password_prefijo = register_cvar("account_password_prefijo", "_twbpw")
// Event register_forward( FM_ClientUserInfoChanged, "FWClientUserInfoChanged" ) register_event("TeamInfo", "HookJoinTeam", "a", "2!UNASSIGNED") /*=================================================================================*/ // SQLx cvars mysqlx_host = register_cvar ("gxm_host", "127.0.0.1"); mysqlx_user = register_cvar ("gxm_user", "user"); mysqlx_pass = register_cvar ("gxm_pass", "pass"); mysqlx_db = register_cvar ("gxm_dbname", "db"); /*=================================================================================*/ MySQLx_Init()
} /*=================================================================================*/ public cmdtopin (id) { HookJoinTeam(); return PLUGIN_HANDLED }
/*=================================================================================*/ public client_putinserver(id) { LogeadoUSR[id] = 0; Connected[id] = 0 passwordSQl[id] = 0; } public client_connect(id) { LogeadoUSR[id] = 0; Connected[id] = 0 passwordSQl[id] = 0; } /*=================================================================================*/ public client_disconnect(id) { Connected[id] = 0 } /*=================================================================================*/ public FWClientUserInfoChanged( Index, Buffer ) { if( !is_user_connected( Index ) ) return FMRES_IGNORED; static NickName[32], NickOld[32]; get_user_name( Index, NickOld, 31 ) engfunc( EngFunc_InfoKeyValue, Buffer, "name", NickName, 31 ) // Si tampoco me confundo, esto obtiene el valor "name" de su setinfo. if( equal( NickName, NickOld ) ) return FMRES_IGNORED; engfunc( EngFunc_SetClientKeyValue, Index, Buffer, "name", NickOld ) // Le volvemos a poner el nick viejo para que no se lo pueda cambiar. client_cmd( Index, "name ^"%s^"; setinfo name ^"%s^"", NickOld, NickOld ) return FMRES_SUPERCEDE; } /*================================================================================ [MENU Join] =================================================================================*/ public HookJoinTeam() { static id; id = read_data(1) switch(CheckCuentaMenu(id)) { case 0..3: { if(!Connected[id]) { new Menu = menu_create("\yMenu de Login/Registro", "showMenuLoginReg") menu_additem(Menu, "\wLogin" , "1", 0) menu_additem(Menu, "\wRegistrar Cuenta" , "2", 0) menu_setprop(Menu,MPROP_EXITNAME,"Salir") menu_setprop(Menu, MPROP_EXIT, MEXIT_ALL) menu_display(id, Menu, 0) } } }
return PLUGIN_HANDLED } /*=================================================================================*/ public showMenuLoginReg(id, Menu, item) { if (item == MENU_EXIT) { menu_destroy(Menu) return PLUGIN_HANDLED } new iData[6]; new iAccess; new iCallback; new iName[64]; menu_item_getinfo(Menu, item, iAccess, iData, 5, iName, 63, iCallback) switch (str_to_num(iData)) { case 1: { client_cmd(id, "messagemode ingresar_password"); } case 2: { client_cmd(id, "messagemode _password"); } } return PLUGIN_HANDLED }
/*================================================================================ [Func Login y Create Cuenta] =================================================================================*/ public crear_cuenta(id) { if(!is_user_connected(id)) return PLUGIN_HANDLED
new say[300] // Obtenemos en un string lo que escribio como password read_args(say, charsmax(say)) // Lo preparamos para analizar remove_quotes(say), trim(say) // Si solamente apreto enter lo omitiremos if(equal(say, "")) return PLUGIN_HANDLED // Verificamos que la password solo contenga una palabra if(contain(say, " ") != -1) { ChatColor(id, "!g[TWB]!y La contrasenia debe ser 1 (una) palabra") return PLUGIN_HANDLED } copy(passwordSQl[id], charsmax(passwordSQl), say) // Guardamos el nick en la variable 'name' get_user_name(id, NickSQL[id], charsmax(NickSQL))
static szQuery[ 128 ], iData[ 1 ]; new zwname[33] get_user_name(id,zwname,charsmax(zwname)) formatex( szQuery, 127, "SELECT `nick`, `password` FROM `account` WHERE ( `nick` = '%s' );", zwname );
iData[ 0 ] = id; SQL_ThreadQuery( g_hTuple, "QuerySelectData2", szQuery, iData, 1 ); return PLUGIN_HANDLED }
public QuerySelectData2( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) { if( iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED ) { log_amx( "%s", szError ); return; } else { new id = iData[ 0 ]; new prefijo[8] if(SQL_NumResults(hQuery) < 1) { get_user_name(id, NickSQL[id], charsmax(NickSQL)) SaveCuenta(id); get_pcvar_string(cvar_password_prefijo, prefijo, charsmax(prefijo)) client_cmd(id, "setinfo %s %s", prefijo, passwordSQl[id]) client_cmd(id, "writecfg config") ChatColor(id, "!g[TWB]!y Has sido registrado!. Nick: %s - Password: %s", NickSQL[id], passwordSQl[id]) engclient_cmd(id, "joinclass", "5"); Connected[id] = 1 LogeadoUSR[id] = 1; } } } /*=================================================================================*/
/*=================================================================================*/ CheckCuentaMenu(id) { if(!LogeadoUSR[id]) { // Al no existir, cancelamos Connected[id] = 0; LogeadoUSR[id] = 0; return 0 } if(!Connected[id]) { Connected[id] = 0; LogeadoUSR[id] = 0; return 2 }
return PLUGIN_HANDLED }
/*================================================================================ [Auto Join] =================================================================================*/ public message_show_menu(msgid, dest, id) { if(!is_user_connected(id)) return PLUGIN_HANDLED static team_select[] = "#Team_Select" static menu_text_code[sizeof team_select] get_msg_arg_string(4, menu_text_code, sizeof menu_text_code - 1) if (!equal(menu_text_code, team_select)) return PLUGIN_CONTINUE
set_force_team_join_task(id, msgid)
return PLUGIN_HANDLED } /*=================================================================================*/ set_force_team_join_task(id, menu_msgid) { if(!is_user_connected(id)) return PLUGIN_HANDLED static param_menu_msgid[2] param_menu_msgid[0] = menu_msgid set_task(AUTO_TEAM_JOIN_DELAY, "task_force_team_join", id, param_menu_msgid, sizeof param_menu_msgid) return PLUGIN_HANDLED; } /*=================================================================================*/ public task_force_team_join(menu_msgid[], id) { if (get_user_team(id)) return
force_team_join(id) }
/*================================================================================ [MySQLx] =================================================================================*/ public MySQLx_Init() { new szHost[64], szUser[32], szPass[32], szDB[128]; get_pcvar_string( mysqlx_host, szHost, charsmax( szHost ) ); get_pcvar_string( mysqlx_user, szUser, charsmax( szUser ) ); get_pcvar_string( mysqlx_pass, szPass, charsmax( szPass ) ); get_pcvar_string( mysqlx_db, szDB, charsmax( szDB ) ); g_hTuple = SQL_MakeDbTuple( szHost, szUser, szPass, szDB ); } /*=================================================================================*/ SaveCuenta(id) { if(!is_user_connected(id)) return PLUGIN_HANDLED static szQuery[ 128 ]; formatex( szQuery, 127, "REPLACE INTO `account` (`nick`, `password`) VALUES ('%s', '%s');", NickSQL[id] , passwordSQl[id] ); SQL_ThreadQuery( g_hTuple, "QuerySetData", szQuery); return PLUGIN_HANDLED; } /*=================================================================================*/
public LoadCuenta(id) { if(!is_user_connected(id)) return PLUGIN_HANDLED new say[300]
read_args(say, charsmax(say)) remove_quotes(say), trim(say)
if(equal(say, "")) return PLUGIN_HANDLED
if(contain(say, " ") != -1) { ChatColor(id, "!g[TWB]!y La contrasenia debe ser 1 (una) palabra") return PLUGIN_HANDLED } copy(passwordNEW[id], charsmax(passwordNEW), say) static szQuery[ 128 ], iData[ 1 ]; new zwname[33] get_user_name(id,zwname,charsmax(zwname)) formatex( szQuery, 127, "SELECT `nick`, `password` FROM `account` WHERE ( `nick` = '%s' );", zwname );
iData[ 0 ] = id; SQL_ThreadQuery( g_hTuple, "QuerySelectData", szQuery, iData, 1 ); return PLUGIN_HANDLED } /*=================================================================================*/
public QuerySelectData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) { if( iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED ) { log_amx( "%s", szError ); return PLUGIN_HANDLED; } else { new id = iData[ 0 ]; if(!is_user_connected(id)) return PLUGIN_HANDLED; new password2SQL[32]; new ColPass = SQL_FieldNameToNum(hQuery, "password") new name[32], prefijo[8] get_user_name(id, name, charsmax(name)) get_pcvar_string(cvar_password_prefijo, prefijo, charsmax(prefijo)) if(SQL_NumResults(hQuery) > 0) { SQL_ReadResult(hQuery, ColPass, password2SQL, charsmax(password2SQL)) //copy(passwordSQl[id], charsmax(passwordSQl), password2SQL) if(equali(password2SQL, passwordNEW[id])) { ChatColor(id, "!g[TWB]!y Contrasenia Aceptada") client_print(id, print_center, "Login Exitoso!") client_cmd(id, "setinfo ^"%s^" ^"%s^"",prefijo,password2SQL) client_cmd(id, "writecfg config") engclient_cmd(id, "joinclass", "5"); Connected[id] = 1; LogeadoUSR[id] = 1; } else { client_cmd(id, "messagemode ingresar_password"); ChatColor(id, "!g[TWB]!y Contraseņa Incorrecta. Escriba nuevamente su contraseņa") Connected[id] = 0; LogeadoUSR[id] = 0; HookJoinTeam(); } } else { // Al no existir, cancelamos ChatColor(id, "!g[TWB]!y La cuenta !team NO EXISTE!y Debes Registrarte!... Ingresa una Contrasenia para registrar nueva cuenta."); client_cmd(id, "messagemode _password"); LogeadoUSR[id] = 0; } } return PLUGIN_HANDLED; } /*=================================================================================*/ public QuerySetData( iFailState, Handle:hQuery, szError[ ], iError, iData[ ], iDataSize, Float:fQueueTime ) { if( iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED ) { log_amx( "%s", szError ); return; } }
/*================================================================================ [Stocks] =================================================================================*/ stock force_team_join(id) { if(!is_user_connected(id)) return PLUGIN_HANDLED static jointeam[] = "jointeam" engclient_cmd(id, jointeam, "5") return PLUGIN_HANDLED; } /*=================================================================================*/ stock check_user_name(id, const name[32] = "") { new plrname[32] if(equal(name, "")) { get_user_name(id, plrname, 31) } else { plrname = name } //load_cuentas(id) } /*=================================================================================*/
stock ChatColor(const id, const input[], any:...) { new count = 1, players[32] static msg[191] vformat(msg, 190, input, 3) replace_all(msg, 190, "!g", "^4") // Green Color replace_all(msg, 190, "!y", "^1") // Default Color replace_all(msg, 190, "!team", "^3") // Team Color replace_all(msg, 190, "!team2", "^0") // Team2 Color if (id) players[0] = id; else get_players(players, count, "ch") { for (new i = 0; i < count; i++) { if (is_user_connected(players[i])) { message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]) write_byte(players[i]); write_string(msg); message_end(); } } } } /*=================================================================================*/
I look forward to your help ... Thank you very much.
Sorry for my Bad English.
:)
|