SA-MP Forums Archive
[Include] Better Dialogs - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Better Dialogs (/showthread.php?tid=215084)



Better Dialogs - Gabe - 22.01.2011

Hello all,

I had started programming my own gamemode when I realized that the way OnDialogResponse is handled is messy and confusing. Henceforth, I made my own include for it. I decided to share this with you all in hopes that it helps make scripting easier.

The function is called based on the dialog ID and which button was clicked.

Please note that this works perfectly, but I have future plans for it also.

Syntax:
Код:
Dialog:[dialogID]_[Btn1 or Btn2](listitem, playerid, inputtext[]){
return 1;
}
Usage Example:

PHP код:
#include <dialog>
public OnPlayerConnectplayerid )
    {
    
ShowPlayerDialogplayerid0DIALOG_STYLE_INPUT" ""Welcome to Project Fresh. Please login with your username below or register.""Next >>""<Register>" );
    return(
1);
    }
 
Dialog:0_Btn1(listitemplayeridinputtext[]){
                    
SetPlayerName(playeridinputtext);
                         return(
1);
 }
 
 
Dialog:0_Btn2(listitemplayeridinputtext[]){
                    
SendClientMessageplayeridX11_ANTIQUEWHITE1"This account is not registered, and registrations are closed, sorry!" );
                         return(
1);
 } 
Note that if you leave one of the button functions undefined, it will still work, and it will work with your current script.

Credits: ****** to his library hooks.

Download:
Код:
http://gabe.me/dialog.inc
Comments are appreciated.


Re: Better Dialogs - Gabe - 22.01.2011

Quick fix, anyone who downloaded it in the last minute must redownload. xD

I uploaded the wrong version.


Re: Better Dialogs - Pooh7 - 22.01.2011

Why simply not use if(response) for button 1 and if(!response) for button 2?


Re: Better Dialogs - olaf137 - 22.01.2011

I prefer having only one public per dialog. So i modified it a bit. But its still an awesome script.
Tiny but usefull.


Re: Better Dialogs - playbox12 - 22.01.2011

I don't really get the point, like Pooh7 said, you just use if(response) for the first button and if(!reponse) for the second button, it basicly does the same thing. I haven't looked in the source though, but I think it will be slower, and I find this much more confusing.


Re: Better Dialogs - Gabe - 22.01.2011

The reason that I use this is because putting all of the different functions in one function (OnDialogResponse) is programmatically incorrect, and to better be used by someone like me, where each feature in my game mode is in it's own include file.

If you look at a script with many dialogs, OnDialogResponse is the ugliest thing.

EDIT:
It's useful to me, I just though someone else might appreciate it. If you don't find it useful, don't use it.


Re: Better Dialogs - Sellize - 03.04.2015

Well done, Gabe. In my opinion this is much more well-arranged than the regular OnDialogResponse.


Re: Better Dialogs - Crayder - 03.04.2015

Quote:
Originally Posted by Sellize
Посмотреть сообщение
Well done, Gabe. In my opinion this is much more well-arranged than the regular OnDialogResponse.
Nice bump! There are far better systems nowadays.


Re: Better Dialogs - Pottus - 03.04.2015

If your using YSI why not just use y_inline/y_dialog it's by far the best way.


Re: Better Dialogs - PaulDinam - 04.04.2015

Quote:
Originally Posted by Pottus
Посмотреть сообщение
If your using YSI why not just use y_inline/y_dialog it's by far the best way.
I prefer hooking dialog responses, but either way would be organized.