Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog System
#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 Code:
Code:
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; 
}  

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 Code:
Code:
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; 
}  

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 Code:
Code:
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 Code:
Code:
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 
Jim - Created this tutorial 
SA-MP Team - Created SA-MP
Y_Less - Sscanf
Zeex - ZCMD
PawnHunter - Strcat suggestion
MartinSwag - Defining suggestion
TheBetaFox - Strcat tutorial
Reply
#2
That's Nice .. Show us more
[Image: P3QQ3z2.gif]
Reply
#3
Thx for sharing @alimaroco.
But very old thread, must be closed.
Keep calm and enjoy elites host community!!!
You can ask me everything.
Skype:barcellonagameplay
Best regardz,
Joker >_<
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)