samp.directory
← Scripts y librerías

hreesang/samp-pp-dialogs

An open.mp/SA:MP library that provides functions to display dialogs with asynchronous responses

Librería★ 8actualizado mar 2023Sin licenciaPawnsampctl
Abrir en GitHub

Este repositorio no tiene archivo de licencia. Se puede leer, pero eso por sí solo no da permiso para reutilizarlo.

Instalar con sampctl

sampctl package install hreesang/samp-pp-dialogs

Ejecútalo en la carpeta de tu proyecto. sampctl descarga el paquete y sus dependencias.

README.md

samp-pp-dialogs

Installation

Simply install to your project:

sampctl install Hreesang/samp-pp-dialogs

Include in your code and begin using the library:

#include <pp_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 pp_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

Task:ShowPlayerAsyncDialog(playerid, DIALOG_STYLE: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 responses[E_ASYNC_DIALOG] array. If another dialog gets shown while awaiting, the Task will be discarded with any following code that was to be resumed.

For comfortability, it also provides support for PawnPlus strings:

ShowPlayerDialogStr(playerid, dialogid, DIALOG_STYLE:style, ConstString:caption, ConstString:info, ConstString:button1, ConstString:button2 = ConstString:STRING_NULL);
Task:ShowPlayerAsyncDialogStr(playerid, DIALOG_STYLE:style, ConstString:caption, ConstString:info, ConstString:button1, ConstString:button2 = ConstString:STRING_NULL);

Example

static TestAsyncDialog(playerid)
{
	yield 1;
	new Task:t = ShowPlayerAsyncDialog(
		playerid,
		DIALOG_STYLE_MSGBOX,
		"Hello World | Async Dialog",
		"Through TestAsyncDialog, the World says \"Hello World.\"",
		"Hi!",
		"Ok!"
	);
	new responses[E_ASYNC_DIALOG];
	await_arr(responses) t;

	new string[144];
	format(
		string,
		sizeof(string),
		"Script: TestAsyncDialog - Response: %s",
		responses[E_ASYNC_DIALOG_RESPONSE] ? "true" : "false"
	);
	SendClientMessage(playerid, -1, string);
}

static TestAsyncDialogStr(playerid)
{
	yield 1;
	new Task:t = ShowPlayerAsyncDialogStr(
		playerid,
		DIALOG_STYLE_MSGBOX,
		str_new_static("Hello World | Async Dialog Str"),
		str_new_static("Through TestAsyncDialogStr, the World says \"Hello World.\""),
		str_new_static("Hi!"),
		str_new_static("Ok!")
	);
	new responses[E_ASYNC_DIALOG];
	await_arr(responses) t;

	new string[144];
	format(
		string,
		sizeof(string),
		"Script: TestAsyncDialogStr - Response: %s",
		responses[E_ASYNC_DIALOG_RESPONSE] ? "true" : "false"
	);
	SendClientMessage(playerid, -1, string);
}

What's the Difference?

You might be wondering that because this library is quite similar with async-dialogs. Well, I have this library privately in my script because of some preference reasons. I don't find comfortable with the async-dialogs enumerator naming convention, and also there's a bug in there that messes up my script dialog IDs. I suspected that the bug happens because I have some libraries which hook the dialog functions and callback in my script, and the async-dialogs doesn't trigger the hooks because it directly calls the native.

Thanks

  • IS4Code for PawnPlus, which allows this and even more awesome stuff
  • AGraber for async-dialogs, most of the concept is from there, even the README.md is from there
  • Y-Less for Pre-Hooks snippets

dialogopenmppawnplussamp

Esta página se genera con lo que GitHub publica sobre el repositorio. samp.directory no aloja el código. Informar de un problema con esta ficha

hreesang/samp-pp-dialogs: Librería de SA-MP | samp.directory