Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /****************************************KEYCONF****************************************/
- // Bah, so much for GetPlayerInput(). :P
- alias choiceup "puke 201"
- alias choicedown "puke 202"
- alias choiceselect "puke 203"
- defaultbind end choiceselect
- defaultbind pgup choiceup
- defaultbind pgdn choicedown
- addkeysection "Choice Menus" menus
- addmenukey "Menu Select" choiceselect
- addmenukey "Menu Up" choiceup
- addmenukey "Menu Down" choicedown
- /*************************************GLOBAL SCRIPTS************************************/
- // Put these (up to the next line) in a library if need be.
- #include "zcommon.acs"
- #define CURSOR 200
- #define id_cursor 9970
- #define id_choices 9980
- int ThisScript = 0;
- int menu = OFF;
- int currentchoice = 0;
- int maxchoices = 0;
- function void ClearMsg ( int id )
- {
- HudMessage(s:""; 0,id,-1,0,0,0);
- }
- function void Choice ( int number, int name )
- {
- SetHudSize(384,256,0);
- SetFont("SmallFont"); //You may change this...
- HudMessage(d:number+1,s:". \cl",s:name; // or this, to your liking. Everything else should probably stay the same.
- HUDMSG_PLAIN,id_choices+number,CR_GREEN,67.1,170.1+(number*8.0),9999.0);
- ACS_Execute(CURSOR,0);
- maxchoices = number;
- menu = ON;
- for(int x=1; x<=100; x++)
- ClearMsg(id_choices+number+x);
- }
- function void ClearCursor ( void )
- {
- ACS_Terminate(CURSOR,0);
- ClearMsg(id_cursor);
- for(int x=0; x<=100; x++)
- ClearMsg(id_choices+x);
- LocalAmbientSound("menu/clear",127); //Get rid of this (or any other LocalAmbientSounds) if it annoys you. :P
- menu = OFF;
- }
- // The following four scripts are best kept as scripts due to:
- // (a) functions being unable to handle delays
- // (b) "puke" being unable to grab the number of a script as defined in the scripts lump.
- // You should define CURSOR as a number that won't interfere with your scripts.
- script CURSOR ( void )
- {
- SetHudSize(384,256,0);;
- HudMessage(s:"\cj*";
- HUDMSG_PLAIN,id_cursor,-1,52.1,170.1+(currentchoice*8.0),0.12);
- delay(5);
- restart;
- }
- script 201 ( void ) NET // MENU UP.
- {
- if(menu==ON)
- {
- if(currentchoice>0) currentchoice--;
- LocalAmbientSound("menu/cursor",127);
- }
- }
- script 202 ( void ) NET // MENU DOWN.
- {
- if(menu==ON)
- {
- if(currentchoice<=maxchoices-1) currentchoice++;
- LocalAmbientSound("menu/cursor",127);
- }
- }
- script 203 ( void ) NET // MENU SELECT.
- {
- if(menu==ON)
- {
- ClearMsg(id_cursor);
- ACS_Execute(ThisScript,0);
- delay(1); // Don't ask me why this needs to be here; it just... does.
- currentchoice = 0;
- }
- }
- /**************************************MAP SCRIPTS**************************************/
- // Example script to demonstrate setting up this choice menu.
- script 52 ( void )
- {
- ThisScript = 52; // Feh, stupid hacky way of telling script 203 which script to resume. :(
- // Set this value to whatever number the script is.
- // =========================================================================================
- // WARNING: You shouldn't put this script in a place within your map where the script can be
- // triggered multiple times - it will take effect as if the select key was pressed.
- // =========================================================================================
- // Time to set up the choices menu. Choices must be in order and start from 0.
- Choice(0,"Shotgun");
- Choice(1,"Chaingun");
- Choice(2,"BFG9000");
- suspend;
- switch(currentchoice) //This can be changed to an "if" statement if you wish.
- {
- // The following cases can do ABSOLUTELY anything you want.
- // I've set them up to give you weapons when selected.
- case 0:
- GiveInventory("Shotgun",1);
- SetWeapon("Shotgun");
- break;
- case 1:
- GiveInventory("Chaingun",1);
- SetWeapon("Chaingun");
- break;
- case 2:
- // A menu within a menu! Feel free to have as many branches as you wish.
- // (The masochistic types may want to do a full dialog tree for an NPC.) :P
- LocalAmbientSound("menu/choose",127);
- Print(s:"Are you sure? This is a cheapass weapon.");
- Choice(0,"Yes.");
- Choice(1,"No.");
- suspend;
- switch(currentchoice) //Another switch, within a switch! Have as many of these as you want,
- //provided you place a "suspend" immediately before each one.
- {
- case 0:
- GiveInventory("BFG9000",1);
- SetWeapon("BFG9000");
- }
- }
- ClearCursor(); //This will get rid of the menu.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement