![]() |
|
[Library] LiveDialogs.inc - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Releases (https://forum.open.mp/forumdisplay.php?fid=13) ---- Forum: Libraries (https://forum.open.mp/forumdisplay.php?fid=31) ---- Thread: [Library] LiveDialogs.inc (/showthread.php?tid=3727) |
LiveDialogs.inc - vawylon - 2025-12-19 LiveDialogs https://github.com/vawylon/LiveDialogs LiveDialogs — Allows you to write multi-level dialogs in a single function without duplicating logic between “opening” and “handling the response”. Example: ```c CMD:menu(playerid) { Dialog_Create(playerid, Dialog:Menu); } dialog Menu(playerid) { Create:<"Money"> { // when pressing "Back" we will close the dialog ResponseRight: return DIALOG_CLOSE; // using a loop we create 10 items for (new i = 1, amount; i <= 10; i++) { new amount = i * 20000; ListItem:<"Get %d$", amount> { GivePlayerMoney(playerid, amount); SendClientMessage(playerid, -1, "You received {44FF44}%d$", amount); return DIALOG_REOPEN; // Reopen the dialog } } ListItem:<"Experience"> { // Dialog when selecting the "Experience" item Create:<"Get experience"> { // Go back in case "Back" is pressed ResponseRight: return DIALOG_BACK; ListItem:<"1 EXP"> { SetPlayerLevel(playerid, GetPlayerLevel(playerid) + 1); SendClientMessage(playerid, -1, "You received {FFCC44}%d EXP", 1); return DIALOG_BACK; } ListItem:<"Enter value"> { // Create a dialog when selecting value input Create:<"Get experience"> { // Go back in case "Back" is pressed ResponseRight: return DIALOG_BACK; InputText:<"Enter amount of experience"> { new exp = Dialog_Number(playerid); if (exp <= 0) { // Reopen the dialog if the number is not valid SendClientMessage(playerid, -1, "Invalid value entered!"); return DIALOG_REOPEN; } SetPlayerLevel(playerid, GetPlayerLevel(playerid) + exp); SendClientMessage(playerid, -1, "You received {FFCC44}%d EXP", exp); return DIALOG_BACK; } } Button:<"Give", "Back">; } } Button:<"Select", "Back">; } } Button:<"Select", "Close">; } ``` |