This tutorial will explain to you how you can create your very basic dialogs and use them in your script/server. Before we get started I will explain to you how the dialog systems actually work.
What are Dialogs?
Dialogs in SA:MP are just like the dialogs you would see on a standard windows operating system. Just like In windows Dialogs are used the same way In SA:MP.
They are used to display information.
They are used to make things easier and more clear to understand.
They are used to preform actions.
Such as displaying a button that can be clicked on to preform an action. Easiest to understand would be the "Close or OK" Button. These buttons normally come with information that a user must read and respond to by preforming the action( clicking on the buttons displayed) or another example would to be to call a function for example I have a register dialog and they are required to put a password in
Why should I use a dialog in SA:MP When I can use the chat box area?
Dialogs as I stated above are cleaner and with sa-mp It kinda makes your server look better, even more advanced. It also tells players that you have taken the time to build your server and make your script better to play. No one likes to sit there and have to type something in every time they want to preform an action. for example you can move your arrow keys to simply select an action you want to preform, without having to type another command in.
The types of dialog boxes that are available for you to use
Just to note.. the information that is within the opening "(" and closing ")" brackets are the actual STYLE names will be used inside of our dialog function next in this tutorial.
Okay I get it now but how do we display our dialog to our player?
The first thing you need to do is define our dialog boxes. so to do this you'll need to open up pawn and create or open a script if you haven't already done so.
So now you'll need to go to the top of your script right under the primary #include which is #include <a_samp>.
Once you are there we are going to be starting with a simple Message Box so add this define.
Huh DIALOG_MESSAGEBOX? 96620? What's that?
Well first of all as I listed above DIALOG_MESSAGEBOX is to tell SA:MP/PAWN what dialog style we are going to be using.
As for 96620 that is the number that we want to give our dialog. In reality it can anything but the reason why I prefer to add such a higher number instead of for example.. "1" is because it will help prevent DUPLICATE dialog IDS. They can be a pain in the ass and it will completely mess up your script. Your script will not run properly.
So that sums up the Define, moving forward.
What's next Devoted?
Now you need to actually call our dialog inside of a call back or stock.
BTW, stocks are functions just PAWNS way of saying function.
Okay so where are we calling it?
We are going to call it when a player connects..
So look for OnPlayerConnect and between the "{" & "}" brackets you will typing this in.
So this is the final explanation..
playerid is the id of the player that we want to show our messagebox to.
ShowPlayerDialog is the function that tells sa:mp that you want to show a player a dialog.
DIALOG_MESSAGEBOX is the name of dialog we defined above.
DIALOG_STYLE_MSGBOX is the type of dialog which was explained above.
The first parameter
in the open and closed quotation marks is our TITLE. We called in Login Message, that is what the player will see at the top of the dialog when it pops up.
The second parameter
is the information we want the user to know. In other words, the text we want to display.
Third and fourth
are the names to our buttons.
Okay so that's going to sum it up for today I still have 3 more dialogs to explain and they will be explained rest assured, I'll update this again daily until it is completed.
That's a promise. I keep my word.
So until tomorrow.
For those of you that want to read more about dialogs you can check out the wiki pages that SA:MP has made available.
What are Dialogs?
Dialogs in SA:MP are just like the dialogs you would see on a standard windows operating system. Just like In windows Dialogs are used the same way In SA:MP.
They are used to display information.
They are used to make things easier and more clear to understand.
They are used to preform actions.
Such as displaying a button that can be clicked on to preform an action. Easiest to understand would be the "Close or OK" Button. These buttons normally come with information that a user must read and respond to by preforming the action( clicking on the buttons displayed) or another example would to be to call a function for example I have a register dialog and they are required to put a password in
Why should I use a dialog in SA:MP When I can use the chat box area?
Dialogs as I stated above are cleaner and with sa-mp It kinda makes your server look better, even more advanced. It also tells players that you have taken the time to build your server and make your script better to play. No one likes to sit there and have to type something in every time they want to preform an action. for example you can move your arrow keys to simply select an action you want to preform, without having to type another command in.
The types of dialog boxes that are available for you to use
- Message Boxes - (DIALOG_STYLE_MSGBOX)
- Input Boxes - (DIALOG_STYLE_INPUT)
- List Boxes - (DIALOG_STYLE_LIST)
- Password Box - (DIALOG_STYLE_PASSWORD)
Just to note.. the information that is within the opening "(" and closing ")" brackets are the actual STYLE names will be used inside of our dialog function next in this tutorial.
Okay I get it now but how do we display our dialog to our player?
The first thing you need to do is define our dialog boxes. so to do this you'll need to open up pawn and create or open a script if you haven't already done so.
So now you'll need to go to the top of your script right under the primary #include which is #include <a_samp>.
Once you are there we are going to be starting with a simple Message Box so add this define.
PHP:
#define DIALOG_MESSAGEBOX 96620
Huh DIALOG_MESSAGEBOX? 96620? What's that?
Well first of all as I listed above DIALOG_MESSAGEBOX is to tell SA:MP/PAWN what dialog style we are going to be using.
As for 96620 that is the number that we want to give our dialog. In reality it can anything but the reason why I prefer to add such a higher number instead of for example.. "1" is because it will help prevent DUPLICATE dialog IDS. They can be a pain in the ass and it will completely mess up your script. Your script will not run properly.
So that sums up the Define, moving forward.
What's next Devoted?
Now you need to actually call our dialog inside of a call back or stock.
BTW, stocks are functions just PAWNS way of saying function.
Okay so where are we calling it?
We are going to call it when a player connects..
So look for OnPlayerConnect and between the "{" & "}" brackets you will typing this in.
PHP:
ShowPlayerDialog(playerid, DIALOG_MESSAGEBOX, DIALOG_STYLE_MSGBOX, "Login Message", "Welcome to my script! This is an awesome script and I like to use a ton of dialogs instead of those annoying /chat commands! WOO!!! ", "Close", "");
So this is the final explanation..
playerid is the id of the player that we want to show our messagebox to.
ShowPlayerDialog is the function that tells sa:mp that you want to show a player a dialog.
DIALOG_MESSAGEBOX is the name of dialog we defined above.
DIALOG_STYLE_MSGBOX is the type of dialog which was explained above.
The first parameter
in the open and closed quotation marks is our TITLE. We called in Login Message, that is what the player will see at the top of the dialog when it pops up.
The second parameter
is the information we want the user to know. In other words, the text we want to display.
Third and fourth
are the names to our buttons.
Okay so that's going to sum it up for today I still have 3 more dialogs to explain and they will be explained rest assured, I'll update this again daily until it is completed.
That's a promise. I keep my word.
So until tomorrow.
For those of you that want to read more about dialogs you can check out the wiki pages that SA:MP has made available.
To view the content, you need to sign in or register
Last edited: