[Tutorial] How to Make a Simple Dialog
#1

INTRO
Although, most of you don't need this, but there are still some of those new PAWNer's out there, and this might deem useful to them. It is not hard to make a Dialog, and is probably the first thing I even learned in Scripting! I know this isn't much of an Intro, so I'm just going to move on...

MAKING THE DIALOG


ShowPlayerDialog(playerid, dialogid, style, "Title", "info \n for new lines", "First Button", "Second Button");

Okay, this here tells you everything. This is the format for making a Dialog. Now there are 4 types of Dialog's, of which I'm not going to go into detail with but can be found here: https://sampwiki.blast.hk/wiki/Dialog_Styles
Now, There are several ways to make these... I'm going to make a simple /getgun (For Admins).

*NOTE* Remove
pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1)
if you are doing TDM, DM, etc...(unless you want it for admins only) If you don't remove it, you should get errors unless you have PlayerInfo, and pAdmin defined!

Also, you see the
pawn Code:
>= 1
That is the Admin's level. If you want it for a higher Admin, all you have to do is make it your desired Admin level.

*So here is what I came up with:
pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1) return
ShowPlayerDialog(playerid, 1, 2, "Gun Menu","AK47\nM41",
"Get Gun", "Cancel");
(In this there are only two guns, but you can add more.)
However, this isn't it. If you click on Get Gun, you aren't going to get a gun. Heres the Second part.

PART 2
You must go to the 'public OnDialogResponse'

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 if(dialogid == 1)  
 {
     if(listitem == 0) GivePlayerWeapon(playerid, 30, 9999);
     if(listitem == 1) GivePlayerWeapon(playerid, 31, 9999);
 }
 return 1;
}
This pretty much sums it up. I know it isn't great, but it should help out for some of you new PAWNer's. Mind you, this stuff does get complicated. Oh, and if you want to take it off Admin only, just erase the first line. Let me know if anyone finds any problems, I'll fix them. Thanks.

If this helped you, +rep me.

-Blessed
Reply
#2

Use [ pawn ] [ /pawn ] for the Coding.Also you should explain it a lot more.
Reply
#3

Nice
Reply
#4

pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1);
Code:
error 017: undefined symbol "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
Reply
#5

Quote:
Originally Posted by newbienoob
View Post
pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1);
Code:
error 017: undefined symbol "PlayerInfo"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
He said, Thats what he came up with, you would need to define PlayerInfo pAdmin using Enum's, so thats why that will NOT work, remove that line to make things work
Reply
#6

Thanks Infinity, I will work on explaining this.
Reply
#7

Good Job
Reply
#8

This dialogs was fully messed up in my head, good job I understznd them now
Reply
#9

pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1);
ShowPlayerDialog(playerid, 1, 2, "Gun Menu","AK47\nM41",
"Get Gun", "Cancel");
This simply won't go. You are closing "if" statement right after you called it. It should return an error "empty statement" or something like that on that line. Good code would be
pawn Code:
if(PlayerInfo[playerid][pAdmin] >= 1) return ShowPlayerDialog(playerid, 1, 2, "Gun Menu","AK47\nM41", "Get Gun", "Cancel");
//or
if(PlayerInfo[playerid][pAdmin] >= 1)
{
         ShowPlayerDialog(playerid, 1, 2, "Gun Menu","AK47\nM41", "Get Gun", "Cancel");
         return 1;
}
Reply
#10

Use a switch statement rather than an if statement. It's much more efficient.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)