DUDA MYSQL R39
#1

hola estoy manejando nuevamente mysql luego de aсos pero algo pasa con el registro

cuando pongo /login password pongo una contraseсa incorrecta o la original se repiten los mensajes como contraseсa incorrecta y no para hasta ke salga del server o ponga la contraseсa correcta.

pawn Код:
funcion comprobarcuentalogin(playerid)
{
    new rows,fields;
    cache_get_data(rows, fields);
    if(!rows) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!");
    else { }
}

COMMAND:login(playerid,params[]){
    if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!");

    new nsa[144];
    mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid) );
    mysql_function_query(database, nsa, true, "comprobarcuentalogin","i", playerid);

    if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>");

    mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),params);
    mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid);
    return 1;
}

funcion PlayerLogin(playerid)
{
    new rows,fields,maximum[36];
    cache_get_data(rows, fields);
    if(rows)
    {

////////////////////////////////////////////////////////////////////////////////
    ResetPlayerMoney(playerid);

    new src2[90];
    format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1 WHERE `name` = '%s'",PlayerName(playerid) );
    mysql_function_query(database, src2, false, "", "");

    new src4[400];
    new ipv[16];
    GetPlayerIp(playerid,ipv,16);
    format(src4,sizeof(src4),"UPDATE `accounts` SET `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid) );
    mysql_function_query(database, src4, false, "", "");


    cache_get_field_content(0, "money", maximum),      GivePlayerMoney(playerid, strval(maximum) );
    cache_get_field_content(0, "deaths", maximum),     PlayerInfo[playerid][Deaths] = strval(maximum);
    cache_get_field_content(0, "kills", maximum),      PlayerInfo[playerid][Kills] = strval(maximum);
    cache_get_field_content(0, "level", maximum),      PlayerInfo[playerid][Level] = strval(maximum);
    cache_get_field_content(0, "hours",maximum),       PlayerInfo[playerid][hours] = strval(maximum);
    cache_get_field_content(0, "minutes",maximum),     PlayerInfo[playerid][mins] = strval(maximum);
    cache_get_field_content(0, "seconds",maximum),     PlayerInfo[playerid][secs] = strval(maximum);
    cache_get_field_content(0, "score",maximum),       SetPlayerScore(playerid, strval(maximum) );


    PlayerInfo[playerid][Registered] = 1;
    PlayerInfo[playerid][LoggedIn] = 1;

////////////////////////////////////////////////////////////////////////////////

        PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        if(PlayerInfo[playerid][Level] > 0)
        {
            new string[128];
            format(string,sizeof(string),"* Has accedido correctamente con tu cuenta en el servidor. (AdminNivel: %d)", PlayerInfo[playerid][Level] );
            return SendClientMessage(playerid,0xABE109FF,string);
        }
        else SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!");
        return 1;
    }
    else
    {
        PlayerInfo[playerid][FailLogin]++;
        printf("* %s ha fallado en acceder a su cuenta, contraseсa incorrecta Intento (%d)", PlayerName(playerid), PlayerInfo[playerid][FailLogin] );
        if(PlayerInfo[playerid][FailLogin] == 4)
        {
            new string[128];
            format(string, sizeof(string), "* %s ha sido kickeado. (Razon: Contraseсas Incorrectas de cuenta)", PlayerName(playerid) );
            SendClientMessageToAll(COLOR_ROJO, string);
            print(string);
            SetTimerEx( "KickPlayer", 1000, false, "i", playerid );
        }
        SendClientMessage(playerid,COLOR_ROJO,"* Error: Contraseсa Incorrecta!");
    }
    return 1;
}
parece ke tengo ke cerrar en alguna parte el codigo con 0 o el comando del mysql llamando al playerlogin es el problema, alguien sabe?


+rep saludos
Reply
#2

usa un print para saber como es la consulta que se hace en

mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),params);

