[Help] Dialogs doesn't respone for me.
#1

PHP код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
    
    if(
dialogid == DIALOG_REGISTER) {
        
GetPlayerIp(playerid,pIP[playerid],16);
        if(!
responseKick(playerid);
        if(!
strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new 
INI:iFile INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        
INI_SetTag(iFile,"data");
        
INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        
#if defined AUTOLOGIN
            
INI_WriteString(iFile,"IP",pIP[playerid]);
        
#endif
        
INI_WriteInt(iFile,"Cash",0);
        
INI_WriteInt(iFile,"Score",0);
        
INI_Close(iFile);
        
pLogged[playerid] = 1;
        new 
iStr[128];
        
format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        
SendClientMessage(playerid,yellow,iStr);
        return 
1;
    }
    if(
dialogid == DIALOG_LOGIN) {
        if(!
responseKick(playerid);
        new 
iStr[128],gTries;
        if(
gTries == 0gTries 1;
        if(
gTries == 3) { // 3 tries = kick
            
new pName[30];
            
GetPlayerName(playerid,pName,sizeof(pName));
            
format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
            
SendClientMessageToAll(red,iStr);
            return 
Kick(playerid);
        }
        if(!
strlen(inputtext)) {
            
format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
            return 
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
        }
        if(
udb_hash(inputtext) == pInfo[playerid][Pass]) {
            
pLogged[playerid] = 1;
            
SendClientMessage(playerid,lime,"You've successfully logged in.");
            
SetPlayerScore(playerid,pInfo[playerid][Score]); //Loading player score
            
GivePlayerMoney(playerid,pInfo[playerid][Cash]); //Loading player money
        
} else {
            
format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
            
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
            
gTries++;
            return 
1;
        }
        
            if(
dialogid == Msg_Dialog)
    {
        if(!
response) return 0;
        else
        {
            new 
string[128];
            if(!
strlen(inputtext)) return SendClientMessage(playerid,0xff0000ff,"You must to type a Message!");
            if(!
dini_Exists(MsgFile()))
            {
                
dini_Create(MsgFile());
            }
            
dini_Set(MsgFile(),"MSG",inputtext);
            
format(string,128,"Server message edited to : %s",inputtext);
            
SendClientMessage(playerid,0xffffffff,string);
        }
            return 
1;
    }
    if(
dialogid == DEIALOG_ID)
    {
        if(!
response) return 1;
        if(
listitem == sizeof(radiolist)) return OnPlayerCommandText(playerid,"/radio");
        if(
listitem == sizeof(radiolist)+1) return StopAudioStreamForPlayer(playerid),Radio[playerid] = false;
        
StopAudioStreamForPlayer(playerid);
        
PlayAudioStreamForPlayer(playerid,radiolist[listitem][0]);
        new 
str[50]; format(str,50,"Now listening to \"%s\"...",radiolist[listitem][1]);
        
SendClientMessage(playerid,0x33CCFFAA,str);
        
SendClientMessage(playerid,0xFFFFFFAA,"Stop listening: /MOFF");
        
Radio[playerid] = true;
        return 
1;
        }
    }
        return 
0;

When i click on the dialogs options nothing happens, it works before few day's.

Thanks for helpers!
Reply
#2

Debug your code with prints.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
Debug your code with prints.
Well i'm pretty newbie about prints, but i tried and nothing shown up in the console..
Reply
#4

Put a print on the first line inside the callback:

pawn Код:
public OnDialogResponse(...)
{
    print("OnDialogResponse was called");

    // All your code here
    return 1;
}
Does that get printed when you respond to a dialog?
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
Put a print on the first line inside the callback:

pawn Код:
public OnDialogResponse(...)
{
    print("OnDialogResponse was called");

    // All your code here
    return 1;
}
Does that get printed when you respond to a dialog?
Yes it get printed when i respond.
Reply
#6

try this one
pawn Код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
   
    if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }

    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) Kick(playerid);
        new iStr[128],gTries;
        if(gTries == 0) gTries = 1;
        if(gTries == 3)
        { // 3 tries = kick
            new pName[30];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
            SendClientMessageToAll(red,iStr);
            return Kick(playerid);
        }
        if(!strlen(inputtext))
    {
            format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
            return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
        }
        if(udb_hash(inputtext) == pInfo[playerid][Pass])
    {
            pLogged[playerid] = 1;
            SendClientMessage(playerid,lime,"You've successfully logged in.");
            SetPlayerScore(playerid,pInfo[playerid][Score]); //Loading player score
            GivePlayerMoney(playerid,pInfo[playerid][Cash]); //Loading player money
        }
    else
    {
            format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
            ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
            gTries++;
            return 1;
        }
    }
       
    if(dialogid == Msg_Dialog)
    {
        if(!response) return 0;
        new string[128];
        if(!strlen(inputtext)) return SendClientMessage(playerid,0xff0000ff,"You must to type a Message!");
        if(!dini_Exists(MsgFile()))
        {
            dini_Create(MsgFile());
        }
        dini_Set(MsgFile(),"MSG",inputtext);
        format(string,128,"Server message edited to : %s",inputtext);
        SendClientMessage(playerid,0xffffffff,string);
        return 1;
    }


    if(dialogid == DEIALOG_ID)
    {
        if(!response) return 1;
        if(listitem == sizeof(radiolist)) return OnPlayerCommandText(playerid,"/radio");
        if(listitem == sizeof(radiolist)+1) return StopAudioStreamForPlayer(playerid),Radio[playerid] = false;
        StopAudioStreamForPlayer(playerid);
        PlayAudioStreamForPlayer(playerid,radiolist[listitem][0]);
        new str[50]; format(str,50,"Now listening to \"%s\"...",radiolist[listitem][1]);
        SendClientMessage(playerid,0x33CCFFAA,str);
        SendClientMessage(playerid,0xFFFFFFAA,"Stop listening: /MOFF");
        Radio[playerid] = true;
        return 1;

    }
    return 0;
}
edit: ah, the indentation is fucked.
Reply
#7

