Problema con dialog y condicionales
#1

Hola tengo problemas con mi funcion esta no funciona como quiero.

Lo que quiero es que; Compruebe la clave del usuario y si es correcta, comprobar si esta baneado, comprobar si es admin y hacer spawn.

Si ingresa la clave incorrecta 3 veces le de kick al usuario, si el usuario es admin lo lleve al dialog "DIALOGO_ADMIN_CLAVE".

pawn Код:
#define LIMITE_INTENTOS_INGRESO 3 // Intentos de clave

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        case DIALOGO_INGRESAR:
        {
            new string[256];
            if (!response) return Kick(playerid);
            if(!strlen(inputtext))
            {
                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");
            }
            if (!strcmp(inputtext, JugadorInfo[playerid][Clave]))
            {
                if (JugadorInfo[playerid][Baneado] == 1)
                {
                    LimpiarChat(playerid);
                    SendClientMessage(playerid, COLOR_NARANJA, "Has sido kickeado automбticamente. (Razуn: Tu nombre de usuario se encuentra baneado)");
                    KickJugador(playerid);
                    return 1;
                }
                if (JugadorInfo[playerid][Admin] > 0)
                {
                    ShowPlayerDialog(playerid, DIALOGO_ADMIN_CLAVE, DIALOG_STYLE_PASSWORD, "Seguridad Administrativa", "Por favor ingrese su clave administrativa", "Continuar", "Cancelar");
                }
                else if (JugadorInfo[playerid][Admin] == 0)
                {
                    format(string, sizeof(string), "SERVIDOR: Bienvenido %s.", NombreLimpio(playerid));
                    SendClientMessage(playerid, COLOR_BLANCO, string);
                    JugadorLogueado[playerid] = 1;
                }
            }
            else
            {
                SetPVarInt(playerid, "IntentosIngreso", GetPVarInt(playerid, "IntentosIngreso") +1 );
                format(string, sizeof(string), " La contraseсa introducida es incorrecta. (%d/%d)", GetPVarInt(playerid, "IntentosIngreso"), LIMITE_INTENTOS_INGRESO);
                SendClientMessage(playerid, COLOR_GRIS, string);
                if (GetPVarInt(playerid, "IntentosIngreso") == LIMITE_INTENTOS_INGRESO)
                {
                    SendClientMessage(playerid, COLOR_NARANJA, "Has sido baneado automбticamente. (Razуn: Lнmite de intentos de ingreso)");
                    BanEx(playerid, "Lнmite de intentos de ingreso.");
                    return 1;
                }

                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");
            }
        }
        case DIALOGO_ADMIN_CLAVE:
        {
            new string[256];
            if(!strlen(inputtext) || strval(inputtext) == 0)
            {
                ShowPlayerDialog(playerid, DIALOGO_ADMIN_CLAVE, DIALOG_STYLE_PASSWORD, "Seguridad Administrativa", "Por favor ingrese su clave administrativa", "Continuar", "Cancelar");
            }
            if(strval(inputtext) == JugadorInfo[playerid][AdminClave])
            {
                format(string, sizeof(string), "SERVIDOR: Bienvenido %s.", NombreLimpio(playerid));
                SendClientMessage(playerid, COLOR_BLANCO, string);
                JugadorLogueado[playerid] = 1;
                format(string, sizeof(string), "Te has identificado como Administrador.");
                SendClientMessage(playerid, COLOR_BLANCO, string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_NARANJA, "Has sido kickeado automбticamente. (Razуn: Clave de administracion invalida)");
                KickJugador(playerid);
            }
        }
    }
    return 1;
}
Reply
#2

Otra duda que tengo es que estoy haciendo una consulta multitabla, esta consulta me funciona bien fuera de pawno (en phpMyAdmin), quiero saber si estaria bien realizada de la siguiente manera:

pawn Код:
mysql_format(MySQL, Query, sizeof(Query), "SELECT usuarios.*, administradores.ID AS AdminID, administradores.Nombre AS AdminNombre, administradores.Clave AS AdminClave, administradores.Rango AS AdminRango FROM usuarios, administradores WHERE usuarios.Nombre = '%e' AND administradores.Nombre = '%e' LIMIT 1", NombreJugador(playerid), NombreJugador(playerid));
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)