31.01.2012, 22:09
(
Последний раз редактировалось MP2; 09.02.2013 в 17:25.
)
Dialog Buffer v1.1
by MP2
I am no longer supporting this include, as it is rather bugged (see 'known bugs' below). If anyone can fix it that would be awesome. PM me the revisions and I'll update this and give you credit.by MP2
Introduction
This is a fairly simple include that "buffers" dialogs when they are shown while one is already shown for the player.
Say you have a quiz with 5 dialogs. You also have a command to offer guns to a player. When you offer to sell the guns to a player, it opens a dialog menu on their screen with all the weapons. What if you're on the 4th dialog in the quiz and suddenly it gets closed because of the weapon menu? This include prevents that.
While it may not seem amazingly useful - if you need it, it's here. I'm not going to lie and say that it's extremely useful, it's just that nobody has made it before* and it can be quite useful for some people.
* If they have, feel free to correct me.
EDIT: Turns out ****** was planning to make this, but I beat him to it!
P.S. I'm not fully certain if "buffer" is the correct term, but I like it so deal with it :>
Changelog
1.0 (31st Jan 2012):
- Initial release
1.1 (1st March 2012):
- Added 'force' parameter to ShowPlayerDialog to instantly show a dialog (if a dialog is already shown, it will be re-shown after the forced dialog is closed)
- Added two callbacks:
* OnDialogShowForPlayer(playerid, dialogid); - Called when a dialog is shown for a player
* OnDialogForceClose(playerid, dialogid); - Called when a dialog is forced to close (NOTE: it will be re-shown when the current FORCED dialog is closed)
- Automatic dialog color setting. Allows you to color all dialogs the same, instead of the ugly default grey.
- Fixed problem with return code in hooked OnDialogResponse that caused problems when using dialogs in filterscripts (OnDialogResponse wasn't being called)
Compare .inc files: http://diffchecker.com/870c9f4
NOTE: I have not tested this thoroughly. Please report any bugs in this topic or PM them to me. You will receive reputation for reporting bugs.
Future Plans
- An 'extraid' parameter in the dialog, to pass, for example, an extra player ID (e.g. the weapon-selling dialog I mentioned in a previous example).
Known Bugs
If you show a forced dialog, then show another, when the first one is closed a dialog with empty caption, info and buttons is shown.
Usage
There is no 'usage' as such, just use ShowPlayerDialog() as you normally would, the function is automatically 'changed' to add the buffering.
If you wanted to show 3 dialogs in a row, without messing around with response code, you can just do this:
pawn Код:
ShowPlayerDialog(playerid, DIALOG_BLAH, DIALOG_STYLE_MSGBOX, "Dialog 1", "Info", "Next", "");
ShowPlayerDialog(playerid, DIALOG_BLAH, DIALOG_STYLE_MSGBOX, "Dialog 2", "Info", "Next", "");
ShowPlayerDialog(playerid, DIALOG_BLAH, DIALOG_STYLE_MSGBOX, "Dialog 3", "Info", "Close", "");
I also added GetPlayerDialog(playerid). Pretty self explanatory.
NEW: Forced dialogs
In version 1.1 I added an extra parameter to the end of ShowPlayerDialog, called 'force'. If this is set to 1, the dialog is shown instantly, closing any open dialogs. The que will resume after the forced dialog is closed. OnDialogForceClose is called to signify which dialog was forced to close. No action should be required, however.
If you want to just add it to the que, just leave the parameter out, and use the default ShowPlayerDialog syntax. Unfortunately I can't make the new 'force' parameter show up in pawno, so this is the only way you will know about it.
If you set a variable when you show a dialog, for example if you show a 'Would you like to buy weapons from x' dialog, and you set the pWeaponBuy[playerid] variable to the ID of the player who is offering weapons, you must put this code under OnDialogShowForPlayer, not next to your ShowPlayerDialog lines. This will prevent mix-ups and clashes. EDIT: Just realised this won't really work until I add an 'extraid' parameter. Will be in v1.2.
Installation
• Download the .inc file below
• Place it in C:\Program Files\Rockstar Games\GTA San Andreas\pawno\include (or where ever your include folder is)
• Add " #include <dbuffer> " at the top of your gamemode like so:
Код:
#include <a_samp> #undef MAX_PLAYERS #define MAX_PLAYERS 32 // How many slots you have - important! #include <dbuffer>
• If you wish for more than 10 dialogs to be buffered, change the value of MAX_DIALOGS in the .inc file.
• Download YSI HERE
• Nothing more! No functions to use or anything, essentially plug and play. Just use ShowPlayerDialog as you normally would.
NOTE: Using this in a gamemode and showing a dialog from a filterscript may cause problems. I'm not sure if you can use it in both.
NOTE: Not re-defining MAX_PLAYERS between a_samp and dbuffer will not cause any problems. Leaving it out will use the one defined in a_samp, which is 500. It just seems a waste of memory.
Setting it to something lower than the actual slots will cause you problems when you have more players than that.
Download
www.movieserv.net/files/dbuffer.inc
OLD VERSIONS:
http://www.movieserv.net/files/dbuffer_v1.0.inc
No mirrors please. This is my own website, so the link should never go down. If it does, PM me.
Thank you!
Please leave a comment below, maybe with a suggestion! Don't forget to report any bugs also please.
Thank you.