Luego, con la consulta que obtuviste en el print vas a phpmyadmin y verificas si te salen datos.
Reply
#3

Quote:
Originally Posted by TheMasterNico
Посмотреть сообщение
usa un print para saber como es la consulta que se hace en

mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),params);

Luego, con la consulta que obtuviste en el print vas a phpmyadmin y verificas si te salen datos.
EL CODIGO ME FUNCIONA BIEN, LO KE PASA ESQUE NOSE PORQUE MANDA MUCHOS MENSAJES DE CONTRASEСA INCORRECTA CUANDO ME EQUIVOCO, SOLO DEBERIA ENVIAR UNO SOLO
Reply
#4

podrias probar asi

Код:
COMMAND:login(playerid,params[]){
    if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!");
    if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>");

    new nsa[144];
    mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid));
    mysql_function_query(database, nsa, true, "comprobarcuentalogin","is", playerid, params);
    return 1;
}

funcion comprobarcuentalogin(playerid, password[])
{
    new rows,fields;
    cache_get_data(rows, fields);
    if(rows)
	{
	    mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),password);
    	mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid);
	}
	else
	{
        SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!");
	}
	return 1;
}

funcion PlayerLogin(playerid)
{
    new rows,fields,maximum[36];
    cache_get_data(rows, fields);
    if(rows)
    {

	////////////////////////////////////////////////////////////////////////////////
		ResetPlayerMoney(playerid);

	    new src2[90], ipv[16];
	    GetPlayerIp(playerid,ipv,16);
	    format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1, `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid));
	    mysql_function_query(database, src2, false, "", "");

	    GivePlayerMoney(playerid, cache_get_field_content_int(0, "money"));
	    PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "deaths");
		PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "kills");
	    PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "level");
	    PlayerInfo[playerid][hours] = cache_get_field_content_int(0, "hours");
	    PlayerInfo[playerid][mins] = cache_get_field_content_int(0, "minutes");
	    PlayerInfo[playerid][secs] = cache_get_field_content_int(0, "seconds");
	    SetPlayerScore(playerid, cache_get_field_content_int(0, "score"));


		PlayerInfo[playerid][Registered] = 1;
	 	PlayerInfo[playerid][LoggedIn] = 1;

////////////////////////////////////////////////////////////////////////////////

		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		if(PlayerInfo[playerid][Level] > 0)
		{
			new string[128];
			format(string,sizeof(string),"* Has accedido correctamente con tu cuenta en el servidor. (AdminNivel: %d)", PlayerInfo[playerid][Level] );
			SendClientMessage(playerid,0xABE109FF,string);
       	}
        SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!");
    }
    else
    {
		PlayerInfo[playerid][FailLogin]++;
		printf("* %s ha fallado en acceder a su cuenta, contraseсa incorrecta Intento (%d)", PlayerName(playerid), PlayerInfo[playerid][FailLogin] );
		if(PlayerInfo[playerid][FailLogin] == 4)
		{
			new string[128];
			format(string, sizeof(string), "* %s ha sido kickeado. (Razon: Contraseсas Incorrectas de cuenta)", PlayerName(playerid) );
			SendClientMessageToAll(COLOR_ROJO, string);
			print(string);
			SetTimerEx( "KickPlayer", 1000, false, "i", playerid );
		}
		SendClientMessage(playerid,COLOR_ROJO,"* Error: Contraseсa Incorrecta!");
	}
	return 1;
}
Reply
#5

Quote:
Originally Posted by FelipeAndres
Посмотреть сообщение
podrias probar asi

Код:
COMMAND:login(playerid,params[]){
    if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ROJO,"* Error: Ya has accedido en tu cuenta!");
    if(strlen(params)==0) return SendClientMessage(playerid,COLOR_ROJO,"* Uso correcto: /login <contraseсa>");

    new nsa[144];
    mysql_format(database, nsa, sizeof(nsa), "SELECT * FROM `accounts` WHERE `name` = '%s'",PlayerName(playerid));
    mysql_function_query(database, nsa, true, "comprobarcuentalogin","is", playerid, params);
    return 1;
}

funcion comprobarcuentalogin(playerid, password[])
{
    new rows,fields;
    cache_get_data(rows, fields);
    if(rows)
	{
	    mysql_format(database, SQUERY, sizeof(SQUERY), "SELECT * FROM `accounts` WHERE `name` = '%e' AND `password` = '%e'",PlayerName(playerid),password);
    	mysql_function_query(database, SQUERY, true, "PlayerLogin", "d", playerid);
	}
	else
	{
        SendClientMessage(playerid,COLOR_ROJO,"* Error: Esta cuenta no existe, usa /registrar <contraseсa> para crear una cuenta!");
	}
	return 1;
}

funcion PlayerLogin(playerid)
{
    new rows,fields,maximum[36];
    cache_get_data(rows, fields);
    if(rows)
    {

	////////////////////////////////////////////////////////////////////////////////
		ResetPlayerMoney(playerid);

	    new src2[90], ipv[16];
	    GetPlayerIp(playerid,ipv,16);
	    format(src2,sizeof(src2),"UPDATE `accounts` SET `loggedin` = 1, `ip` = '%s' WHERE `name` = '%s'", ipv, PlayerName(playerid));
	    mysql_function_query(database, src2, false, "", "");

	    GivePlayerMoney(playerid, cache_get_field_content_int(0, "money"));
	    PlayerInfo[playerid][Deaths] = cache_get_field_content_int(0, "deaths");
		PlayerInfo[playerid][Kills] = cache_get_field_content_int(0, "kills");
	    PlayerInfo[playerid][Level] = cache_get_field_content_int(0, "level");
	    PlayerInfo[playerid][hours] = cache_get_field_content_int(0, "hours");
	    PlayerInfo[playerid][mins] = cache_get_field_content_int(0, "minutes");
	    PlayerInfo[playerid][secs] = cache_get_field_content_int(0, "seconds");
	    SetPlayerScore(playerid, cache_get_field_content_int(0, "score"));


		PlayerInfo[playerid][Registered] = 1;
	 	PlayerInfo[playerid][LoggedIn] = 1;

////////////////////////////////////////////////////////////////////////////////

		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		if(PlayerInfo[playerid][Level] > 0)
		{
			new string[128];
			format(string,sizeof(string),"* Has accedido correctamente con tu cuenta en el servidor. (AdminNivel: %d)", PlayerInfo[playerid][Level] );
			SendClientMessage(playerid,0xABE109FF,string);
       	}
        SendClientMessage(playerid,0xABE109FF,"* Has accedido correctamente en tu cuenta, ya puedes jugar!");
    }
    else
    {
		PlayerInfo[playerid][FailLogin]++;
		printf("* %s ha fallado en acceder a su cuenta, contraseсa incorrecta Intento (%d)", PlayerName(playerid), PlayerInfo[playerid][FailLogin] );
		if(PlayerInfo[playerid][FailLogin] == 4)
		{
			new string[128];
			format(string, sizeof(string), "* %s ha sido kickeado. (Razon: Contraseсas Incorrectas de cuenta)", PlayerName(playerid) );
			SendClientMessageToAll(COLOR_ROJO, string);
			print(string);
			SetTimerEx( "KickPlayer", 1000, false, "i", playerid );
		}
		SendClientMessage(playerid,COLOR_ROJO,"* Error: Contraseсa Incorrecta!");
	}
	return 1;
}
gracias me ayudo para crear el comando register tambien! +rep
Reply
#6

ALFINAL NO FUNCIONO XD QUE PODRA SER
Reply
#7

pero qe onda te hace flood aun? o no te reconoce la contraseсa
Reply
#8

ahi le movi algo y funciono, gracias


tema solucionado
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)