Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Fast and simple dialog processor.
- *
- * Copyright (c) 2016 Anton Styazhkin (Untonyst).
- *
- * This software is provided 'as-is', without any express or implied warranty.
- * In no event will the authors be held liable for any damages arising
- * from the use of this software.
- *
- * Permission is granted to anyone to use this software for
- * any purpose, including commercial applications, and to alter it and
- * redistribute it freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- * claim that you wrote the original software. If you use this software in
- * a product, an acknowledgment in the product documentation would be
- * appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- * misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- */
- #if !defined _samp_included
- #error Please include <a_npc> or <a_samp> first.
- #endif
- #if defined _u_dialog_included
- #error Include <u_dialog> already included.
- #endif
- #define _u_dialog_included
- #if !defined MAX_FUNC_NAME
- #define MAX_FUNC_NAME (31)
- #endif
- #if !defined PRIVATE_DIALOG_ID
- #define PRIVATE_DIALOG_ID (32767)
- #endif
- #if !defined MAX_DIALOG_NAME
- #define MAX_DIALOG_NAME (MAX_FUNC_NAME)
- #endif
- #if !defined isnull
- #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
- #endif
- #define DialogResponse:%0(%1,%2,%3,%4)\
- forward %0(%1,%2,%3,%4);\
- public %0(%1,%2,%3,%4)
- static func_dlg[MAX_PLAYERS][MAX_DIALOG_NAME + 1 char];
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- #if defined OnDialogPerformed
- if (OnDialogPerformed(playerid, func_dlg[playerid],
- response, funcidx(func_dlg[playerid])) == 0)
- {
- return 0;
- }
- #endif
- if (dialogid == PRIVATE_DIALOG_ID)
- {
- if (inputtext[0] == '\0')
- {
- inputtext[0] = '\1';
- }
- else
- {
- new i, c;
- while ((c = inputtext[i]) != '\0')
- {
- if (c == '%')
- {
- inputtext[i] = '#';
- }
- i++;
- }
- }
- CallLocalFunction(func_dlg[playerid], "ddds",
- playerid, response, listitem, inputtext);
- return 1;
- }
- #if defined u_dlg__OnDialogResponse
- return u_dlg__OnDialogResponse(playerid, dialogid,
- response, listitem, inputtext);
- #else
- return 0;
- #endif
- }
- #if defined _ALS_OnDialogResponse
- #undef OnDialogResponse
- #else
- #define _ALS_OnDialogResponse
- #endif
- #define OnDialogResponse u_dlg__OnDialogResponse
- #if defined u_dlg__OnDialogResponse
- forward u_dlg__OnDialogResponse(playerid, dialogid,
- response, listitem, inputtext[]);
- #endif
- stock
- DialogShowForPlayer(playerid, function[],
- style, caption[], info[], button1[], button2[])
- {
- if (IsPlayerConnected(playerid) == 0)
- return 0;
- strpack(func_dlg[playerid], function);
- ShowPlayerDialog(playerid, PRIVATE_DIALOG_ID,
- style, caption, info, button1, button2);
- return 1;
- }
- #define ShowPlayerDialogEx DialogShowForPlayer
- #if defined OnDialogPerformed
- forward OnDialogPerformed(playerid, function[], response, success);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement