[Tutorial] Detailing in dialogs - Easy For Newbies
#1

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!

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(playeridpNamesizeof(pName)); // Getting the player name
    
format(stringsizeof(string), "Your name is %s with ID %i !"pNameplayerid); // Formatting the message
    
SendClientMessage(playerid, -1string); // Sending the message to the player
    
return 1;

You see, it's very simple. But now, instead of using SendClientMessage, we will change it to ShowPlayerDialog!

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(playeridpNamesizeof(pName)); // Getting the player name
    
format(stringsizeof(string), "Your Name: %s \n Your ID: %i"pNameplayerid); // Formatting the message
    
ShowPlayerDialog(playerid21DIALOG_STYLE_MSGBOX"EXAMPLE" string "Ok"""); // ShowPlayerDialog
    
return 1;

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!

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(playeridpNamesizeof(pName)); // Getting the player name
    
format(Dialogsizeof(Dialog), "Your Name: %s "pName); // Strcat
    
format(Dialogsizeof(Dialog), "Your ID: %i "playerid); // Strcat
    // You can add more formats here
    
ShowPlayerDialog(playerid21DIALOG_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(playeridpNamesizeof(pName)); // Getting the player name
    
format(stringsizeof(string), "Your Name: %s \n Your ID: %i"pNameplayerid); // Formatting the message
    
ShowPlayerDialog(playeridDIALOG_NAMEDIALOG_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!
Reply


Messages In This Thread
Detailing in dialogs - Easy For Newbies - by Karan007 - 30.10.2015, 08:06
Re: Detailing in dialogs - Easy For Newbies - by Ritzy2K - 30.10.2015, 08:14
Re: Detailing in dialogs - Easy For Newbies - by iKarim - 30.10.2015, 08:25
Re: Detailing in dialogs - Easy For Newbies - by MartinSwag - 30.10.2015, 08:42
Re: Detailing in dialogs - Easy For Newbies - by Karan007 - 30.10.2015, 09:04
Re: Detailing in dialogs - Easy For Newbies - by Sudaisx - 30.10.2015, 09:10
Re: Detailing in dialogs - Easy For Newbies - by Karan007 - 30.10.2015, 11:45
Re: Detailing in dialogs - Easy For Newbies - by HydraHumza - 30.10.2015, 13:07
Re: Detailing in dialogs - Easy For Newbies - by Karan007 - 30.10.2015, 16:03

Forum Jump:


Users browsing this thread: 1 Guest(s)