Raised This Month: $ Target: $400
 0% 

Help Script Register/Login


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
p4rp4d30
Veteran Member
Join Date: Mar 2007
Old 03-23-2011 , 18:31   Help Script Register/Login
Reply With Quote #1

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_hostmysqlx_usermysqlx_dbmysqlx_pass;

/*================================================================================
                [Iniciacion Plugin]
=================================================================================*/
public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
// 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_forwardFM_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 FWClientUserInfoChangedIndexBuffer )
{
    if( !
is_user_connectedIndex ) )
        return 
FMRES_IGNORED;
    
    static 
NickName[32], NickOld[32]; get_user_nameIndexNickOld31 )
    
engfuncEngFunc_InfoKeyValueBuffer"name"NickName31 // Si tampoco me confundo, esto obtiene el valor "name" de su setinfo.
    
    
if( equalNickNameNickOld ) )
        return 
FMRES_IGNORED;
    
    
engfuncEngFunc_SetClientKeyValueIndexBuffer"name"NickOld // Le volvemos a poner el nick viejo para que no se lo pueda cambiar.
    
    
client_cmdIndex"name ^"%s^"; setinfo name ^"%s^""NickOldNickOld )
    
    return 
FMRES_SUPERCEDE;
}  
/*================================================================================
                [MENU Join]
=================================================================================*/
public HookJoinTeam() 

    static 
idid 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(MenuMPROP_EXITMEXIT_ALL
                 
                
menu_display(idMenu0
            }
        }
    }

    return 
PLUGIN_HANDLED 

/*=================================================================================*/
public showMenuLoginReg(idMenuitem

    if (
item == MENU_EXIT
    { 
        
menu_destroy(Menu
        return 
PLUGIN_HANDLED 
    

     
    new 
iData[6]; 
    new 
iAccess
    new 
iCallback
    new 
iName[64]; 
    
menu_item_getinfo(MenuitemiAccessiData5iName63iCallback
      
    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(saycharsmax(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(idNickSQL[id], charsmax(NickSQL))
    

    static 
szQuery128 ], iData];
    new 
zwname[33]
    
get_user_name(id,zwname,charsmax(zwname))
    
    
formatexszQuery127"SELECT `nick`, `password` FROM `account` WHERE ( `nick` = '%s' );"zwname );  

    
iData] = id;
    
SQL_ThreadQueryg_hTuple"QuerySelectData2"szQueryiData);
    return 
PLUGIN_HANDLED
}

public 
QuerySelectData2iFailStateHandle:hQueryszError[ ], iErroriData[ ], iDataSizeFloat:fQueueTime 

    if( 
iFailState == TQUERY_CONNECT_FAILED 
    
|| iFailState == TQUERY_QUERY_FAILED 
    { 
        
log_amx"%s"szError );
        
        return;
    } 
    else 
    { 
        new 
id iData];
        
        new 
prefijo[8]
        
        if(
SQL_NumResults(hQuery) < 1)
        {
            
get_user_name(idNickSQL[id], charsmax(NickSQL))
            
SaveCuenta(id);
            
get_pcvar_string(cvar_password_prefijoprefijocharsmax(prefijo))
            
client_cmd(id"setinfo %s %s"prefijopasswordSQl[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(msgiddestid
{
    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED
    
    
static team_select[] = "#Team_Select"
    
static menu_text_code[sizeof team_select]
    
get_msg_arg_string(4menu_text_codesizeof menu_text_code 1)
    if (!
equal(menu_text_codeteam_select))
        return 
PLUGIN_CONTINUE

    set_force_team_join_task
(idmsgid)

    return 
PLUGIN_HANDLED
}
/*=================================================================================*/
set_force_team_join_task(idmenu_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"idparam_menu_msgidsizeof 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_stringmysqlx_hostszHostcharsmaxszHost ) );
    
get_pcvar_stringmysqlx_userszUsercharsmaxszUser ) );
    
get_pcvar_stringmysqlx_passszPasscharsmaxszPass ) );
    
get_pcvar_stringmysqlx_dbszDBcharsmaxszDB ) );
    
    
g_hTuple SQL_MakeDbTupleszHostszUserszPassszDB );
    
}
/*=================================================================================*/
SaveCuenta(id)

    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED
    
    
static szQuery128 ]; 
    
formatexszQuery127"REPLACE INTO `account` (`nick`, `password`) VALUES ('%s', '%s');"NickSQL[id] , passwordSQl[id] );
    
SQL_ThreadQueryg_hTuple"QuerySetData"szQuery);
    
    return 
PLUGIN_HANDLED;
}
/*=================================================================================*/

public LoadCuenta(id)
{
    if(!
is_user_connected(id))
        return 
PLUGIN_HANDLED
    
    
new say[300]

    
read_args(saycharsmax(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 
szQuery128 ], iData];
    new 
zwname[33]
    
get_user_name(id,zwname,charsmax(zwname))
    
    
formatexszQuery127"SELECT `nick`, `password` FROM `account` WHERE ( `nick` = '%s' );"zwname );  

    
iData] = id;
    
SQL_ThreadQueryg_hTuple"QuerySelectData"szQueryiData);
    return 
PLUGIN_HANDLED
    
}
/*=================================================================================*/

public QuerySelectDataiFailStateHandle:hQueryszError[ ], iErroriData[ ], iDataSizeFloat:fQueueTime 

    
    if( 
iFailState == TQUERY_CONNECT_FAILED 
    
|| iFailState == TQUERY_QUERY_FAILED 
    { 
        
log_amx"%s"szError );
        
        return 
PLUGIN_HANDLED;
    } 
    else 
    { 
        new 
id iData];
        
        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(idnamecharsmax(name))
        
get_pcvar_string(cvar_password_prefijoprefijocharsmax(prefijo))
        
        
    
        if(
SQL_NumResults(hQuery) > 0)
        {
            
SQL_ReadResult(hQueryColPasspassword2SQLcharsmax(password2SQL))
            
//copy(passwordSQl[id], charsmax(passwordSQl), password2SQL)
            
            
            
if(equali(password2SQLpasswordNEW[id])) 
            { 
                
ChatColor(id"!g[TWB]!y Contrasenia Aceptada"
                
client_print(idprint_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 QuerySetDataiFailStateHandle:hQueryszError[ ], iErroriData[ ], iDataSizeFloat: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(idjointeam"5")
    
    return 
PLUGIN_HANDLED;
}
/*=================================================================================*/
stock check_user_name(id, const name[32] = "")
{
    new 
plrname[32]
   
    if(
equal(name""))
    {
        
get_user_name(idplrname31)
    }
    else
    {
        
plrname name
    
}
    
//load_cuentas(id)
}
/*=================================================================================*/


stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    
vformat(msg190input3)
    
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
replace_all(msg190"!team2""^0"// Team2 Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
         for (new 
0counti++)
         {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_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.
p4rp4d30 is offline
 



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 14:38.


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