Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Releases Libraries [Library] Task-based (async) dialog handling with PawnPlus

 
  • 0 Vote(s) - 0 Average
Library Task-based (async) dialog handling with PawnPlus
Graber
Offline

open.mp Developer

Posts: 31
Threads: 4
Joined: Feb 2019
Reputation: 6
Location: Germany
#1
2019-04-13, 03:43 PM (This post was last modified: 2019-04-15, 09:26 AM by kristo.)
samp-async-dialogs

[Image: sampctl-samp--async--dialogs-2f2f2f.svg?...-the-badge]

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 allowing this and even more awesome stuff
  • TommyB for helping me test it out on a real environment
TommyB
Offline

discord-connector #1 fan

Posts: 34
Threads: 3
Joined: Feb 2019
Reputation: 6
Location: Texas, USA
#2
2019-04-13, 03:59 PM
best script
spacemud
Offline

open.mp Developer

Posts: 33
Threads: 1
Joined: Feb 2019
Reputation: 3
#3
2019-04-13, 04:07 PM
very nice
violator
Offline

Banned
Posts: 15
Threads: 1
Joined: Apr 2019
#4
2019-04-13, 04:17 PM
best nice
Toretto
Offline

Moderator

Posts: 40
Threads: 1
Joined: Apr 2019
Reputation: 4
#5
2019-04-13, 05:07 PM
(2019-04-13, 03:59 PM)TommyB Wrote: best script

ever
Markski
Offline

Burgershot Clerk

Posts: 127
Threads: 6
Joined: Apr 2019
Reputation: 5
Location: La Plata, Argentina
#6
2019-04-13, 06:05 PM
QUE BONITO
Website
JustMichael
Offline

Forum Manager

Posts: 189
Threads: 3
Joined: Feb 2019
Reputation: 17
Location: England
#7
2019-04-13, 06:34 PM
It's just so beautiful, tears of joy boys.
Remember to always refer to J0sh as `J0sh...`

@ Networks/Servers
San Andreas Gaming Network (Owner/Founder)
San Andreas Gaming (Owner/Founder)
Grand Theft Cop's n Robber's (Owner)
Britannia Roleplay (Owner/Founder)
Alpine RP (Owner/Founder)
Aluminium Network (Maintainer)
AlphaDM (Tech Support)

# Services
Burgershot.gg (Forum Manager)
open.mp (Member)

~ Languages/Frameworks
Pawn, C, C++, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,
Angular, React, Vue, Svelte, Laravel, Rocket
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode