[Tutorial] How To Make simple Shop and /rules menu
#1

How To Make Simple Shop, and rules menu
Hey guys, in this tutorial Im going to show you How To Make Simple Shop, teleport, and rules menu.
Okay First of all, you need to be have zcmd include, which you can download here

Okay, put zcmd.inc to your pawno includes folder. Go to Pawno folder, and you will see include folder, put that zcmd.inc there.

Okay Lets Geting Started.

Open Your Pawno. Then Click New

Okay first of all, we need to include our zcmd to our gameMode
Type this in the top of your script, under #include <a_samp>:
Code:
#include <zcmd>
Okay, now our zcmd file have been included.

Then We need to define our menus that will be use later.
Code:
#define SHOP_MENU 999 // 999 is the id for Our Shop Menu that will be used later
#define RULES_MENU 777 // same like that ive explained above
Okay, first we need to define our dialogs. 999, 888, 777, Is the names of Our dialogs. You can Changed it to whatever number you wish.

Okay, now we gotta handle for these dialogs. Means we gotta handle, when player click menu list, then, it will give respond.
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 999)// this is for check, if the dialog id = 999, we will do these below
	{
	    if(response)// if they response for the menus of dialog
	    {
	        if(listitem == 0)// if they response of the first list, we will do these below. We gotta make shop menu, so example the first list is shotgun, then we will give player shotgun weapon.
	        {
	            	GivePlayerWeapon(playerid, 25, 390);
	            	SendClientMessage(playerid, -1, "You Have Bought 390 package of Shotgun Ammo");
	        }
	        
	        if (listitem == 1)// same like above that ive explained.
	        {
	            	GivePlayerWeapon(playerid, 34, 100);
	            	SendClientMessage(playerid, -1, "You Have Bought 100 package of sniper");
	        }
	    }
	}
	return 1;
}
Okay now, we want thing, when we typed /shop, it will be shown menu like above.
So all we need to do is type this:

Code:
CMD:shop(playerid, params[])
{
    ShowPlayerDialog(playerid, 999, DIALOG_STYLE_LIST, "My Shop", "Shotgun\nSniper", "Buy","");// " My shop " is the text that will be shown or the tittle in the top of our menu. Shotgun and sniper is the list of menu. 999 Is the ID of our shop dialog that we have defined before. That \n is command in pawno kind of when you press "enter" button on notepad. "Buy" is the button that stands for to buy weaps
	return 1;
}
DIALOG_STYLE_LIST is kind of Dialogs. Means, it is kind of dialog that show function to show list.

Thats the example parameters if we are using zcmd as our include. I wont explain the advanced of zcmd function in this tutorial.

Okay, We are done with Our Shop Menu!!!
Lets move to make a rules Menu.

Okay make this one
Code:
CMD:rules(playerid, params[])
{
ShowPlayerDialog(playerid, 999, DIALOG_STYLE_MSGBOX, "My Server Rules", "No Hacking Or Advertising\nNo Cbugging or Stop Animation\nNo Insulting other Player\nNo Car Ramming or HeliKilling\nNo Using 3rd Party tools that give player more advantage\nPlease Follow these rules", "Ok","");
return 1;
}
DIALOG_STYLE_MSGBOX is the kind of dialogs style to show of message like Stats, rules, etc. "My Server Rules" is the text that will be shown in the top of menu, you can say that The purpose of Menu.


Okay that is
wish it helped for newbies
Reply
#2

This shows how to make a dialog.
Reply
#3

Hmm looks nice +REP
Reply
#4

Hey i have 1 question could you add so it takes money off the player buying guns?
Reply
#5

Yes, Of course, It could be added like this.

Code:
if(listitem == 0)
{
if(GetPlayerMoney(playerid)>1000)
{
SendClientMessage(playerid, COLOR_WHITE, "You Have Bought 390 of Shotgun Ammo);
GivePlayerWeapon(playerid, 25, 390);
GivePlayerMoney(playerid, -1000); // 1000 is the price of shotgun. You can change it
}
else()
{
SendClientMessage(playerid, COLOR_WHITE, "You Dont Have Enough Money");
}
}
Reply
#6

Quote:
Originally Posted by qazwsx
View Post
Yes, Of course, It could be added like this.

Code:
if(listitem == 0)
	        	{
	            	GivePlayerWeapon(playerid, 25, 390);
	            	SendClientMessage(playerid, -1, "You Have Bought 390 package of Shotgun Ammo");
GivePlayerMoney(playerid, -1000); // 1000 is the price of weapon. You can change it. 
	        	}
You have write, that if a player has $999 or lower then that, he can still buy a gun.

It should be :

pawn Code:
if(listitem == 0)
{
    if(GetPlayerMoney(playerid) > 1000)
    {
        GivePlayerMoney(playerid, -1000);
        GivePlayerWeapon(playerid, 25,390);
        SendClientMessage(playerid, -1, "You Have Bought 390 package of Shotgun Ammo");
    }
    else SendClientMessage(playerid, -1, "ERROR: You Don't Have Enought Money!");
}
Reply
#7

Quote:
Originally Posted by Areax
View Post
You have write, that if a player has $999 or lower then that, he can still buy a gun.

It should be :

pawn Code:
if(listitem == 0)
{
    if(GetPlayerMoney(playerid) > 1000)
    {
        GivePlayerMoney(playerid, -1000);
        GivePlayerWeapon(playerid, 25,390);
        SendClientMessage(playerid, -1, "You Have Bought 390 package of Shotgun Ammo");
    }
    else SendClientMessage(playerid, -1, "ERROR: You Don't Have Enought Money!");
}
Thanks for the comment
Edited, and fixed
Reply
#8

Good tutorial. Next time use [ pawn ] [ /pawn ] instead of those Code.
Reply
#9

Quote:
Originally Posted by Necip
View Post
Good tutorial. Next time use [ pawn ] [ /pawn ] instead of those Code.
lol okay :P
Btw, thanks
Reply
#10

Why you define this:

pawn Code:
#define SHOP_MENU 999 // 999 is the id for Our Shop Menu that will be used later
#define RULES_MENU 777 // same like that ive explained above
If you're not going to use it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)