[Ayuda] Problema con OnDialogResponse
#1

Hola gente!
Bueno, estoy haciendo un sistema de configs. para mi Chatbot, pero tengo el problema de que el OnDialogResponse no funciona.

No se si me explico...
Les dejo el codigo para que lo entiendan mejor
pawn Код:
CMD:cbot(playerid, params[])
{
    if(!IsPlayerLuxAdminLevel(playerid, 5) || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, LIGHTBLUE, "Necesitas ser administrador para usar este Comando!");
    ShowPlayerDialog(playerid, BotD, DIALOG_STYLE_LIST, "Chatbot Configs", "Habilitar/Deshabilitar\nBloquear Player\nDesbloquear Player\nEnviar mensaje", "Aceptar", "");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == BotD)
    {
        if(response)
        {
            if(listitem == 0)
            {
                SwitchBot();
            }
            else if(listitem == 1)
            {
                ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, "Bloquear un Jugador", "", "Aceptar", "Cancelar");
            }
            else if(listitem == 2)
            {
                ShowPlayerDialog(playerid, botD2, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");
            }
            else if(listitem == 3)
            {
                ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, "Enviar un texto", "", "Aceptar", "Cancelar");
            }
        }
    }
   
    else if(dialogid == BotD1)
    {
        if(response)
        {
            new string[128], pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname, sizeof(pname));
       
            if(sscanf(inputtext, "d", bbid)) return ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");
            else
            {
                if(BBot[bbid] == 0)
                {
                    format(string, sizeof(string), "El jugador %s (%s) no esta bloqueado!", pname, bbid);
                    SendClientMessage(playerid, LIGHTBLUE, string);
                }
                else if(BBot[bbid] == 1)
                {
                    BBot[bbid] = 1;
                    format(string, sizeof(string), "El jugador %s (%s) fue bloqueado!", pname, bbid);
                    SendClientMessage(playerid, LIGHTBLUE, string);
                }
            }
        }
    }
   
    else if(dialogid == BotD2)
    {
        if(response)
        {
            new string[128], pname[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname, sizeof(pname));
            if(sscanf(inputtext, "d", bbid)) return ShowPlayerDialog(playerid, BotD2, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");
            else
            {
                format(string, sizeof(string), "El jugador %s (%s) fue desbloqueado!", pname, bbid);
                SendClientMessage(playerid, LIGHTBLUE, string);
                BBot[bbid] = 0;
            }
        }
    }
    else if(dialogid == BotD3)
    {
        if(response)
        {
            new string[128];
            if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, "Enviar un texto", "", "Aceptar", "Cancelar");
            else if(!isnull(inputtext))
            {
                format (string, sizeof(string), inputtext);
                SendBotMessage(inputtext);
            }
        }
    }
    return 1;
}
Chaoz, aver si me podes ayudar, vos seguro encontras el problema ajaj.

Yo intente varias cosas y nada me sirvio :S
Reply
#2

