Want more features on Pastebin? Sign Up, it's FREE!
Guest

Jimmy91ST

By: a guest on Mar 10th, 2009  |  syntax: None  |  size: 4.48 KB  |  views: 657  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /****************************************KEYCONF****************************************/
  2.  
  3. // Bah, so much for GetPlayerInput(). :P
  4.  
  5. alias choiceup "puke 201"
  6. alias choicedown "puke 202"
  7. alias choiceselect "puke 203"
  8.  
  9. defaultbind end choiceselect
  10. defaultbind pgup choiceup
  11. defaultbind pgdn choicedown
  12.  
  13. addkeysection "Choice Menus" menus
  14. addmenukey "Menu Select" choiceselect
  15. addmenukey "Menu Up" choiceup
  16. addmenukey "Menu Down" choicedown
  17.  
  18. /*************************************GLOBAL SCRIPTS************************************/
  19. // Put these (up to the next line) in a library if need be.
  20. #include "zcommon.acs"
  21.  
  22. #define CURSOR 200
  23.  
  24. #define id_cursor               9970
  25. #define id_choices              9980
  26.  
  27. int ThisScript = 0;
  28. int menu = OFF;
  29. int currentchoice = 0;
  30. int maxchoices = 0;
  31.  
  32. function void ClearMsg ( int id )
  33. {
  34.   HudMessage(s:""; 0,id,-1,0,0,0);
  35. }
  36.  
  37. function void Choice ( int number, int name )
  38. {
  39.   SetHudSize(384,256,0);
  40.   SetFont("SmallFont");                    //You may change this...
  41.   HudMessage(d:number+1,s:". \cl",s:name;  // or this, to your liking. Everything else should probably stay the same.
  42.   HUDMSG_PLAIN,id_choices+number,CR_GREEN,67.1,170.1+(number*8.0),9999.0);
  43.   ACS_Execute(CURSOR,0);
  44.   maxchoices = number;
  45.   menu = ON;
  46.  
  47.   for(int x=1; x<=100; x++)
  48.   ClearMsg(id_choices+number+x);
  49. }
  50.  
  51. function void ClearCursor ( void )
  52. {
  53.   ACS_Terminate(CURSOR,0);
  54.   ClearMsg(id_cursor);
  55.   for(int x=0; x<=100; x++)
  56.   ClearMsg(id_choices+x);
  57.   LocalAmbientSound("menu/clear",127); //Get rid of this (or any other LocalAmbientSounds) if it annoys you. :P
  58.   menu = OFF;
  59. }
  60.  
  61. // The following four scripts are best kept as scripts due to:
  62. // (a) functions being unable to handle delays
  63. // (b) "puke" being unable to grab the number of a script as defined in the scripts lump.
  64.  
  65. // You should define CURSOR as a number that won't interfere with your scripts.
  66. script CURSOR ( void )
  67. {
  68.   SetHudSize(384,256,0);;
  69.   HudMessage(s:"\cj*";
  70.   HUDMSG_PLAIN,id_cursor,-1,52.1,170.1+(currentchoice*8.0),0.12);
  71.   delay(5);
  72.   restart;
  73. }
  74.  
  75. script 201 ( void ) NET // MENU UP.
  76. {
  77.   if(menu==ON)
  78.   {
  79.     if(currentchoice>0) currentchoice--;
  80.     LocalAmbientSound("menu/cursor",127);
  81.   }
  82. }
  83.  
  84. script 202 ( void ) NET // MENU DOWN.
  85. {
  86.   if(menu==ON)
  87.   {
  88.     if(currentchoice<=maxchoices-1) currentchoice++;
  89.     LocalAmbientSound("menu/cursor",127);
  90.   }
  91. }
  92.  
  93. script 203 ( void ) NET // MENU SELECT.
  94. {
  95.   if(menu==ON)
  96.   {
  97.     ClearMsg(id_cursor);
  98.     ACS_Execute(ThisScript,0);
  99.     delay(1); // Don't ask me why this needs to be here; it just... does.
  100.     currentchoice = 0;
  101.   }
  102. }
  103.  
  104. /**************************************MAP SCRIPTS**************************************/
  105.  
  106. // Example script to demonstrate setting up this choice menu.
  107. script 52 ( void )
  108. {
  109.   ThisScript = 52; // Feh, stupid hacky way of telling script 203 which script to resume. :(
  110.                    // Set this value to whatever number the script is.
  111.  
  112.   // =========================================================================================
  113.   // WARNING: You shouldn't put this script in a place within your map where the script can be
  114.   // triggered multiple times - it will take effect as if the select key was pressed.
  115.   // =========================================================================================
  116.  
  117.   // Time to set up the choices menu. Choices must be in order and start from 0.
  118.   Choice(0,"Shotgun");
  119.   Choice(1,"Chaingun");
  120.   Choice(2,"BFG9000");
  121.   suspend;
  122.   switch(currentchoice) //This can be changed to an "if" statement if you wish.
  123.   {
  124.   // The following cases can do ABSOLUTELY anything you want.
  125.   // I've set them up to give you weapons when selected.
  126.   case 0:
  127.     GiveInventory("Shotgun",1);
  128.     SetWeapon("Shotgun");
  129.     break;
  130.   case 1:
  131.     GiveInventory("Chaingun",1);
  132.     SetWeapon("Chaingun");
  133.     break;
  134.   case 2:
  135.     // A menu within a menu! Feel free to have as many branches as you wish.
  136.     // (The masochistic types may want to do a full dialog tree for an NPC.) :P
  137.     LocalAmbientSound("menu/choose",127);
  138.     Print(s:"Are you sure? This is a cheapass weapon.");
  139.     Choice(0,"Yes.");
  140.     Choice(1,"No.");
  141.     suspend;
  142.     switch(currentchoice) //Another switch, within a switch! Have as many of these as you want,
  143.                           //provided you place a "suspend" immediately before each one.
  144.     {
  145.     case 0:
  146.       GiveInventory("BFG9000",1);
  147.       SetWeapon("BFG9000");
  148.     }
  149.   }
  150.  
  151.   ClearCursor(); //This will get rid of the menu.
  152. }
clone this paste RAW Paste Data