Quote:
Originally Posted by emokidx111
Посмотреть сообщение
try this one
pawn Код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
   
    if(dialogid == DIALOG_REGISTER)
    {
        GetPlayerIp(playerid,pIP[playerid],16);
        if(!response) Kick(playerid);
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
        new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
        INI_SetTag(iFile,"data");
        INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
        #if defined AUTOLOGIN
            INI_WriteString(iFile,"IP",pIP[playerid]);
        #endif
        INI_WriteInt(iFile,"Cash",0);
        INI_WriteInt(iFile,"Score",0);
        INI_Close(iFile);
        pLogged[playerid] = 1;
        new iStr[128];
        format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
        SendClientMessage(playerid,yellow,iStr);
        return 1;
    }

    if(dialogid == DIALOG_LOGIN)
    {
        if(!response) Kick(playerid);
        new iStr[128],gTries;
        if(gTries == 0) gTries = 1;
        if(gTries == 3)
        { // 3 tries = kick
            new pName[30];
            GetPlayerName(playerid,pName,sizeof(pName));
            format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
            SendClientMessageToAll(red,iStr);
            return Kick(playerid);
        }
        if(!strlen(inputtext))
    {
            format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
            return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
        }
        if(udb_hash(inputtext) == pInfo[playerid][Pass])
    {
            pLogged[playerid] = 1;
            SendClientMessage(playerid,lime,"You've successfully logged in.");
            SetPlayerScore(playerid,pInfo[playerid][Score]); //Loading player score
            GivePlayerMoney(playerid,pInfo[playerid][Cash]); //Loading player money
        }
    else
    {
            format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
            ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
            gTries++;
            return 1;
        }
    }
       
    if(dialogid == Msg_Dialog)
    {
        if(!response) return 0;
        new string[128];
        if(!strlen(inputtext)) return SendClientMessage(playerid,0xff0000ff,"You must to type a Message!");
        if(!dini_Exists(MsgFile()))
        {
            dini_Create(MsgFile());
        }
        dini_Set(MsgFile(),"MSG",inputtext);
        format(string,128,"Server message edited to : %s",inputtext);
        SendClientMessage(playerid,0xffffffff,string);
        return 1;
    }


    if(dialogid == DEIALOG_ID)
    {
        if(!response) return 1;
        if(listitem == sizeof(radiolist)) return OnPlayerCommandText(playerid,"/radio");
        if(listitem == sizeof(radiolist)+1) return StopAudioStreamForPlayer(playerid),Radio[playerid] = false;
        StopAudioStreamForPlayer(playerid);
        PlayAudioStreamForPlayer(playerid,radiolist[listitem][0]);
        new str[50]; format(str,50,"Now listening to \"%s\"...",radiolist[listitem][1]);
        SendClientMessage(playerid,0x33CCFFAA,str);
        SendClientMessage(playerid,0xFFFFFFAA,"Stop listening: /MOFF");
        Radio[playerid] = true;
        return 1;

    }
    return 0;
}
edit: ah, the indentation is fucked.
What you changed here?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)