Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Custom Menu System v1.0 for Vice City Multiplayer.
- Scripter: Seby
- Special credits goes to shadow.heekz,Knucis and Gudio because I learnt new squirrel stuff from them.
- Functions: CreateMenu(title,options);
- info - options are up to 8
- Events: 1. onPlayerMenu(player,menuid,option);
- info - This is called when a player choose an option from the main menu, that has no submenu.
- 2. onPlayerSubMenu(player,submenuid,option);
- info - This is called when a player choose an option from a submenu, of an option choosed in the main menu.
- */
- menuoptionchoosen <- array(GetMaxPlayers(), null);
- menuidonscreen <- array(GetMaxPlayers(), null);
- submenuonscreen <- array(GetMaxPlayers(), null);
- submenuoptionchoosen <- array(GetMaxPlayers(), null);
- menucount <- 0;
- menu <- array(255, null);
- //-------------------------------------------------------------------
- function onScriptLoad()
- {
- // Bind Keys ==========================================================
- UP_ARROW <- BindKey(true, 0x26, 0, 0);
- DOWN_ARROW <- BindKey(true, 0x28, 0, 0);
- SPACEBAR <- BindKey(true, 0x20, 0, 0);
- BACKSPACE <- BindKey(true, 0x08, 0, 0);
- // ====================================================================
- print("Menu System v1.0 made by Seby was loaded.");
- }
- //-------------------------------------------------------------------
- function onScriptUnload()
- {
- print("Menu System v1.0 made by Seby could not be loaded.");
- }
- //-------------------------------------------------------------------
- function onPlayerJoin( player )
- {
- menuidonscreen[player.ID] = -1;
- menuoptionchoosen[player.ID] = 0;
- submenuoptionchoosen[player.ID] = 0;
- submenuonscreen[player.ID] = 0;
- }
- //-------------------------------------------------------------------
- function onPlayerMenu(player, menuid, option)
- {
- switch(menuid) // menu ID - it starts with 0
- {
- case 0: // first menu/menu created
- switch(option) // we are switching options now
- {
- case 1: // this means the first option from menu 0
- MessagePlayer("// code here for option 1 in menu 0",player);
- break;
- case 2: // option 2
- // here script the code for the option2, when it is selected.
- break;
- default: break;
- }
- break;
- default: break;
- }
- }
- //-------------------------------------------------------------------
- function onPlayerSubMenu(player, submenuid, option)
- {
- switch(submenuid) // the ID of the selected option in main menu
- {
- case 1: // it starts with ID 1, and not with 0
- switch(option)
- {
- case 1: // the ID of the selected option in the sub menu - it also starts with ID 0
- MessagePlayer("You choosed the option 1 of the submenu with ID 1",player);
- break;
- case 2:
- MessagePlayer("// code here for the choosed option 2 of the submenu with ID 1",player);
- break;
- default: break;
- }
- break;
- default: break;
- }
- }
- //-------------------------------------------------------------------
- function onPlayerCommand( player, command, arguments )
- {
- local cmd = command;
- if(cmd == "menutest")
- {
- 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.");
- menu[0].ShowForPlayer(player);
- }
- return 1;
- }
- //-------------------------------------------------------------------
- function onKeyDown( player, bind )
- {
- switch(bind)
- {
- case UP_ARROW:
- if(menuidonscreen[player.ID] > -1) KeyBindMenu(player, UP_ARROW);
- break;
- case DOWN_ARROW:
- if(menuidonscreen[player.ID] > -1) KeyBindMenu(player, DOWN_ARROW);
- break;
- case SPACEBAR:
- if(menuidonscreen[player.ID] > -1) KeyBindMenu(player, SPACEBAR);
- break;
- case BACKSPACE:
- if(menuidonscreen[player.ID] > -1) KeyBindMenu(player, BACKSPACE);
- break;
- default: break;
- }
- }
- //-------------------------------------------------------------------
- class ClassForMenu
- {
- // textdraws
- t = null;
- tt = null;
- // end of textdraws
- // sprites
- s = null;
- // end of sprites
- numberofparams = null;
- numberofparamssub = null;
- optionhassubmenu = null;
- ID = null;
- optionname = null;
- suboption = null;
- x = null;
- y = null;
- optionx = null;
- titlecol = null;
- unselectedcol = null;
- selectedcol = null;
- spritex = null;
- spritey = null;
- constructor(menuid,thetitle, ...)
- {
- if ( vargv.len() > 1 || vargv.len() > 8)
- {
- x = 80;
- y = 310;
- optionx = x+50;
- titlecol = 0xFF00FFFF;
- unselectedcol = 0xFFAAAAAA;
- selectedcol = 0xFFFFFFFF;
- spritex = x-10;
- spritey = y-10;
- t = array(9,null);
- tt = array(9,null);
- s = array(9,null);
- suboption = array(9,null);
- for(local i = 0; i < t.len(); i++)
- {
- t[i] = array(9,null);
- tt[i] = array(9,null);
- s[i] = array(9,null);
- suboption[i] = array(9,null);
- }
- optionname = array(9,null);
- numberofparamssub = array(9,null);
- optionhassubmenu = array(9, null);
- for(local i = 0; i < optionhassubmenu.len(); i++) optionhassubmenu[i] = 0;
- ID = menuid;
- local title = thetitle.tostring();
- //==================================================================================
- // Index options' names
- for(local so = 0; so <= vargv.len(); so++)
- {
- if(so)
- {
- optionname[so] = vargv[so-1];
- }
- }
- // Textdraws
- t[0][0] = ::CreateTextdraw(title,x,y,titlecol);
- tt[0][1] = ::CreateTextdraw(":: " + vargv[0],optionx,y+15,selectedcol);
- t[0][2] = ::CreateTextdraw(":: " + vargv[1],optionx,y+30,unselectedcol);
- t[0][1] = ::CreateTextdraw(":: " + vargv[0],optionx,y+15,unselectedcol);
- tt[0][2] = ::CreateTextdraw(":: " + vargv[1],optionx,y+30,selectedcol);
- // Sprites
- s[0][0] = ::CreateSprite("menubackground.png",spritex,spritey,0,0,0,200);
- s[0][1] = ::CreateSprite("menubackground.png",spritex,spritey+18,0,0,0,200);
- s[0][2] = ::CreateSprite("menubackground.png",spritex,spritey+36,0,0,0,200);
- s[0][3] = ::CreateSprite("menubackground.png",spritex,spritey+54,0,0,0,200);
- numberofparams = vargv.len();
- //==================================================================================
- switch(vargv.len())
- {
- case 8:
- t[0][8] = ::CreateTextdraw(":: " + vargv[7],optionx,y+120,unselectedcol);
- tt[0][8] = ::CreateTextdraw(":: " + vargv[7],optionx,y+120,selectedcol);
- t[0][7] = ::CreateTextdraw(":: " + vargv[6],optionx,y+105,unselectedcol);
- tt[0][7] = ::CreateTextdraw(":: " + vargv[6],optionx,y+105,selectedcol);
- t[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,unselectedcol);
- tt[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,selectedcol);
- CreateAllToFive(vargv[2],vargv[3],vargv[4],optionx,y,unselectedcol,selectedcol,spritex,spritey);
- s[0][8] = ::CreateSprite("menubackground.png",spritex,spritey+144,0,0,0,200);
- s[0][7] = ::CreateSprite("menubackground.png",spritex,spritey+126,0,0,0,200);
- break;
- case 7:
- t[0][7] = ::CreateTextdraw(":: " + vargv[6],optionx,y+105,unselectedcol);
- tt[0][7] = ::CreateTextdraw(":: " + vargv[6],optionx,y+105,selectedcol);
- t[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,unselectedcol);
- tt[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,selectedcol);
- CreateAllToFive(vargv[2],vargv[3],vargv[4],optionx,y,unselectedcol,selectedcol,spritex,spritey);
- s[0][7] = ::CreateSprite("menubackground.png",spritex,spritey+126,0,0,0,200);
- break;
- case 6:
- t[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,unselectedcol);
- tt[0][6] = ::CreateTextdraw(":: " + vargv[5],optionx,y+90,selectedcol);
- CreateAllToFive(vargv[2],vargv[3],vargv[4],optionx,y,unselectedcol,selectedcol,spritex,spritey);
- s[0][7] = ::CreateSprite("menubackground.png",spritex,spritey+126,0,0,0,200);
- break;
- case 5:
- CreateAllToFive(vargv[2],vargv[3],vargv[4],optionx,y,unselectedcol,selectedcol,spritex,spritey);
- case 4:
- t[0][4] = ::CreateTextdraw(":: " + vargv[3],optionx,y+60,unselectedcol);
- tt[0][4] = ::CreateTextdraw(":: " + vargv[3],optionx,y+60,selectedcol);
- t[0][3] = ::CreateTextdraw(":: " + vargv[2],optionx,y+45,unselectedcol);
- tt[0][3] = ::CreateTextdraw(":: " + vargv[2],optionx,y+45,selectedcol);
- s[0][5] = ::CreateSprite("menubackground.png",spritex,spritey+90,0,0,0,200);
- s[0][4] = ::CreateSprite("menubackground.png",spritex,spritey+72,0,0,0,200);
- break;
- case 3:
- t[0][3] = ::CreateTextdraw(":: " + vargv[2],optionx,y+45,unselectedcol);
- tt[0][3] = ::CreateTextdraw(":: " + vargv[2],optionx,y+45,selectedcol);
- s[0][4] = ::CreateSprite("menubackground.png",spritex,spritey+72,0,0,0,200);
- break;
- default: break;
- }
- } else ::print("Error in menu System - You can add min 2 options, and max 8 options !");
- }
- function CreateAllToFive(param1,param2,param3,optionx,y,unselectedcol,selectedcol,spritex,spritey)
- {
- t[0][5] = ::CreateTextdraw(":: " + param3,optionx,y+75,unselectedcol);
- tt[0][5] = ::CreateTextdraw(":: " + param3,optionx,y+75,selectedcol);
- t[0][4] = ::CreateTextdraw(":: " + param2,optionx,y+60,unselectedcol);
- tt[0][4] = ::CreateTextdraw(":: " + param2,optionx,y+60,selectedcol);
- t[0][3] = ::CreateTextdraw(":: " + param1,optionx,y+45,unselectedcol);
- tt[0][3] = ::CreateTextdraw(":: " + param1,optionx,y+45,selectedcol);
- s[0][6] = ::CreateSprite("menubackground.png",spritex,spritey+108,0,0,0,200);
- s[0][5] = ::CreateSprite("menubackground.png",spritex,spritey+90,0,0,0,200);
- s[0][4] = ::CreateSprite("menubackground.png",spritex,spritey+72,0,0,0,200);
- }
- function AddSubMenu(option, ...)
- {
- if ( vargv.len() > 1 || vargv.len() < 9)
- {
- numberofparamssub[option] = vargv.len();
- for(local so = 1; so <= vargv.len(); so++)
- {
- if(so)
- {
- suboption[option][so] = vargv[so-1];
- }
- }
- for(local so = vargv.len(); so < 9; so++)
- {
- if(so)
- {
- if(so != vargv.len())
- suboption[option][so] = 0;
- }
- }
- StuffForSubMenu(option,numberofparamssub[option],suboption[option][1],suboption[option][2],suboption[option][3],suboption[option][4],suboption[option][5],suboption[option][6],suboption[option][7],suboption[option][8]);
- } else ::print("Error in menu System - You can add min 2 suboptions, and max 8 suboptions !");
- }
- function StuffForSubMenu(option,params,name1,name2,name3,name4,name5,name6,name7,name8)
- {
- local title = optionname[option];
- optionhassubmenu[option] = 1;
- t[option][0] = ::CreateTextdraw(title,x,y,titlecol);
- tt[option][1] = ::CreateTextdraw(":: " + name1,optionx,y+15,selectedcol);
- t[option][2] = ::CreateTextdraw(":: " + name2,optionx,y+30,unselectedcol);
- t[option][1] = ::CreateTextdraw(":: " + name1,optionx,y+15,unselectedcol);
- tt[option][2] = ::CreateTextdraw(":: " + name2,optionx,y+30,selectedcol);
- s[option][0] = ::CreateSprite("menubackground.png",spritex,spritey,0,0,0,200);
- s[option][1] = ::CreateSprite("menubackground.png",spritex,spritey+18,0,0,0,200);
- s[option][2] = ::CreateSprite("menubackground.png",spritex,spritey+36,0,0,0,200);
- s[option][3] = ::CreateSprite("menubackground.png",spritex,spritey+54,0,0,0,200);
- if(name3 != null)
- {
- t[option][3] = ::CreateTextdraw(":: " + name3,optionx,y+45,unselectedcol);
- tt[option][3] = ::CreateTextdraw(":: " + name3,optionx,y+45,selectedcol);
- s[option][4] = ::CreateSprite("menubackground.png",spritex,spritey+72,0,0,0,200);
- }
- if(name4 != null)
- {
- t[option][4] = ::CreateTextdraw(":: " + name4,optionx,y+60,unselectedcol);
- tt[option][4] = ::CreateTextdraw(":: " + name4,optionx,y+60,selectedcol);
- s[option][5] = ::CreateSprite("menubackground.png",spritex,spritey+90,0,0,0,200);
- }
- if(name5 != null)
- {
- t[option][5] = ::CreateTextdraw(":: " + name5,optionx,y+75,unselectedcol);
- tt[option][5] = ::CreateTextdraw(":: " + name5,optionx,y+75,selectedcol);
- s[option][6] = ::CreateSprite("menubackground.png",spritex,spritey+108,0,0,0,200);
- }
- if(name6 != null)
- {
- t[option][6] = ::CreateTextdraw(":: " + name6,optionx,y+90,unselectedcol);
- tt[option][6] = ::CreateTextdraw(":: " + name6,optionx,y+90,selectedcol);
- s[option][7] = ::CreateSprite("menubackground.png",spritex,spritey+126,0,0,0,200);
- }
- if(name7 != null)
- {
- t[option][7] = ::CreateTextdraw(":: " + name7,optionx,y+105,unselectedcol);
- tt[option][7] = ::CreateTextdraw(":: " + name7,optionx,y+105,selectedcol);
- }
- if(name8 != null)
- {
- t[option][8] = ::CreateTextdraw(":: " + name8,optionx,y+120,unselectedcol);
- tt[option][8] = ::CreateTextdraw(":: " + name8,optionx,y+120,selectedcol);
- s[option][8] = ::CreateSprite("menubackground.png",spritex,spritey+144,0,0,0,200);
- }
- }
- function ShowSubMenuForPlayer(player,option)
- {
- local params = numberofparamssub[option];
- t[option][0].ShowForPlayer(player);
- tt[option][1].ShowForPlayer(player);
- t[option][2].ShowForPlayer(player);
- for(local soo = 0; soo < 4; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- switch(params)
- {
- case 8:
- for(local soo = 2; soo < 9; soo++)
- if(t[option][soo]) t[option][soo].ShowForPlayer(player);
- for(local soo = 4; soo < 9; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- case 7:
- for(local soo = 2; soo < 8; soo++)
- if(t[option][soo]) t[option][soo].ShowForPlayer(player);
- for(local soo = 4; soo < 8; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- case 6:
- for(local soo = 2; soo < 7; soo++)
- if(t[option][soo]) t[option][soo].ShowForPlayer(player);
- for(local soo = 4; soo < 7; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- case 5:
- for(local soo = 2; soo < 6; soo++)
- if(t[option][soo]) t[option][soo].ShowForPlayer(player);
- for(local soo = 4; soo < 6; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- case 4:
- for(local soo = 2; soo < 5; soo++)
- if(t[option][soo]) t[option][soo].ShowForPlayer(player);
- for(local soo = 4; soo < 5; soo++)
- if(s[option][soo]) s[option][soo].ShowForPlayer(player);
- break;
- case 3:
- t[option][3].ShowForPlayer(player);
- s[option][4].ShowForPlayer(player);
- break;
- default: break;
- }
- ::submenuoptionchoosen[player.ID] = 1;
- }
- function HideSubMenuForPlayer(player,option)
- {
- local params = numberofparamssub[option];
- t[option][0].HideFromPlayer(player);
- t[option][1].HideFromPlayer(player);
- tt[option][1].HideFromPlayer(player);
- t[option][2].HideFromPlayer(player);
- tt[option][2].HideFromPlayer(player);
- for(local soo = 0; soo < 4; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- switch(params)
- {
- case 8:
- for(local soo = 2; soo < 9; soo++)
- if(t[option][soo]) t[option][soo].HideFromPlayer(player);
- for(local tee = 2; tee < 9; tee++)
- if(tt[option][tee]) tt[option][tee].HideFromPlayer(player);
- for(local soo = 4; soo < 9; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- case 7:
- for(local soo = 2; soo < 8; soo++)
- if(t[option][soo]) t[option][soo].HideFromPlayer(player);
- for(local tee = 2; tee < 8; tee++)
- if(tt[option][tee]) tt[option][tee].HideFromPlayer(player);
- for(local soo = 4; soo < 8; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- case 6:
- for(local soo = 2; soo < 7; soo++)
- if(t[option][soo]) t[option][soo].HideFromPlayer(player);
- for(local tee = 2; tee < 7; tee++)
- if(tt[option][tee]) tt[option][tee].HideFromPlayer(player);
- for(local soo = 4; soo < 7; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- case 5:
- for(local soo = 2; soo < 6; soo++)
- if(t[option][soo]) t[option][soo].HideFromPlayer(player);
- for(local tee = 2; tee < 6; tee++)
- if(tt[option][tee]) tt[option][tee].HideFromPlayer(player);
- for(local soo = 4; soo < 6; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- case 4:
- for(local soo = 2; soo < 5; soo++)
- if(t[option][soo]) t[option][soo].HideFromPlayer(player);
- for(local tee = 2; tee < 5; tee++)
- if(tt[option][tee]) tt[option][tee].HideFromPlayer(player);
- for(local soo = 4; soo < 5; soo++)
- if(s[option][soo]) s[option][soo].HideFromPlayer(player);
- break;
- case 3:
- t[option][3].HideFromPlayer(player);
- tt[option][3].HideFromPlayer(player);
- s[option][4].HideFromPlayer(player);
- break;
- default: break;
- }
- ::submenuoptionchoosen[player.ID] = 0;
- }
- function ShowForPlayer(player)
- {
- t[0][0].ShowForPlayer(player);
- tt[0][1].ShowForPlayer(player);
- t[0][2].ShowForPlayer(player);
- s[0][0].ShowForPlayer(player);
- s[0][1].ShowForPlayer(player);
- s[0][2].ShowForPlayer(player);
- s[0][3].ShowForPlayer(player);
- switch(numberofparams)
- {
- case 8:
- for(local sp = 4; sp < 9; sp++)
- if(s[0][sp]) s[0][sp].ShowForPlayer(player);
- for(local te = 2; te < 9; te++)
- if(t[0][te]) t[0][te].ShowForPlayer(player);
- break;
- case 7:
- for(local sp = 4; sp < 8; sp++)
- if(s[0][sp]) s[0][sp].ShowForPlayer(player);
- for(local te = 2; te < 8; te++)
- if(t[0][te]) t[0][te].ShowForPlayer(player);
- break;
- case 6:
- for(local sp = 4; sp < 7; sp++)
- if(s[0][sp]) s[0][sp].ShowForPlayer(player);
- for(local te = 2; te < 7; te++)
- if(t[0][te]) t[0][te].ShowForPlayer(player);
- break;
- case 5:
- for(local sp = 4; sp < 6; sp++)
- if(s[0][sp]) s[0][sp].ShowForPlayer(player);
- for(local te = 2; te < 6; te++)
- if(t[0][te]) t[0][te].ShowForPlayer(player);
- break;
- case 4:
- for(local sp = 4; sp < 5; sp++)
- if(s[0][sp]) s[0][sp].ShowForPlayer(player);
- for(local te = 2; te < 5; te++)
- if(t[0][te]) t[0][te].ShowForPlayer(player);
- break;
- case 3:
- t[0][3].ShowForPlayer(player);
- s[0][4].ShowForPlayer(player);
- break;
- default: break;
- } // end of switch
- player.IsFrozen = true;
- menuoptionchoosen[player.ID] = 1;
- menuidonscreen[player.ID] = ID;
- }
- function HideFromPlayer(player, type)
- {
- t[0][0].HideFromPlayer(player);
- t[0][1].HideFromPlayer(player);
- tt[0][1].HideFromPlayer(player);
- t[0][2].HideFromPlayer(player);
- tt[0][2].HideFromPlayer(player);
- s[0][0].HideFromPlayer(player);
- s[0][1].HideFromPlayer(player);
- s[0][2].HideFromPlayer(player);
- s[0][3].HideFromPlayer(player);
- switch(numberofparams)
- {
- case 8:
- for(local sp = 4; sp < 9; sp++)
- if(s[0][sp]) s[0][sp].HideFromPlayer(player);
- for(local te = 2; te < 9; te++)
- if(t[0][te]) t[0][te].HideFromPlayer(player);
- for(local tee = 2; tee < 9; tee++)
- if(tt[0][tee]) tt[0][tee].HideFromPlayer(player);
- break;
- case 7:
- for(local sp = 4; sp < 8; sp++)
- if(s[0][sp]) s[0][sp].HideFromPlayer(player);
- for(local te = 2; te < 8; te++)
- if(t[0][te]) t[0][te].HideFromPlayer(player);
- for(local tee = 2; tee < 8; tee++)
- if(tt[0][tee]) tt[0][tee].HideFromPlayer(player);
- break;
- case 6:
- for(local sp = 4; sp < 8; sp++)
- if(s[0][sp]) s[0][sp].HideFromPlayer(player);
- for(local te = 2; te < 7; te++)
- if(t[0][te]) t[0][te].HideFromPlayer(player);
- for(local tee = 2; tee < 7; tee++)
- if(tt[0][tee]) tt[0][tee].HideFromPlayer(player);
- break;
- case 5:
- for(local sp = 4; sp < 7; sp++)
- if(s[0][sp]) s[0][sp].HideFromPlayer(player);
- for(local te = 2; te < 6; te++)
- if(t[0][te]) t[0][te].HideFromPlayer(player);
- for(local tee = 2; tee < 6; tee++)
- if(tt[0][tee]) tt[0][tee].HideFromPlayer(player);
- break;
- case 4:
- for(local sp = 4; sp < 6; sp++)
- if(s[0][sp]) s[0][sp].HideFromPlayer(player);
- for(local te = 2; te < 5; te++)
- if(t[0][te]) t[0][te].HideFromPlayer(player);
- for(local tee = 2; tee < 5; tee++)
- if(tt[0][tee]) tt[0][tee].HideFromPlayer(player);
- break;
- case 3:
- t[0][3].HideFromPlayer(player);
- tt[0][3].HideFromPlayer(player);
- s[0][4].HideFromPlayer(player);
- break;
- default: break;
- } // end of switch
- switch(type)
- {
- case 0:
- player.IsFrozen = false;
- menuoptionchoosen[player.ID] = 0;
- menuidonscreen[player.ID] = -1;
- break;
- case 1:
- break;
- default: break;
- } // end of switch
- }
- thetitle = "Menu System v1.0 (by Seby)";
- }
- function CreateMenu(thetitle, ...)
- {
- if ( vargv.len() > 1 || vargv.len() > 8)
- {
- switch(vargv.len())
- {
- case 2:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1]);
- menucount++;
- return menu[menucount];
- case 3:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2]);
- menucount++;
- return menu[menucount];
- case 4:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2],vargv[3]);
- menucount++;
- return menu[menucount];
- case 5:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2],vargv[3],vargv[4]);
- menucount++;
- return menu[menucount];
- case 6:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2],vargv[3],vargv[4],vargv[5]);
- menucount++;
- return menu[menucount];
- case 7:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2],vargv[3],vargv[4],vargv[5],vargv[6]);
- menucount++;
- return menu[menucount];
- case 8:
- menu[menucount] = ClassForMenu(menucount,thetitle,vargv[0],vargv[1],vargv[2],vargv[3],vargv[4],vargv[5],vargv[6],vargv[7]);
- menucount++;
- return menu[menucount];
- default: break;
- }
- } else ::print("Error in menu System - You can add min 2 options, and max 8 options !");
- }
- function KeyBindMenu(player, bind)
- {
- local menuid = menuidonscreen[player.ID],
- themenu = menu[menuid],
- newoption = menuoptionchoosen[player.ID] + 1,
- newoptionup = menuoptionchoosen[player.ID] - 1,
- subnewoption = submenuoptionchoosen[player.ID] + 1,
- subnewoptionup = submenuoptionchoosen[player.ID] - 1,
- option = menuoptionchoosen[player.ID],
- suboptionchoosen = submenuoptionchoosen[player.ID],
- maxparams = themenu.numberofparams,
- submaxparams = themenu.numberofparamssub[menuoptionchoosen[player.ID]];
- switch(bind)
- {
- case UP_ARROW:
- if(submenuonscreen[player.ID] == 0)
- {
- if(option != 1)
- {
- themenu.tt[0][option].HideFromPlayer(player);
- themenu.t[0][option].ShowForPlayer(player);
- themenu.t[0][newoptionup].HideFromPlayer(player);
- themenu.tt[0][newoptionup].ShowForPlayer(player);
- menuoptionchoosen[player.ID]--;
- }
- else
- {
- themenu.tt[0][option].HideFromPlayer(player);
- themenu.t[0][option].ShowForPlayer(player);
- themenu.t[0][maxparams].HideFromPlayer(player);
- themenu.tt[0][maxparams].ShowForPlayer(player);
- menuoptionchoosen[player.ID] = maxparams;
- }
- }
- else
- {
- if(suboptionchoosen != 1)
- {
- themenu.tt[option][suboptionchoosen].HideFromPlayer(player);
- themenu.t[option][suboptionchoosen].ShowForPlayer(player);
- themenu.t[option][subnewoptionup].HideFromPlayer(player);
- themenu.tt[option][subnewoptionup].ShowForPlayer(player);
- submenuoptionchoosen[player.ID]--;
- }
- else
- {
- themenu.tt[option][suboptionchoosen].HideFromPlayer(player);
- themenu.t[option][suboptionchoosen].ShowForPlayer(player);
- themenu.t[option][submaxparams].HideFromPlayer(player);
- themenu.tt[option][submaxparams].ShowForPlayer(player);
- submenuoptionchoosen[player.ID] = submaxparams;
- }
- }
- break;
- case DOWN_ARROW:
- if(submenuonscreen[player.ID] == 0)
- {
- if(option != maxparams)
- {
- themenu.tt[0][option].HideFromPlayer(player);
- themenu.t[0][option].ShowForPlayer(player);
- themenu.t[0][newoption].HideFromPlayer(player);
- themenu.tt[0][newoption].ShowForPlayer(player);
- menuoptionchoosen[player.ID]++;
- }
- else
- {
- themenu.tt[0][option].HideFromPlayer(player);
- themenu.t[0][option].ShowForPlayer(player);
- themenu.t[0][1].HideFromPlayer(player);
- themenu.tt[0][1].ShowForPlayer(player);
- menuoptionchoosen[player.ID] = 1;
- }
- }
- else
- {
- if(suboptionchoosen != submaxparams)
- {
- themenu.tt[option][suboptionchoosen].HideFromPlayer(player);
- themenu.t[option][suboptionchoosen].ShowForPlayer(player);
- themenu.t[option][subnewoption].HideFromPlayer(player);
- themenu.tt[option][subnewoption].ShowForPlayer(player);
- submenuoptionchoosen[player.ID]++;
- }
- else
- {
- themenu.tt[option][suboptionchoosen].HideFromPlayer(player);
- themenu.t[option][suboptionchoosen].ShowForPlayer(player);
- themenu.t[option][1].HideFromPlayer(player);
- themenu.tt[option][1].ShowForPlayer(player);
- submenuoptionchoosen[player.ID] = 1;
- }
- }
- break;
- case SPACEBAR:
- if(themenu.optionhassubmenu[option] == 0) onPlayerMenu(player, menuid, option);
- else
- {
- if(submenuonscreen[player.ID] == 0)
- {
- themenu.HideFromPlayer(player,1);
- themenu.ShowSubMenuForPlayer(player,option);
- submenuonscreen[player.ID] = 1;
- }
- onPlayerSubMenu(player, option, suboptionchoosen);
- }
- break;
- case BACKSPACE:
- if(submenuonscreen[player.ID] == 0)
- {
- themenu.HideFromPlayer(player,0);
- menuidonscreen[player.ID] = -1;
- menuoptionchoosen[player.ID] = 0;
- }
- else
- {
- submenuoptionchoosen[player.ID] = 0;
- submenuonscreen[player.ID] = 0;
- menuoptionchoosen[player.ID] = 1;
- themenu.HideSubMenuForPlayer(player,option);
- themenu.ShowForPlayer(player);
- }
- break;
- default: break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement