30.10.2015, 08:06
(
Последний раз редактировалось Karan007; 01.11.2015 в 06:12.
)
Hello guys,
today i'm going to show you how to detail anything you want in any dialog! That's very easy but yet some people do not know how to do so. So, i made this tutorial to show them some examples of it. So, without wasting times, we'll start our tutorial!
So, about using formats, it's really very simple. I'll show you an example of it right now.
You see, it's very simple. But now, instead of using SendClientMessage, we will change it to ShowPlayerDialog!
Format explained more easily here!
So, now we will change the same thing to showplayerdialog!
So now, we have formatted it to ShowPlayerDialog!
Additional Note: While formatting to message, use \n for the dialog to skip one line! And also instead of usig DIALOG_STYLE_MSGBOX you can use any type of dialog style, this doesn't require only DIALOG_STYLE_MSGBOX!
So, we use strcat to make really long dialog without making them crashing, strcat has also other more purposes.
Here, strcat is more explained!
So, now we are going to define the IDs of the dialogs we are going to be using. Defining dialogs are important! If we do not define them, we can make another dialog and use an already defined id for a dialog. So, let's proceed in for more information.
Credits
Karan007 - Created this tutorial
SA-MP Team - Created SA-MP
****** - Sscanf
Zeex - ZCMD
PawnHunter - Strcat suggestion
MartinSwag - Defining suggestion
TheBetaFox - Strcat tutorial
Enjoy!
today i'm going to show you how to detail anything you want in any dialog! That's very easy but yet some people do not know how to do so. So, i made this tutorial to show them some examples of it. So, without wasting times, we'll start our tutorial!
STEP 1 - USING FORMAT
So, about using formats, it's really very simple. I'll show you an example of it right now.
PHP код:
CMD:name(playerid,params[])
{
new string[128], /*This is to define the string and the size of it*/ pName[MAX_PLAYER_NAME]; // Name variable
GetPlayerName(playerid, pName, sizeof(pName)); // Getting the player name
format(string, sizeof(string), "Your name is %s with ID %i !", pName, playerid); // Formatting the message
SendClientMessage(playerid, -1, string); // Sending the message to the player
return 1;
}
Format explained more easily here!
STEP 2 - SHOWPLAYERDIALOG
So, now we will change the same thing to showplayerdialog!
PHP код:
CMD:name(playerid,params[])
{
new string[128], /*This is to define the string and the size of it*/ pName[MAX_PLAYER_NAME]; // Name variable
GetPlayerName(playerid, pName, sizeof(pName)); // Getting the player name
format(string, sizeof(string), "Your Name: %s \n Your ID: %i", pName, playerid); // Formatting the message
ShowPlayerDialog(playerid, 21, DIALOG_STYLE_MSGBOX, "EXAMPLE" , string , "Ok", ""); // ShowPlayerDialog
return 1;
}
Additional Note: While formatting to message, use \n for the dialog to skip one line! And also instead of usig DIALOG_STYLE_MSGBOX you can use any type of dialog style, this doesn't require only DIALOG_STYLE_MSGBOX!
STEP 3 - STRCAT
So, we use strcat to make really long dialog without making them crashing, strcat has also other more purposes.
Here, strcat is more explained!
PHP код:
CMD:name(playerid,params[])
{
new Dialog[128], /*This is to define the string and the size of it*/ pName[MAX_PLAYER_NAME]; // Name variable
GetPlayerName(playerid, pName, sizeof(pName)); // Getting the player name
format(Dialog, sizeof(Dialog), "Your Name: %s ", pName); // Strcat
format(Dialog, sizeof(Dialog), "Your ID: %i ", playerid); // Strcat
// You can add more formats here
ShowPlayerDialog(playerid, 21, DIALOG_STYLE_MSGBOX, "EXAMPLE" , Dialog , "Ok", ""); // ShowPlayerDialog
return 1;
}
STEP 4 - DEFINE THEM
So, now we are going to define the IDs of the dialogs we are going to be using. Defining dialogs are important! If we do not define them, we can make another dialog and use an already defined id for a dialog. So, let's proceed in for more information.
PHP код:
enum
{
DIALOG_NAME
}
#define DIALOG_NAME 1
CMD:name(playerid,params[])
{
new string[128], /*This is to define the string and the size of it*/ pName[MAX_PLAYER_NAME]; // Name variable
GetPlayerName(playerid, pName, sizeof(pName)); // Getting the player name
format(string, sizeof(string), "Your Name: %s \n Your ID: %i", pName, playerid); // Formatting the message
ShowPlayerDialog(playerid, DIALOG_NAME, DIALOG_STYLE_MSGBOX, "EXAMPLE" , string , "Ok", ""); // ShowPlayerDialog and using defined dialog IDs
return 1;
}
END OF TUTORIAL
Credits
Karan007 - Created this tutorial
SA-MP Team - Created SA-MP
****** - Sscanf
Zeex - ZCMD
PawnHunter - Strcat suggestion
MartinSwag - Defining suggestion
TheBetaFox - Strcat tutorial
Enjoy!