How to Create a Menu(Basic) -
§с†¶e®РµРe - 14.12.2011
Introduction
Many people think dialogs are the only useful thing and menus are very complicated to create and all.But today I am going to show you how to create a simple menu.I will be creating a teleport menu you can customize it as you want.This is not a copy paste tutorial as you will have to read and understand what is written otherwise it won't work.This tutorial is also written in ZCMD make sure you have
in the top.
Starting Steps
First we have to create a menu.The prefix before it is Menu: like we do it in Float: bool: etc.
So now we have created the variable to store the menu.
pawn Код:
teleport = CreateMenu("Teleports", 2, 200.0, 100.0, 150.0, 150.0);
Now a bit of explanation about CreateMenu arguments
pawn Код:
CreateMenu(title, columns, Float:x, Float:y, Float:col1width, Float:col2width);
pawn Код:
title: The heading of the menu
columns: The number here defines how much columns are used [2 is maximum]
Float:x: The heigth position of the menu on screen [left to right]
Float:y: The width position of the menu on screen [up and down]
Float:col1width: The width of the first column
Float:col2width: The width of the second column
Adding some menu items
Although we've got the Menu, but we need some items, under which you can choose in the menu. You add them underneath the CreateMenu that we made earlier.
pawn Код:
AddMenuItem(teleport, 0, "LS");
AddMenuItem(teleport, 0, "LS");
AddMenuItem(teleport, 0, "SF");
AddMenuItem(teleport, 0, "SF");
AddMenuItem(teleport, 0, "LV");
AddMenuItem(teleport, 0, "LV");
AddMenuItem(teleport, 1, "Grove Street");
AddMenuItem(teleport, 1, "Starfish Tower");
AddMenuItem(teleport, 1, "Wheel Arch Angels");
AddMenuItem(teleport, 1, "Jizzys");
AddMenuItem(teleport, 1, "4 Dragons");
AddMenuItem(teleport, 1, "Come-a-Lot");
The explanation for AddMenuItem:
pawn Код:
AddMenuItem(menuid, column, text);
pawn Код:
menuid: The menuid of the menu where the item shall be displayed
column: The column in which the item shall be shown
text: The text of the item
Getting what the user selected and executing it
Okay, now that we have created a full menu with items what should happen when you choose an item? In our example we want to make a teleport menu, so we should get teleported to the position we choose. When a player selects an item on a menu the script calls the callback: public
OnPlayerSelectedMenuRow(playerid, row). The best way to do it is to do it with a switch, this is like several if statements to check if a variable is worth certain values. But first we only want these effects for the menu we want so we need to create a variable that holds what menu the player is looking at, this is done with 'GetPlayerMenu':
pawn Код:
new Menu:CurrentMenu = GetPlayerMenu(playerid);
Now, when somebody selects something on the menu, their menuid will be saved in 'CurrentMenu'.
Now we have to check that the menu they selected on is the menu we want:
pawn Код:
if(CurrentMenu == teleport)
{
switch(row)
{
case 0: //Grove Street
{
SetPlayerPos(playerid, 2493.9133, -1682.3986, 13.3382);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to Grove Street");
}
case 1: //Starfish Tower
{
SetPlayerPos(playerid, 1541.2833, -1362.4741, 329.6457);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the top of Starfish Tower");
}
case 2: //Wheel Arch Angels
{
SetPlayerPos(playerid, -2705.5503, 206.1621, 4.1797);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Wheel Arch Angels tuning-shop");
}
case 3: //Jizzys
{
SetPlayerPos(playerid, -2617.5156, 1390.6353, 7.1105);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to Jizzy's Nightclub!");
}
case 4: //4Dragons
{
SetPlayerPos(playerid, 2028.5538, 1008.3543, 10.8203);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Four Dragons Casino");
}
case 5: //Com-a-Lot
{
SetPlayerPos(playerid, 2169.1838, 1122.5426, 12.6107);
SetPlayerInterior(playerid, 0);
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Come-a-Lot casino!");
}
}
}
Now I'll explain how the switch works, in the top there is this:
this defines what to check, in this case its the menu row then in between the braces under 'switch' there are 'case's, these are the different conditions that the variable in the 'switch' brackets can be, you can define these. Under the cases are more braces, this is where you put functions to take place if that case is the right one.
When everything is done correctly, like I've showed in those examples, the effects for menu items are created successfully.
The Command
Now for the command which makes the player view the menu.
pawn Код:
CMD:teleport(playerid, params[])
{
ShowMenuForPlayer(teleport,playerid);
return 1;
}
Credits
Me-For the tutorial
Zeex-For ZCMD
Hope you liked this tutorial


Re: How to Create a Menu(Basic) -
§с†¶e®РµРe - 14.12.2011
No one??
Re: How to Create a Menu(Basic) -
BMUK - 14.12.2011
There are
alot of tutorials for making menus.
Also, the first question will probably be "I GET ERROR I CANNOT READ FROM ZCMD!!!?!?!?!?!"
If you're going to make a tutorial about menu's then maybe you could make an entirely new menu system that scripters can use.
Re: How to Create a Menu(Basic) - T0pAz - 14.12.2011
what's new?
Re: How to Create a Menu(Basic) -
§с†¶e®РµРe - 14.12.2011
Quote:
Originally Posted by BMUK
There are alot of tutorials for making menus.
Also, the first question will probably be "I GET ERROR I CANNOT READ FROM ZCMD!!!?!?!?!?!"
If you're going to make a tutorial about menu's then maybe you could make an entirely new menu system that scripters can use.
|
I have told it is made in ZCMD also what do you mean by making a entirely new Menu system?
Quote:
Originally Posted by T0pAz
what's new?
|
Nothing.This is just a tutorial on how to make menus
Re: How to Create a Menu(Basic) -
KimGuan - 16.07.2013
I Like Your Simple Copy Paste Boy...Just Check it out
https://sampwiki.blast.hk/wiki/Creating_a_simple_Menu
Re: How to Create a Menu(Basic) -
Ryan_Bowe - 16.07.2013
....
Re: How to Create a Menu(Basic) -
v1k1nG - 28.09.2018
Maybe no one would have noticed after all that time :b
Re: How to Create a Menu(Basic) -
Undef1ned - 28.09.2018
It does not make sense to claim a tutorial from years ago.
Re: How to Create a Menu(Basic) -
TheToretto - 29.09.2018
14/12/
2011