21.11.2009, 12:11
Hello everyone, this is my first tutorial.
Please give you good time to read it!
This is not copyed from any other tutorial, i wrote it in free hand!
I wanted to make this tuturial because when i wanted to learn it, I had to mix two other tuturials together to get the right answer
Okay, lets start.
First you need two know the difference types of Dialog you can make, there's:
The LIST is where you list up a few things to pick from, just like the old menus ( i think its easier to make than the old one )
The INPUT is where you need to write something in then press a button
Lets take it one part at a time:
Well, we can start making a MSGBOX, if you press continue you'll enter the server, if you press Quit you'll be kicked, thats easiest.
go in your script. find OnPlayerConnect and write it like this:
Edit: Headline and Welcomings message
Now you've told your server that when the player connects to your server a dialog with MSGBOX as style will pop up and tell you what you wrote in headline and Welcoms message.
Now you need to find OnDialogResponse in your script, OnDigaloResponse means what the server should response to the to buttons that can be clicked. Type in like this:
Now, this tells the server that dialogid 1 was shown to the player and if he/she selected continue then he/she'll be allowed to enter the server, with the message "Enjoy your stay!". If he/she selected quit he/she got kicked with the message "You selected 'Quit', therefore you got kicked. Goodbye!".
Now you created a Dialog with style MSGBOX
And Now we'll make a Dialog with style LIST
This is the second easiest to make, all the dialogs kinda works on the same way.
Let me explain it again, word for word.
Type like this:
Now you told the server, if a player types the command /teleport a dialog with style LIST appers where he can pick between Los Santos Police Department and Unity Station
To tell the server where Los Santos Police Department and Unity station is, find OnDialogResponse. OnDialogResponse means what the server is gonna do when the player selects something and clicks a button.
Type it like this:
I'll explain what happend now.
When the player selects Los Santos Police Department or Unity Station it will send the player the message "You selected Unity Station / Los Santos Police Department, and got teleported to there!"
Remember when you wanna list more items on the list you need to add them in the OnPlayerCommandText, the way you write them in the line you MUST add them in the OnDialogResponse the same way! else it will be some mess.
The Listitem
Is the number of the listed item, the first on the list is numbed with 0 the second is number 1, next number 3 and so on.
Well, That'll be it from me. hope you can use it. If theres any questions then just ask away
Made by Niixie
Please give you good time to read it!
This is not copyed from any other tutorial, i wrote it in free hand!
I wanted to make this tuturial because when i wanted to learn it, I had to mix two other tuturials together to get the right answer
Okay, lets start.
First you need two know the difference types of Dialog you can make, there's:
- DIALOG_STYLE_MSGBOX
- DIALOG_STYLE_LIST
- DIALOG_STYLE_INPUT - (wont be made)
The LIST is where you list up a few things to pick from, just like the old menus ( i think its easier to make than the old one )
The INPUT is where you need to write something in then press a button
Код:
ShowPlayerDialog(playerid, dialogid, dialogstyle, "welcoming title", "Your Message", "button1", "button2");
- playerid - just keep it at playerid, its the person who should see the dialog
- dialogid - you need to pick a number, like 1. You need the number so you can tell the server wich dialog it should show to the player
- dialogstyle - you need to pick wich dialog you want, a MSGBOX, LIST or INPUT as i told about before
- welcoming title - The name of the dialog, if it was a MSGBOX for welcoming message it could be "Welcome" or "Welcome to [Servername]"
- Your Message - e.x. in a MSGBOX that would be where you type e.x. "Welcome to the server, its a TDM server. CHEATERS ARRENT ALLOWED!"
- Button1 - the first button, normaly the accept button or continue button
- Button2 - the secound button, normaly the deline button or quit button
- \n - makes a new line like pressing enter in pawno or anyother text document
- \t - makes a tap in the text like in pawno when you press the tap button
Well, we can start making a MSGBOX, if you press continue you'll enter the server, if you press Quit you'll be kicked, thats easiest.
go in your script. find OnPlayerConnect and write it like this:
Код:
public OnPlayerConnect(playerid) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Headline", "Welcomings message", "Continue", "Quit"); return 1; }
Now you've told your server that when the player connects to your server a dialog with MSGBOX as style will pop up and tell you what you wrote in headline and Welcoms message.
Now you need to find OnDialogResponse in your script, OnDigaloResponse means what the server should response to the to buttons that can be clicked. Type in like this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 1) { if(response) { SendClientMessage(playerid,0x008000FF, "Enjoy your stay!"); } else { SendClientMessage(playerid, 0xFF0000FF, "You selected 'Quit', therefore you got kicked. Goodbye!"); Kick(playerid); } return 1; } return 0; }
Now you created a Dialog with style MSGBOX
And Now we'll make a Dialog with style LIST
This is the second easiest to make, all the dialogs kinda works on the same way.
Код:
ShowPlayerDialog(playerid, dialogid, dialogstyle, "List Headline", "Listed items", "button1", "button2");
- playerid - just keep it at playerid, its the person who should see the dialog
- dialogid - you need to pick a number, like 2. You need the number so you can tell the server wich dialog it should show to the player
- dialogstyle - you need to pick wich dialog you want, a MSGBOX, LIST or INPUT as i told about in the start (Scroll up if you forgot)
- List Headline - The name of the dialog, if it was a LIST for teleports it could be "Teleports" or "[Servername]: Teleports"
- Listed Items - In a LIST dialog you make a new teleport with a new line (\n). e.x. "Unity Station \n Los Santos Police Department"
- Button1 - the first button, normaly the accept button or Select button
- Button2 - the secound button, normaly the deline button or Cancel button
Type like this:
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/Teleport", true) == 0) { ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel"); return 1; } return 0; }
To tell the server where Los Santos Police Department and Unity station is, find OnDialogResponse. OnDialogResponse means what the server is gonna do when the player selects something and clicks a button.
Type it like this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 2) { if(response) { new message[256+1]; if(listitem == 0) { format(message, 256, "You selected Los Santos Police Department, And got teleported to there!", listitem); SendClientMessage(playerid, 0xFFFFFFFF, message); SetPlayerPos(playerid, 1535.5732,-1675.6609,13.3828); } if(listitem == 1) { format(message, 256, "You selected Unity Station, And got teleported to there!", listitem); SendClientMessage(playerid, 0xFFFFFFFF, message); SetPlayerPos(playerid, 1729.6116,-1855.1116,13.4141); return 1; } } } return 1; }
When the player selects Los Santos Police Department or Unity Station it will send the player the message "You selected Unity Station / Los Santos Police Department, and got teleported to there!"
Remember when you wanna list more items on the list you need to add them in the OnPlayerCommandText, the way you write them in the line you MUST add them in the OnDialogResponse the same way! else it will be some mess.
The Listitem
Код:
} if(listitem == 1) {
Well, That'll be it from me. hope you can use it. If theres any questions then just ask away
Made by Niixie