[Ayuda]: Dialog - Consulta MySQL
#1

Estaba haciendo el sistema de registro y login en MySQL, y me guнe de esta parte:


https://sampforum.blast.hk/showthread.php?tid=435485


Editй el registro y me funcionу, pero ahora el login no me carga el dialog, para registrarse da todo, si se guarda en base de datos y todo normal, pero no me da el login, acб el cуdigo

Lo modifiquй un poco el LOGIN, si pudieran darme lo correcto serнa estupendo ! Gracias :

PHP код:
case LOGUEAR:
        {
            if(!
response)
            {
                
Kick(playerid);
            }
            if(
response)
            {
                new 
escapepass[100];
                
mysql_real_escape_string(inputtextescapepass);
                
format(Querysizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%s' AND `Clave` ='%s'"pName,escapepass);
                
mysql_function_query(ConecctionQuerytrue"OnQueryFinish""ii"1playerid);
            }
            else
            {
                
SendClientMessage(playerid, -1"CONTRASEСA INCORRECTA");
                
Kick(playerid);
            }
        } 
Reply
#2

Te recomiendo uno de estos 2 tutoriales, son mejores que el que colocaste

https://sampforum.blast.hk/showthread.php?tid=581016

https://sampforum.blast.hk/showthread.php?tid=559935
Reply
#3

Quote:
Originally Posted by wharlos
Посмотреть сообщение
Te recomiendo uno de estos 2 tutoriales, son mejores que el que colocaste

https://sampforum.blast.hk/showthread.php?tid=581016

https://sampforum.blast.hk/showthread.php?tid=559935
Utilizo este porque se me hace mбs fбcil de usarlo, y por favor ayъdame con el cуdigo D:
Reply
#4

Tu case se ve bien, si no te sale dialogo para loguear, revisa bien el checkplayer en OnPlayerConnect
Reply
#5

asi creo que funcionaria

Код:
new Password[playerid][129];

public OnPlayerConnect(playerid)
{
	new Query[120];
	format(Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%s'", pName);
	mysql_function_query(Conexion, Query, true, "CheckPlayer", "i", playerid);
	return 1;
}
	
forward CheckPlayer(playerid);
public CheckPlayer(playerid)
{
    new Rows, Field;
	cache_get_data(Rows, Field);
    if(Rows > 0)
	{
	    cache_get_field_content(0, "Clave", Password[playerid], Conexion, 129);
	    ShowPlayerDialog(extraid, LOGUEAR, DIALOG_STYLE_PASSWORD,"Login","Ingresa tu contraseсa:","Enviar","Salir");
	}
	else if(!Rows)
	{
	    SendClientMessage(playerid, -1, "No estas registrado");
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case LOGUEAR:
	 	{
	    	if(!response)
	        {
	            SendClientMessage(playerid, -1, "CONTRASEСA INCORRECTA");
	        	Kick(playerid);
	         }
	         else
	         {
	            if(!strlen(inputtext))
	            {
	                SendClientMessage(playerid, -1, "NO INGRESASTE NINGЪNA CONTRASEСA");
	                Kick(playerid);
					return 1;
	            }
	            if(!strcmp(inputtext, Password[playerid]))
	            {
					new Query[120];
		            mysql_format(Conexion, Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%s'", pName);
		            mysql_function_query(Conexion, Query, true, "LoadAccount", "i", playerid);
	    		}
	    		else
	    		{
	    		    SendClientMessage(playerid, -1, "CONTRASEСA INCORRECTA");
	                Kick(playerid);
					return 1;
	    		}
			}
		}
	}
	return 1;
}

funcion LoadAccount(playerid)
{
 	    PlayerInfo[playerid][Score] = cache_get_field_content_int(0, "score");
		PlayerInfo[playerid][Dinero] = cache_get_field_content_int(0, "dinero");
        PlayerInfo[playerid][Nivel] = cache_get_field_content_int(0, "nivel");
        PlayerInfo[playerid][Dinero] = cache_get_field_content_float(0, "experiencia");
        PlayerInfo[playerid][PosX] = cache_get_field_content_float(0, "posx");
        PlayerInfo[playerid][PosY] = cache_get_field_content_float(0, "posy");
        PlayerInfo[playerid][PosZ] = cache_get_field_content_float(0, "posz");
        PlayerInfo[playerid][Interior] = cache_get_field_content_int(0, "interior");
	return 1;
}
Reply
#6

Quote:
Originally Posted by FelipeAndres
Посмотреть сообщение
asi creo que funcionaria

Код:
new Password[playerid][129];

public OnPlayerConnect(playerid)
{
	new Query[120];
	format(Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%s'", pName);
	mysql_function_query(Conexion, Query, true, "CheckPlayer", "i", playerid);
	return 1;
}
	
forward CheckPlayer(playerid);
public CheckPlayer(playerid)
{
    new Rows, Field;
	cache_get_data(Rows, Field);
    if(Rows > 0)
	{
	    cache_get_field_content(0, "Clave", Password[playerid], Conexion, 129);
	    ShowPlayerDialog(extraid, LOGUEAR, DIALOG_STYLE_PASSWORD,"Login","Ingresa tu contraseсa:","Enviar","Salir");
	}
	else if(!Rows)
	{
	    SendClientMessage(playerid, -1, "No estas registrado");
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
		case LOGUEAR:
	 	{
	    	if(!response)
	        {
	            SendClientMessage(playerid, -1, "CONTRASEСA INCORRECTA");
	        	Kick(playerid);
	         }
	         else
	         {
	            if(!strlen(inputtext))
	            {
	                SendClientMessage(playerid, -1, "NO INGRESASTE NINGЪNA CONTRASEСA");
	                Kick(playerid);
					return 1;
	            }
	            if(!strcmp(inputtext, Password[playerid]))
	            {
					new Query[120];
		            mysql_format(Conexion, Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%s'", pName);
		            mysql_function_query(Conexion, Query, true, "LoadAccount", "i", playerid);
	    		}
	    		else
	    		{
	    		    SendClientMessage(playerid, -1, "CONTRASEСA INCORRECTA");
	                Kick(playerid);
					return 1;
	    		}
			}
		}
	}
	return 1;
}

funcion LoadAccount(playerid)
{
 	    PlayerInfo[playerid][Score] = cache_get_field_content_int(0, "score");
		PlayerInfo[playerid][Dinero] = cache_get_field_content_int(0, "dinero");
        PlayerInfo[playerid][Nivel] = cache_get_field_content_int(0, "nivel");
        PlayerInfo[playerid][Dinero] = cache_get_field_content_float(0, "experiencia");
        PlayerInfo[playerid][PosX] = cache_get_field_content_float(0, "posx");
        PlayerInfo[playerid][PosY] = cache_get_field_content_float(0, "posy");
        PlayerInfo[playerid][PosZ] = cache_get_field_content_float(0, "posz");
        PlayerInfo[playerid][Interior] = cache_get_field_content_int(0, "interior");
	return 1;
}
Nada.. tratй de adaptarlo al sistema y nada..
Reply
#7

en que parte falla?
Reply
#8

Este error lo tenнa yo antes, y la razуn era que se perdнa la conexiуn con el servidor mysql.

Procura que el servidor samp y el mysql estйn en la misma mбquina y cuenten con la misma direcciуn IP, para poder conectarte por localhost.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)