SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 10/04/2019, 06:00 PM   #1
Graber
Banned
 
Join Date: Mar 2013
Location: Germany
Posts: 108
Reputation: 147
Default Task-based (async) dialog handling with PawnPlus

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
  • IllidanS4 for PawnPlus, which allows this and even more awesome stuff
  • TommyB for helping me test it out on a real environment
Graber is offline   Reply With Quote
Old 11/04/2019, 12:08 PM   #2
TommyB
Big Clucker
 
TommyB's Avatar
 
Join Date: Sep 2010
Location: Texas, USA.
Posts: 178
Reputation: 202
Default Re: Task-based (async) dialog handling with PawnPlus

best script
__________________
fired beta tester
TommyB is offline   Reply With Quote
Old 11/04/2019, 12:21 PM   #3
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 600
Reputation: 66
Default Re: Task-based (async) dialog handling with PawnPlus

Quote:
Originally Posted by TommyB View Post
best script
ever
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 11/04/2019, 12:26 PM   #4
Hazon
Big Clucker
 
Hazon's Avatar
 
Join Date: May 2018
Location: Who cares ?
Posts: 117
Reputation: 11
Default Re: Task-based (async) dialog handling with PawnPlus

https://www.yurtube.com/watch?v=tEDY0-vPFR8
Hazon is offline   Reply With Quote
Old 11/04/2019, 01:03 PM   #5
Yukie
Big Clucker
 
Yukie's Avatar
 
Join Date: Nov 2016
Location: Somewhere in PHILIPPINES
Posts: 86
Reputation: 0
Default Re: Task-based (async) dialog handling with PawnPlus

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

Discord: Yukie#5995|FB: @ichaaaannn
Reality Roleplay
samp.reality-rp.ml
Yukie is offline   Reply With Quote
Old 11/04/2019, 02:22 PM   #6
IllidanS4
Huge Clucker
 
IllidanS4's Avatar
 
Join Date: Feb 2013
Posts: 340
Reputation: 260
Default Re: Task-based (async) dialog handling with PawnPlus

Very nice!
__________________
PawnPlus
YSF
Yet Another Lua Plugin
Long Function Names
• i_quat.inc •


kingsofsa.cz:8888 running Cinematic Mode
IllidanS4 is offline   Reply With Quote
Old 11/04/2019, 02:56 PM   #7
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,054
Reputation: 359
Default Re: Task-based (async) dialog handling with PawnPlus

very nice
BigETI is offline   Reply With Quote
Old 11/04/2019, 03:41 PM   #8
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,950
Reputation: 500
Default Re: Task-based (async) dialog handling with PawnPlus

Nice
SyS is offline   Reply With Quote
Old 11/04/2019, 03:52 PM   #9
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 370
Reputation: 179
Default Re: Task-based (async) dialog handling with PawnPlus

epic
kristo is offline   Reply With Quote
Old 12/04/2019, 01:11 AM   #10
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Task-based (async) dialog handling with PawnPlus

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?
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] SPDLog - Fast async logging TheRealSphinx Plugin Development 7 15/05/2017 10:22 PM
async/threaded calls to natives ikkentim Plugin Development 6 14/01/2015 04:15 AM
Best way for handling custom textdraw menus? (enums, dialog style IDs) RajatPawar Scripting Help 2 08/10/2013 03:06 PM
[GameMode] [GM] Purgatoryserver SF:TDM (Inc. dialog based admin cp) ettans Gamemode Scripts 26 01/04/2012 09:54 AM
[help] how to make dialog based command mariomako Help Archive 3 12/05/2011 08:16 PM


All times are GMT. The time now is 03:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.