mira la verdad mientras leia el codigo vi un par de posibles bugs, y creo que te hiciste alto lio con estos dialogos. te reescribi el codigo e implementando switch que en estos casos es mejor que el if else if else if else.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid){
        case BotD:
            if(response){
                switch(listitem){
                    case 0: SwitchBot();
                    case 1: ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, "Bloquear un Jugador", "", "Aceptar", "Cancelar");
                    case 2: ShowPlayerDialog(playerid, botD2, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");
                    case 3: ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, "Enviar un texto", "", "Aceptar", "Cancelar");
                }
            }
        case BotD1:
            if(response){
                new str[128], name[MAX_PLAYER_NAME];
                if(sscanf(inputtext, "d", bbid))return ShowPlayerDialog(playerid, BotD1, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");
                if(!IsPlayerConnected(bbid))return SendClientMessage(playerid, RED, "ERROR: El jugador no se encuentra conectado");
                GetPlayerName(bbid, name, MAX_PLAYER_NAME);
                if(!BBot[bbid]){
                    BBot[bbid] = 1;
                    format(str, 128, "El jugador %s(%i) fue bloqueado!", name, bbid);
                    SendClientMessage(playerid, LIGHTBLUE, str);
                }
                else{
                    format(str, 128, "El jugador %s(%i) ya esta bloqueado!", name, bbid);
                    SendCLientMessage(playerid, RED, str);
                }
            }
        case BotD2:
            if(response){
                new str[128], name[MAX_PLAYER_NAME];
                if(sscanf(inputtext, "d", bbid)return ShowPlayerDialog(playerid, BotD2, DIALOG_STYLE_INPUT, "Desbloquear un Jugador", "", "Aceptar", "Cancelar");                   if(!IsPlayerConnected(bbid))return SendClientMessage(playerid, RED, "ERROR: El jugador no se encuentra conectado");
                if(!IsPlayerConnected(bbid))return SendClientMessage(playerid, RED, "ERROR: El jugador no se encuentra conectado");
                GetPlayerName(bbid, name, MAX_PLAYER_NAME);
                if(BBot[bbid]){
                    BBot[bbid] = 0;
                    format(str, 128, "El jugador $s(%i) fue desbloqueado!", name, bbid);
                    SendClientMessage(playerid, LIGHTBLUE, str);
                }
                else{
                    format(str, 128, "El jugador %s(%i) no esta bloqueado!", name, bbid);
                    SendClientMessage(playerid, LIGHTBLUE, str);
                }
            }
        case BotD3:
            if(response){
                if(isnull(inputtext)) return ShowPlayerDialog(playerid, BotD3, DIALOG_STYLE_INPUT, "Enviar un texto", "", "Aceptar", "Cancelar");
                SendBotMessage(inputtext);
            }
    }
    return 1;
}
decime si te funciona si hay algun error tene en cuenta q lo hice en un bloc de notas xq no tengo mi pc (N) esta es la de mi viejo y no tengo pawno ni otro similar y 0 ganas de descargarlo
Reply
#3

Quote:
Originally Posted by the_chaoz
Посмотреть сообщение
decime si te funciona si hay algun error tene en cuenta q lo hice en un bloc de notas xq no tengo mi pc (N) esta es la de mi viejo y no tengo pawno ni otro similar y 0 ganas de descargarlo
Lo que es el saber :P
Reply
#4

Negro, lo probe y nada :S.

Es igual que antes, solo funciona la primera opcion :/.
No entiendo porque, lo hice en base a dialogs echos por mi que funcionan perfectamente :S.
Tendre que hacer todo por comandos :/.
Es un garron, la primera vez que uso el dialog input, y no lo pude hacer funcionar :/.
Igual creo que es un problema del dialogo de lista.
Voy a hacer lo mismo pero por comandos.

Si se te ocurre una posible solucion, avisame.
Gracias HombreCaotico :B

Edit: Chaoz, el problema es cuando uso ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "titulo", "msje", "aceptar", "cancelar");

Probe por comandos y tampoco funciona.
Voy a buscar un sistema de registro&login y a tomar el ejemplo de ahi.
Gracias!
Reply
#5

dos cosas.
la 1є como definiste los ids de los dialogos?
la 2є no creo q esto tenga algo que ver pero fijate si agregandole un texto en el msj cambia algo.
Reply
#6

Chaoz, ya lo solucionй. (Cambie las IDs de los dialogs, antes eran #define BotD 1000, #define BotD1 1001, etc)
Pero ahora tengo otro problema xD.

En localhost funciona todo correctamente, es mas, es orgasmico ver como funciona todo.
Pero en el hosted no :/.
Mi host actual utiliza CentOS 5.

Si tienes alguna idea de por quй, me vendria de diez el dato.
Gracias :B
PD: El GM no utiliza dialogs, y ninguno de los FSs los usa tampoco.
PD2: Las IDs actuales son:
BotD 170
BotD1 171
BotD2 172, etc.
Reply
#7

esto lo tenes como un fs no?
Reply
#8

Sip.
Lo tengo incluido en mi FS de Banco, Duelos, y Chatbot xD.
Pero ni el banco ni el sistema de duelos utilizan Dialogs tampoco...
Actualmente, es lo unico que utiliza dialogs en el servidor.
Reply
#9

cargalo desde la consola y decime si te lo carga.
Reply
#10

No lo puedo cargar desde la consola xD.
Pero cuando lo cargo directo del server.cfg, me funciona el /cbot (menu principal), y ahora qe puse los comandos, me funcionan todos los comandos :S.
El problema es cuando uso /cbot, no funciona nada de ahi :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)