Custom Menu System v1.0
Since we are able to use textdraws, sprites, custom objects, weapons etc, it's time to create great and useful things, that will make us, and our players, enjoy the game very very much !!
It's our purpose to make our servers better and better !!
I am happy to present you the first Menu System ever made for Vice City Multiplayer !
It supports one submenu for every option shown in the main menu !
Here is the whole code you need:
I have made an example of menu, with submenus:Add this to onScriptLoad CreateMenu("Menu System","Option1","Option2","Option3","Option4","Option5","Option6","Option7","Option8");
menu[0].AddSubMenu(1,"Suboption1-nr1","Suboption1-nr2");
menu[0].AddSubMenu(2,"Suboption2-nr1","Suboption2-nr2","Suboption2-nr3");
menu[0].AddSubMenu(3,"Suboption3-nr1","Suboption3-nr2","Suboption3-nr3","Suboption3-nr4");
menu[0].AddSubMenu(4,"Suboption4-nr1","Suboption4-nr2","Suboption4-nr3","Suboption4-nr4","Suboption4-nr5");
menu[0].AddSubMenu(5,"Suboption5-nr1","Suboption5-nr2","Suboption5-nr3","Suboption5-nr4","Suboption5-nr5","Suboption5-nr6");
menu[0].AddSubMenu(6,"Suboption6-nr1","Suboption6-nr2","Suboption6-nr3","Suboption6-nr4","Suboption6-nr5","Suboption6-nr6","Suboption6-nr7");
menu[0].AddSubMenu(7,"Suboption7-nr1","Suboption7-nr2","Suboption7-nr3","Suboption7-nr4","Suboption7-nr5","Suboption&-nr6","Suboption7-nr7","Suboption7-nr8");
menu[0].AddSubMenu(8,"You","cannot","add","just","one","option !","The reason","is very logic.");
Then you create a command like this, to show you the menu:if(cmd == "showfirstmenu")
{
menu[0].ShowForPlayer(player);
}
I strongly suggest you to create menus and submenus onServerStart/onScriptLoad !!Why ? Because you need to keep the evidence of the id of the menu you want to use, so you will not damage any other menu.You can walk between options using UP and DOWN ARROWS, and when you choosed one, press SPACEBAR ! (just like in San Andreas)
When you think you don't need the custom menu anymore, press BACKSPACE, and it will be hidden again.
DetailsEvery textdraw and sprite that is created by functions like CreateMenu and menu[menuid].AddSubMenu, is actually permanently on server, and them are shown just when needs to be.
That's why I suggest you to use it only in onServerStart/onScriptLoad.
other note: There are two events that are called when you select an option or a suboption.
(the events were added in the pastebin, but just forgot to give details about it)
This is called when a player choose an option from the main menu, that has no submenu:
onPlayerMenu(player, menuid, option)
{
}
menuid - the ID of the main menu. (the first menu created has ID 0)
option - option ID choosed by the player. (the first option from the menu has ID 1)
This is called when a player choose an option from a submenu of an option choosed in the main menu:
onPlayerSubMenu(player, submenuid, option)
{
}
submenuid - submenu ID - the option choosed in the main menu
option - ID of the option choosed in the submenu
Here is an example for every event:http://pastebin.com/QSBJLhrFAnd from here, you can download a .nut file with all you need to run the menu system, + the sprite you need:http://www.solidfiles.com/d/c349cb0c34/Menu_System_by_Seby.rarhttp://www.solidfiles.com/d/6cc4f83f60/menubackground.png
CreditsScripter: SebySpecial thanks goes to those guys because I learnt important squirrel stuff from them:heekz - he teached me how to create classKnucis - told me about vargv, and how to use themGudio - for supporting me in this whole time (he knows what I mean ), finding the problem when I thought there is no fix for it and teaching me squirrel important stuff.