SA-MP Forums Archive
Ayuda con registro MySQL R38 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: Ayuda con registro MySQL R38 (/showthread.php?tid=524480)



Ayuda con registro MySQL R38 - YazukiAkira - 07.07.2014

Hola usuarios, estoy intentando hacer un registro con MySQL la version R38 pero tengo el problema de que cuando ingreso no comprueba mi nombre en la base de datos.

pawn Код:
public OnPlayerSpawn(playerid)
{
    ComprobarUsuario(playerid);
    return 1;
}

public ComprobarUsuario(playerid)
{
    new fila, campo, string[256];
    cache_get_data(fila, campo, MySQL);

    if(fila)
    {
        mysql_format(MySQL, Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%e' LIMIT 1", NombreJugador(playerid));
        mysql_tquery(MySQL, Query, "CargarJugadorInfo", "i", playerid);

        format(string, sizeof(string), "{FFFFFF}Hola, %s!\n\nBienvenido de nuevo a {D69929}Servidor Roleplay{FFFFFF}.\nPor favor ingrese su clave para ingresar.", NombreLimpio(playerid));
        ShowPlayerDialog(playerid, DIALOGO_INGRESAR, DIALOG_STYLE_PASSWORD, "{00C6FF}› Bienvenido, ingrese su clave", string, "Ingresar", "Cancelar");
    }
    else if(!fila) {
        if(!NombreValido(playerid))
        {
            LimpiarChat(playerid);
            SendClientMessage(playerid, COLOR_BLANCO, "Tu nombre no cumple con el formato 'Nombre_Apellido'.");
            SendClientMessage(playerid, COLOR_BLANCO, "Has sido kickeado automбticamente.");
            KickJugador(playerid);
            return 1;
        }
        format(string, sizeof(string), "{EEEEEE}Antes que nada, deberбs registrar tu nombre de usuario. Para ello,\ndeberбs escoger una contraseсa y recordarla. Sin ella no tendrбs\nacceso a tu cuenta en el futuro.\nIntroduce la contraseсa a continuaciуn:");
        ShowPlayerDialog(playerid, DIALOGO_REGISTRO, DIALOG_STYLE_PASSWORD, "{00C6FF}› Registrarse", string, "Continuar", "");
    }
    return 1;
}

public CargarJugadorInfo(playerid)
{
    JugadorInfo[playerid][ID] = cache_get_field_content_int(0, "ID", MySQL);
    cache_get_field_content(0, "Clave", JugadorInfo[playerid][Clave], MySQL, 200);
    cache_get_field_content(0, "Correo", JugadorInfo[playerid][Correo], MySQL, 200);
    JugadorInfo[playerid][Baneado] = cache_get_field_content_int(0, "Baneado", MySQL);
    JugadorInfo[playerid][Nivel] = cache_get_field_content_int(0, "Nivel", MySQL);
    JugadorInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin", MySQL);
    JugadorInfo[playerid][Skin] = cache_get_field_content_int(0, "Skin", MySQL);
    JugadorInfo[playerid][Edad] = cache_get_field_content_int(0, "Edad", MySQL);
    JugadorInfo[playerid][Genero] = cache_get_field_content_int(0, "Genero", MySQL);
    JugadorInfo[playerid][Nacionalidad] = cache_get_field_content_int(0, "Nacionalidad", MySQL);
    JugadorInfo[playerid][PosX] = cache_get_field_content_float(0, "PosX", MySQL);
    JugadorInfo[playerid][PosY] = cache_get_field_content_float(0, "PosY", MySQL);
    JugadorInfo[playerid][PosZ] = cache_get_field_content_float(0, "PosZ", MySQL);
    JugadorInfo[playerid][Angulo] = cache_get_field_content_float(0, "Angulo", MySQL);
    JugadorInfo[playerid][Interior] = cache_get_field_content_int(0, "Interior", MySQL);
    JugadorInfo[playerid][Mundo] = cache_get_field_content_int(0, "Mundo", MySQL);
    JugadorInfo[playerid][Dinero] = cache_get_field_content_int(0, "Dinero", MySQL);
    JugadorInfo[playerid][Vida] = cache_get_field_content_float(0, "Vida", MySQL);
    JugadorInfo[playerid][Armadura] = cache_get_field_content_float(0, "Armadura", MySQL);
    return 1;
}



Re: Ayuda con registro MySQL R38 - YazukiAkira - 07.07.2014

Ya encontre el problema.

Solucion, realizar primero la consulta a MySQL para despues comprobar.
pawn Код:
public OnPlayerSpawn(playerid)
{
    mysql_format(MySQL, Query, sizeof(Query), "SELECT * FROM `usuarios` WHERE `Nombre` = '%e' LIMIT 1", NombreJugador(playerid));
    mysql_tquery(MySQL, Query, "ComprobarUsuario", "i", playerid);
    return 1;
}