[Tutorial] Using & Understanding Dialogs

Results 1 to 6 of 6
  1. #1
    King Canadian whhacker93 is offline
    MemberRank
    Apr 2008 Join Date
    CanadaLocation
    926Posts

    [Tutorial] Using & Understanding Dialogs

    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


    • 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 Code:
    #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 Code:

    ShowPlayerDialog
    (playeridDIALOG_MESSAGEBOXDIALOG_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.

    ShowPlayerDialog - SA-MP Wiki
    Last edited by whhacker93; 01-12-13 at 07:11 PM.


  2. #2
    King Canadian whhacker93 is offline
    MemberRank
    Apr 2008 Join Date
    CanadaLocation
    926Posts

    Post Re: [TUTORIAL] Using Basic Dialogs

    Alright day 2 here..
    Understanding the input box and what it can be used for

    Today we will be going over the next type of dialog box.


    • Input Boxes - (DIALOG_STYLE_INPUT)



    This box is commonly used to allow users to input information that can be interpreted by someone or something on the other side.

    For example, you have a box that is used inside of a report system. You need the user to report another players name..

    The players name is taken from the input box. We then know the players name and we can now understand who and for what reasons this user was reported.

    Okay now that you understand what the input box is and what it can be used for lets get started with how we can use this input box script inside of our script.

    So firstly like yesterday we need to define this dialog at the top of our script.

    PHP Code:
    #define DIALOG_REPORTINPUT 96621 
    Just like we did when we defined our message box. I won't be explaining the definition again but it's the same concept, we define our dialog and give it a dialog id so the script understands which dialog we want our script to work with.

    Now the next step is to find a spot for it and call it accordingly.

    Making the input command and including ZCMD
    Okay we are going to need to make a command that will prompt our users the input box we defined.

    To do this we will first need to make a command.

    We will be using an include called ZCMD. I will explain to you what ZCMD is at the end of todays tutorial, for now.. lets continue.

    You'll need to get an include file which can be found there >
    zcmd.inc - Solidfiles

    Once you have the include file you'll need to locate your pawn main directory and then navigate to the include folder. It is a sub folder within the main pawn folder.

    Place the include that you have downloaded inside of the include folder.

    Now we need to include the .inc file inside of our script.

    To do this go to the top of the list and right under the first include you're going to add this line

    PHP Code:
    #include <zcmd> 
    Now we can move on with creating our command.

    Go to the call back
    OnPlayerCommandText(playerid, cmdtext[])
    Now you'll need to delete the entire callback or ZCMD will not work. Delete the callback and everything inside of the brackets.

    Now we will make the command in the same spot.

    PHP Code:
    CMDreport (playeridparams[])
    {
    ShowPlayerDialog(playerid,DIALOG_REPORTINPUTDIALOG_STYLE_INPUT"Report a Player""Enter the offending users name and a brief description of the offence.""Report""Cancel");



    What does all of this mean?


    • The first three letters of our command "CMD" is how ZCMD knows that we're telling it something. that's how the inc knows that we want to use it.
    • report is the name of the command that is what the user will input into the chat box to open up our report dialog.
    • playerid as I've previous explained is the id of the player that is executing this command.
    • params are the parameters of the command. They are left blank for the simplicity of this tutorial.


    What is ZCMD?
    ZCMD is a faster command processing unit. It is used to process commands faster than the default command processor. It's light weight and is just as efficient if not better than the standard processor.

    That settles it for the command, in the continuation of this tutorial I will show you how to handle the information that the user has submitted via our input box.

    Until tomorrow, see ya then!


    EDIT

    I apologize for the delay in the next continuation of this tutorial, I got a new job as a cashier while I'm taking courses for computer science so I'm a little full but I should have a few hours to spare tonight so I'll finish our tutorial then.


    Last edited by whhacker93; 05-12-13 at 07:53 PM.

  3. #3
    Apprentice Pink Silver is offline
    MemberRank
    Jan 2014 Join Date
    MontrealLocation
    5Posts

    Re: [Tutorial] Using & Understanding Dialogs

    Are you going to finish this?

  4. #4
    King Canadian whhacker93 is offline
    MemberRank
    Apr 2008 Join Date
    CanadaLocation
    926Posts

    Re: [Tutorial] Using & Understanding Dialogs

    I plan to finish this soon, no idea when as I don't have much time but soon.

  5. #5
    Valued Member Injected45 is offline
    MemberRank
    Nov 2014 Join Date
    142Posts

    Re: [Tutorial] Using & Understanding Dialogs

    its very helpful thanks

  6. #6
    King Canadian whhacker93 is offline
    MemberRank
    Apr 2008 Join Date
    CanadaLocation
    926Posts

    Re: [Tutorial] Using & Understanding Dialogs

    You're welcome, I still haven't found the time to finish up.



Advertisement