[Include] Better Dialogs
#1

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: Comments are appreciated.
Reply
#2

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

I uploaded the wrong version.
Reply
#3

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

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

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.
Reply
#6

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.
Reply
#7

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

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.
Reply
#9

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

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)