[ FilterScript ] Custom Menu System v2.0

Started by Sebastian, Oct 16, 2014, 09:48 PM

Previous topic - Next topic

Sebastian

When devs implemented GUI., textdraws have been moved to client-side scripting.
This system will no longer work, since version 04rel004, and there is really no need for it's adaptation.




Custom Menu System v2.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 !

Every (sub)menu can now support up to 10 options !

Here you can find all files you need to make it work:

Click here to see the source code of S_CMS_v2.nut, without downloading !



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.



Description:
   Custom Menu System by Seby ( aka CMSS ) is a system that gives scripters the ability to create their own INTERACTIVE MENU,
up to 10 options, but every option can also have a submenu (with another 10 options) !!

   Version 2.0 works a lot different than v1.0:
      -Now there are 9 sprites, created when the script is loaded. We only show them when needed.
      -The textdraws are all created right in the moment of accessing the menu, but don't worry, it will not reach the VC:MP limit (256) that fast, because it works in this way: when a player X wants to see a menu that is also shown for  player Y, the textdraws will be just shown to X, not re-created ! So the textdraws will be removed only when there will be no viewer.
      -No more double textdraws. ( 2 textdraws were used for one option, in v1.0 - one grey, one white )
      -To avoid the bugs, a player that is watching a menu and leave the server or just get killed without closing it, everything related to menus will be instantly canceled for him. ( menuRageQuit( player ) )
      -You are now able to set the title of a submenu. (not like before, where the titles were auto-set)
      -No need to manually hide the main menu, when you want to show the submenu ! Just use "menuInstance.ShowSubmenu( player, 5 )" and it will do everything for you. Same goes for HideSubmenu function.

   And maybe more, but I don't remember right now... but take a look at the script, and you will understand. :)
   I made it as understable as I could.

   
   The single thing that stays the same as in v1.0, is the way we save menus' instance: " menu[ ID ] "
   So, when you want to add a submenu for that menu, you will do like this:

menu[3].AddSubmenu( 3, "/Option 3 - blabla", "option 1", "option 2", ... )   
   Keys used to interact with the menu, used in my example, are: UP_ARROW, DOWN_ARROW, SPACEBAR (select), BACKSPACE (back)
   
   I hope I didn't miss anything important.




   Here is the list with the new functions'n'events:   

   Menu functions:
 
  • CreateMenu( title, option1, option2, ... )
  • menuRageQuit( player )
  • menuRageQuitAll( )
  • menuInstance.ShowMenu( player )
  • menuInstance.HideMenu( player )
  • menuInstance.AddSubmenu( optionID of mainmenu, title, option1, option2, ... )
  • menuInstance.ShowSubmenu( player, option )
  • menuInstance.HideSubmenu( player, option )

   Menu events:    
 
  • onPlayerEnterMenu( player, menuID )
  • onPlayerExitMenu( player, menuID )
  • onPlayerSwitchOptionsInMenu( player, menuID, oldOption, newOption )
  • onPlayerSelectInMenu( player, menuID, option )
               
   Submenu events:
  • onPlayerEnterSubmenu( player, menuID, submenuID )
  • onPlayerExitSubmenu( player, menuID, submenuID )
  • onPlayerSwitchOptionsInSubmenu( player, menuID, submenuID, oldOption, newOption )
  • onPlayerSelectInSubmenu( player, menuID, submenuID, option )



Credits
Scripter: Seby
Special thanks goes to those guys because I learnt important squirrel stuff from them:
heekz - he teached me how to create class
Knucis - told me about vargv, and how to use them
Gudio - for supporting me in this whole time (he knows what I mean :D), finding the problem when I thought there is no fix for it and teaching me squirrel important stuff.

Sebastian

I'm happy to announce the release of CMSS v2 !! Written from scratch !! :)
Now you are free to use it in your servers, BUT DO NOT FORGET TO READ THE ENTIRE (first) POST !

ysc3839

I suggest you put this code on git. Such as bitbucket and github etc.

MacTavish


Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Sebastian

Quote from: ysc3839 on Feb 25, 2015, 04:04 AMI suggest you put this code on git. Such as bitbucket and github etc.

I'm not that used to these gits, and I don't believe I really want to start using them now.
If you want to see the code, just take a look here.

Quote from: Beztone on Feb 25, 2015, 05:29 AMWow awesome Dude i was waiting for this :D

Now I am the one waiting to see what will you do with it. :P

vcmptr

My English is not good.

Sebastian

Small update:
-added events that are called when a player switch options in menu/submenu

onPlayerSwitchOptionsInMenu( player, menuID, oldOption, newOption )

onPlayerSwitchOptionsInSubmenu( player, menuID, submenuID, oldOption, newOption )

First post updated !

MatheuS

if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Sebastian

Now, since I know that we can't call more times the same event, I made the script more organized.
You have now a file S_CMS_v2.nut that represents the brain of the system, and some codes that you need to add in your main script.
(like loading the brain.nut, rageQuiting the menus when a player dies, etc)