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:
CMD: report (playerid, params[])
{
ShowPlayerDialog(playerid,DIALOG_REPORTINPUT, DIALOG_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.