SampSharp icon indicating copy to clipboard operation
SampSharp copied to clipboard

Dialog Show Async - SampSharp.Entities.SAMP

Open AgustinIbanez00 opened this issue 2 years ago • 2 comments

Hi, i need to show a dialog asynchronously using SampSharp.Entities framework. How can i do that?

Thanks.

AgustinIbanez00 avatar Apr 02 '22 18:04 AgustinIbanez00

Hi!

Here's a simple example:

public class Issue400AsyncDialogs : ISystem
{
    [PlayerCommand("asyncdialog")]
    public async void ShowAsyncDialog(Player player, IDialogService dialogService)
    {
        var response = await dialogService.Show(player,
            new InputDialog { Caption = "Question", Content = "What's your favorite food?", Button1 = "OK" });

        if (response.Response == DialogResponse.LeftButton)
        {
            player.SendClientMessage($"You like {response.InputText}!");
        }
    }
}

ikkentim avatar Apr 02 '22 18:04 ikkentim

It worked for me, thank you very much.

May I suggest changing the method name to ShowAsync?

AgustinIbanez00 avatar Apr 04 '22 13:04 AgustinIbanez00

done.

ikkentim avatar Sep 19 '22 19:09 ikkentim