Dialogs Dissapearing(Script noob)
#1

My problem is simple.

I install an FS with dialog boxes, it works. When I open a dialog, I click a button. Instead of returning the desired effect or continuing to the next dialog, it goes away and nothing happens. I'm currently experiencing this with

http://www.******************/post/D...systems-17348/

^^ that filterscript.

Here's the gamemode I'm using(Some freeroam I downloaded for the purpose of doing some LAN games with friends)

http://pastebin.com/xiG5zAC1

(I have very little coding knowledge )
Reply
#2

Make sure all of your DIALOG_IDS in each script are unique. If you have a dialog in your gamemmode that has the same ID as a dialog in a filterscript, you will get conflicts (dialogs dissapearing or worse some code from another dialog gets executed) - If you don't return from the callback correctly.

EG, If you have a register dialog in your gamemode that is ID: 1, and in one of your filterscripts you have a race dialog with ID: 1, the server will execute the first dialog with that ID.

EDIT:
Also keep in mind you should return '0' if no dialog was found. See 'return value' note. https://sampwiki.blast.hk/wiki/OnDialogResponse
Notice in the examples on the wiki '0' is returned when no dialogid is found (see comments!).
Reply
#3

I barely understood that :S So I should do something like add another digit to each dialog ID in the FS?

Like:

Return: 1
Return: 2
Return:3

becomes

Return: 91
Return: 92
Return: 93

?
Reply
#4

No.

Код:
ShowPlayerDialog(playerid, DIALOG_ID, ...)
Make sure all your DIALOG_ID are unique cross script.

And return 0 if a dialog isnt executed in a script. See comments on the wiki.
Quote:
Originally Posted by samp wiki
Returning 0 in this callback will pass the dialog to another script in case no matching code were found in your gamemode's callback.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_RULES)
    {
        if(response) // If they clicked 'Yes' or pressed enter
        {
            SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
        }
        else // Pressed ESC or clicked cancel
        {
            Kick(playerid);
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
Reply
#5

Ok, then change all those IDs to a unique number?
Reply
#6

Yes they need to be unique, and make sure you return '0' if a dialogid isn't matched in EVERY script (see comments on wiki) this is very important.
Reply
#7

What do you mean by the dialogid being matched?

Do I just need to change the dialogids, or is there anything else that needs to change?
Reply
#8

1) Dialog ids must be unique.

2) Read the comments in the following code, it illustrates it better than i can explain it.

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_RULES)
    {
        if(response)
        {
            SendClientMessage(playerid, COLOR_GREEN, "Thank you for agreeing to the server rules!");
        }
        else // Pressed ESC or clicked cancel
        {
            Kick(playerid);
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText. <<<<<
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText. <<<<<
}
If you return '1' from OnDialogResponse in your gamemmode, then OnDialogResponse will NOT get executed in your filterscripts.
Reply
#9

Urgh, I'm such a n00b... -_- Those comments just confuse me more.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)