Consulta sobre dialog y variables.
#2

Quote:
Originally Posted by YazukiAkira
Посмотреть сообщение
Tengo una duda con esto, їcomo puedo ir guardando valores enteros y de tipo string del dialog para luego recuperarlos en una funcion?

EJ:

pawn Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Ingrese su clave", "Su clave debe contener letras y numeros.", "Siguiente", "");

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
            // їAqui deberia guardar la clave en una variable de tipo string?
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Ingrese su edad", "Pulsa siguiente.", "Siguiente", "");
        }
    }
    if(dialogid == 2)
    {
        if(response)
        {
            // їAqui deberia guardar la edad en una variable de tipo entero?
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Seleccione su genero", "Hombre\nMujer.", "Siguiente", "");
        }
    }
    if(dialogid == 3)
    {
        switch (listitem)
        {
            case 0:
            {
                // Es hombre
                // їAqui deberia guardar la edad en una variable de tipo entero?
                // Ejecuto una funcion
                GuardarDatos(playerid);
            }
            case 1:
            {
                // Es mujer
                // їAqui deberia guardar la edad en una variable de tipo entero?
                // Ejecuto una funcion
                GuardarDatos(playerid);
            }
        }
    }
    return 1;
}

stock GuardarDatos(playerid)
{
    // Aqui quiero recuperar los datos almacenados en las variables, luego pienso hacer un INSERT a una tabla de MYSQL con los datos de las variables
    // їComo podria hacer eso?
}
Agradezco algun ejemplo con SetPVar* y GetPVar* en int y string, tambiйn con Enum.

Gracias
pawn Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Ingrese su clave", "Su clave debe contener letras y numeros.", "Siguiente", "");

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
            SetPVarString(playerid, "Clave", inputtext); //la almacenamos en Clave
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Ingrese su edad", "Pulsa siguiente.", "Siguiente", "");
        }
    }
    if(dialogid == 2)
    {
        if(response)
        {
            SetPVarInt(playerid, "Edad", inputtext);// Se almacena la edad
            ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Seleccione su genero", "Hombre\nMujer.", "Siguiente", "");
        }
    }
    if(dialogid == 3)
    {
        switch (listitem)
        {
            case 0:
            {
                                SetPVarInt(playerid, "Genero", 0); //Nombramos a la variable Genero, y le damos el valor 0, equivalente a hombre
                GuardarDatos(playerid);
            }
            case 1:
            {
                                SetPVarInt(playerid, "Genero", 1); //Nombramos a la variable de la misma forma, y le damos valor 1, equivalente a mujer
                GuardarDatos(playerid);
            }
        }
    }
    return 1;
}

stock GuardarDatos(playerid)
{
new clave[25]; //si consideramos que la contraseсa no va a contener mбs de 24 caracteres
           //guardarlos a MySQL
}
Para obtener el valor de la variable, se usarнa:
pawn Код:
GetPVarString(playerid, "Clave", clave, 25); //cogemos el valor de la variable Clave y lo llevamos a la otra, para procesarlo posteriormente.
/* GetPVarString(playerid, "Nombrevariable", variableguardado, longitudvariableguardado); */
GetPVarInt(playerid, "Edad");
GetPVarInt(playerid, "Genero");
Creo que seria asi, no sй si me he confundido en algo o no.
Reply


Messages In This Thread
Consulta sobre dialog y variables. - by YazukiAkira - 01.07.2014, 21:15
Respuesta: Consulta sobre dialog y variables. - by Kemula - 01.07.2014, 23:01
Respuesta: Consulta sobre dialog y variables. - by YazukiAkira - 02.07.2014, 01:38
Respuesta: Consulta sobre dialog y variables. - by Kemula - 02.07.2014, 08:09

Forum Jump:


Users browsing this thread: 1 Guest(s)