DUDA MYSQL R39
#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


Messages In This Thread
DUDA MYSQL R39 - by jurgen - 08.02.2016, 23:34
Respuesta: DUDA MYSQL R39 - by TheMasterNico - 08.02.2016, 23:45
Respuesta: DUDA MYSQL R39 - by jurgen - 08.02.2016, 23:50
Respuesta: DUDA MYSQL R39 - by FelipeAndres - 09.02.2016, 00:07
Respuesta: DUDA MYSQL R39 - by jurgen - 09.02.2016, 00:20
Respuesta: DUDA MYSQL R39 - by jurgen - 09.02.2016, 00:32
Respuesta: DUDA MYSQL R39 - by FelipeAndres - 09.02.2016, 00:38
Respuesta: DUDA MYSQL R39 - by jurgen - 09.02.2016, 00:45

Forum Jump:


Users browsing this thread: 1 Guest(s)