Guest User

Base code for Custom LRs with AutoStart false for SM_Hosties

a guest
Aug 20th, 2012
2,592
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Base code for Lastrequest with AutoStart false.
  3.  */
  4.  
  5. #include <sourcemod>
  6. #include <sdktools>
  7. #include <menus>
  8. // Make certain the lastrequest.inc is last on the list
  9. #include <hosties>
  10. #include <lastrequest>
  11.  
  12. #pragma semicolon 1
  13.  
  14. #define PLUGIN_VERSION "1.0.0"
  15.  
  16. // This global will store the index number for the new Last Request
  17. new g_LREntryNum;
  18. new This_LR_Type;
  19. new LR_Player_Prisoner;
  20. new LR_Player_Guard;
  21.  
  22. // menu handler
  23. new Handle:Menu = INVALID_HANDLE;
  24.  
  25. public Plugin:myinfo =
  26. {
  27.     name = "Last Request: LR",
  28.     author = "Author",
  29.     description = "Adds a Lastrequest to sm_hosties",
  30.     version = PLUGIN_VERSION,
  31.     url = "yourwebsite"
  32. };
  33.  
  34. public OnPluginStart()
  35. {
  36.     // Load translations
  37.     LoadTranslations("CustomLRs.phrases");
  38.    
  39.     // menu
  40.     Menu = CreateMenu(MenuHandler);
  41.     SetMenuTitle(Menu, "LR mode select");
  42.     AddMenuItem(Menu, "M1", "Mode 1");
  43.     AddMenuItem(Menu, "M2", "Mode 2");
  44.     SetMenuExitButton(Menu, true);
  45. }
  46.  
  47. public OnConfigsExecuted()
  48. {
  49.     static bool:bAddedLR = false;
  50.     if (!bAddedLR)
  51.     {
  52.         g_LREntryNum = AddLastRequestToList(LR_Start, LR_Stop, "LastRequest", false);
  53.         bAddedLR = true;
  54.     }  
  55. }
  56.  
  57. public MenuHandler(Handle:menu, MenuAction:action, param1, param2)
  58. {
  59.     if (action == MenuAction_Select)
  60.     {
  61.         if(param2 == 0) // Mode 1
  62.         {
  63.             // Code for mode 1 here (can also be a function, recommended in seperate function)
  64.             //
  65.             // End for Code for mode 1
  66.            
  67.             // InitializeLR to start LR globally
  68.             InitializeLR(param1);
  69.         }
  70.         if(param2 == 1) // Mode 2
  71.         {
  72.             // Code for mode 2 here (can also be a function, recommended in seperate function)
  73.             //
  74.             // End for Code for mode 2
  75.            
  76.             // InitializeLR to start LR globally
  77.             InitializeLR(param1);
  78.         }
  79.     }
  80. }
  81.  
  82. // The plugin should remove any LRs it loads when it's unloaded
  83. public OnPluginEnd()
  84. {
  85.     RemoveLastRequestFromList(LR_Start, LR_Stop, "LastRequest");
  86. }
  87.  
  88. public LR_Start(Handle:LR_Array, iIndexInArray)
  89. {
  90.     This_LR_Type = GetArrayCell(LR_Array, iIndexInArray, _:Block_LRType); // get this lr from selection
  91.     if (This_LR_Type == g_LREntryNum)
  92.     {
  93.         LR_Player_Prisoner = GetArrayCell(LR_Array, iIndexInArray, _:Block_Prisoner); // get prisoner's id
  94.         LR_Player_Guard = GetArrayCell(LR_Array, iIndexInArray, _:Block_Guard); // get guard's id
  95.        
  96.         // check datapack value
  97.         new LR_Pack_Value = GetArrayCell(LR_Array, iIndexInArray, _:Block_Global1);
  98.         switch (LR_Pack_Value)
  99.         {
  100.             case -1:
  101.             {
  102.                 PrintToServer("no info included");
  103.             }
  104.         }
  105.        
  106.         SetArrayCell(LR_Array, iIndexInArray, 3, _:Block_Global1);
  107.        
  108.         // here what you want before lr starts
  109.         // ex : send a menu to the prisoner to select a mode in this lr.
  110.         // after player selected a mode, call a function you need to make and call InitializeLR();
  111.         // and for the real sample
  112.         DisplayMenu(Menu, LR_Player_Prisoner, 0); // menu's handle, the prisoner, how long the menu holds on screen if player selects nothing
  113.         PrintToChat(LR_Player_Guard, "\x04[SM] \x01The player %N selected to you as a partner in his lastrequest.", LR_Player_Prisoner);
  114.     }
  115. }
  116.  
  117. public LR_Stop(Type, Prisoner, Guard)
  118. {
  119.     // What happens if there is a winner / lr aborted
  120. }
RAW Paste Data