[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


Messages In This Thread
How to Make a Simple Dialog - by Blessed - 25.05.2012, 05:51
Re: How to Make a Simple Dialog - by Infinity90 - 25.05.2012, 09:34
Re: How to Make a Simple Dialog - by [RMD]MaTriX - 25.05.2012, 09:46
Re: How to Make a Simple Dialog - by newbienoob - 25.05.2012, 09:54
Re: How to Make a Simple Dialog - by Infinity90 - 25.05.2012, 13:59
Re: How to Make a Simple Dialog - by Blessed - 25.05.2012, 16:06
Re: How to Make a Simple Dialog - by SkL_MD - 25.05.2012, 18:09
Re: How to Make a Simple Dialog - by MarTaTa - 25.05.2012, 21:20
Re: How to Make a Simple Dialog - by [MG]Dimi - 25.05.2012, 21:37
Re: How to Make a Simple Dialog - by 2KY - 26.05.2012, 00:57

Forum Jump:


Users browsing this thread: 1 Guest(s)