SA-MP Forums Archive
[Include] Task-based (async) dialog handling with PawnPlus - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Task-based (async) dialog handling with PawnPlus (/showthread.php?tid=665607)



Task-based (async) dialog handling with PawnPlus - Graber - 10.04.2019

samp-async-dialogs



Async dialog handling with PawnPlus tasks.

Installation

Simply install to your project:

Code:
sampctl package install AGraber/samp-async-dialogs
Include in your code and begin using the library:

Code:
#include <async-dialogs>
It is recommended that you set a PawnPlus version explicitely on your pawn.json (preferibly the latest) to avoid always downloading the latest one.

If you don’t use sampctl, just download the async-dialogs.inc include and drop it to your includes/ folder, and then download the PawnPlus plugin and include from here.

While you’re on it and if you don’t use PawnPlus yet, you should check it out!

Usage

This include provides one single function

Code:
AwaitAsyncDialog(playerid, dialog_response[e_DIALOG_RESPONSE_INFO], style, const caption[], const info[], const button1[], const button2[])
This will show the dialog and await for the response, which will pause the current script’s execution and return the yielded value to the last public function (or 0 if it wasn’t set). When it’s responded to, the response details will be inside the dialog_response[e_DIALOG_RESPONSE_INFO] array. If another dialog gets shown while awaiting, the Task will be discarded with any following code that was to be resumed.

Example command:

Code:
CMD:asyncdialog(playerid, params[])
{
    task_yield(1);

    new dialog_response[e_DIALOG_RESPONSE_INFO];
    AwaitAsyncDialog(playerid, dialog_response, DIALOG_STYLE_LIST, "Example dialog", "This is listitem 0\nAnd this is one\nShow example nested dialog", "ok", "no");

    if(dialog_response[E_DIALOG_RESPONSE_Response])
    {
        if(dialog_response[E_DIALOG_RESPONSE_Listitem] == 2)
        {
            new other_dialog_response[e_DIALOG_RESPONSE_INFO];
            AwaitAsyncDialog(playerid, other_dialog_response, DIALOG_STYLE_MSGBOX, "Example nested dialog", "You will recieve a message\nwhichever your response is", "OK", "Yes");

            SendClientMessage(playerid, COLOR_WHITE, "You responded something to the example dialog");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "Recieved: listitem = %d | inputtext = %s", dialog_response[E_DIALOG_RESPONSE_Listitem], dialog_response[E_DIALOG_RESPONSE_InputText]);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Bye!");
    }
}
Thanks



Re: Task-based (async) dialog handling with PawnPlus - TommyB - 11.04.2019

best script


Re: Task-based (async) dialog handling with PawnPlus - TheToretto - 11.04.2019

Quote:
Originally Posted by TommyB
View Post
best script
ever


Re: Task-based (async) dialog handling with PawnPlus - Hazon - 11.04.2019

https://www.yurtube.com/watch?v=tEDY0-vPFR8


Re: Task-based (async) dialog handling with PawnPlus - Yukie - 11.04.2019

how it works? im new btw.. sorry for being noob..


Re: Task-based (async) dialog handling with PawnPlus - IllidanS4 - 11.04.2019

Very nice!


Re: Task-based (async) dialog handling with PawnPlus - BigETI - 11.04.2019

very nice


Re: Task-based (async) dialog handling with PawnPlus - SyS - 11.04.2019

Nice


Re: Task-based (async) dialog handling with PawnPlus - kristo - 11.04.2019

epic


Re: Task-based (async) dialog handling with PawnPlus - Pottus - 12.04.2019

Nice an alternative to using y_inline/y_dialog! I would guess it shouldn't be a problem to nest multiple dialogs within the same function?


Re: Task-based (async) dialog handling with PawnPlus - TommyB - 12.04.2019

Quote:
Originally Posted by Pottus
View Post
Nice an alternative to using y_inline/y_dialog! I would guess it shouldn't be a problem to nest multiple dialogs within the same function?
Nope! You shouldn't have any issue using multiple dialogs in one function.