Advertisement
B2SX

[Store] Case Opening

Oct 12th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.73 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3. #include <sdktools>
  4.  
  5. native Store_GetClientCredits(client);
  6. native Store_SetClientCredits(client, credits);
  7. #define PREFIX "\x01[\x03CaseOpening\x01]\x04"
  8.  
  9. char casePREFIX[32] = "";
  10. int gTime[32], bCase[32], Item, Case, MIN, MAX;
  11. ConVar OpenCost1, OpenCost2, OpenCost3, OpenCost4, OpenCost5, OpenCost6;
  12. ConVar MinPrice1, MinPrice2, MinPrice3, MinPrice4, MinPrice5, MinPrice6;
  13. ConVar MaxPrice1, MaxPrice2, MaxPrice3, MaxPrice4, MaxPrice5, MaxPrice6;
  14.  
  15. public Plugin myinfo =
  16. {
  17.     name = "[Store] Case Opening",
  18.     author = "BaroNN",
  19.     description = "Case Opening Plugin for Zephyrus Store",
  20.     version = "1.2",
  21.     url = ""
  22. };
  23.  
  24. public void OnPluginStart()
  25. {
  26.     RegConsoleCmd("sm_cases", CaseMenu);
  27.     RegConsoleCmd("sm_case", CaseMenu);
  28.     RegConsoleCmd("sm_opencase", CaseMenu);
  29.    
  30.     // Case 1 //
  31.     OpenCost1 = CreateConVar("store_case1_open_cost", "1000");
  32.     MinPrice1 = CreateConVar("store_case1_min_price", "100");
  33.     MaxPrice1 = CreateConVar("store_case1_max_price", "2000");
  34.     // Case 2 //
  35.     OpenCost2 = CreateConVar("store_case2_open_cost", "5000");
  36.     MinPrice2 = CreateConVar("store_case2_min_price", "100");
  37.     MaxPrice2 = CreateConVar("store_case2_max_price", "6000");
  38.     // Case 3 //
  39.     OpenCost3 = CreateConVar("store_case3_open_cost", "10000");
  40.     MinPrice3 = CreateConVar("store_case3_min_price", "100");
  41.     MaxPrice3 = CreateConVar("store_case3_max_price", "11000");
  42.     // Case 4 //
  43.     OpenCost4 = CreateConVar("store_case4_open_cost", "25000");
  44.     MinPrice4 = CreateConVar("store_case4_min_price", "100");
  45.     MaxPrice4 = CreateConVar("store_case4_max_price", "26500");
  46.     // Case 5 //
  47.     OpenCost5 = CreateConVar("store_case5_open_cost", "50000");
  48.     MinPrice5 = CreateConVar("store_case5_min_price", "100");
  49.     MaxPrice5 = CreateConVar("store_case5_max_price", "65000");
  50.     // Case 6 //
  51.     OpenCost6 = CreateConVar("store_case6_open_cost", "100000");
  52.     MinPrice6 = CreateConVar("store_case6_min_price", "100");
  53.     MaxPrice6 = CreateConVar("store_case6_max_price", "110000");
  54.    
  55.     AutoExecConfig(true, "store_caseopening");
  56. }
  57.  
  58. public void OnMapStart()
  59. {
  60.     PrecacheSound("misc/caseopening.mp3", true);
  61.     AddFileToDownloadsTable("sound/caseopening.mp3");
  62. }
  63.  
  64. public Action CaseMenu(int client, int args)
  65. {
  66.     if (gTime[client] > GetTime())
  67.     {
  68.         PrintToChat(client, "%s \x03You can open only one case per\x03 10 \x04seconds.", PREFIX);
  69.         return Plugin_Handled;
  70.     }
  71.     if (bCase[client])
  72.     {
  73.         PrintToChat(client, "%s \x03You are allready opening a case wait.", PREFIX);
  74.         return Plugin_Handled;
  75.     }
  76.    
  77.     Handle menu = CreateMenu(Handelecases);
  78.     SetMenuTitle(menu, "[Store] Case Opening Menu\nBalance: %d (By BaroNN)", Store_GetClientCredits(client));
  79.    
  80.     AddMenuItem(menu, "", "Hurricane Case [1000 Credits]");
  81.     AddMenuItem(menu, "", "Vulcan Case [5000 Credits]");
  82.     AddMenuItem(menu, "", "Revolution Case [10000 Credits]");
  83.     AddMenuItem(menu, "", "Velocity Case [25000 Credits]");
  84.     AddMenuItem(menu, "", "Masterline Case [50000 Credits]");
  85.     AddMenuItem(menu, "", "BaroNN Case [100000 Credits]");
  86.    
  87.     DisplayMenu(menu, client, 30);
  88.     return Plugin_Continue;
  89. }
  90.  
  91. public int Handelecases(Menu menu, MenuAction action, int client, int itemNum)
  92. {
  93.     if (action == MenuAction_End)
  94.         CloseHandle(menu);
  95.    
  96.     if (action == MenuAction_Select)
  97.     {
  98.         switch (itemNum)
  99.         {
  100.             case 0:Case = GetConVarInt(OpenCost1), casePREFIX = "Hurricane";
  101.             case 1:Case = GetConVarInt(OpenCost2), casePREFIX = "Vulcan";
  102.             case 2:Case = GetConVarInt(OpenCost3), casePREFIX = "Revolution";
  103.             case 3:Case = GetConVarInt(OpenCost4), casePREFIX = "Velocity";
  104.             case 4:Case = GetConVarInt(OpenCost5), casePREFIX = "Masterline";
  105.             case 5:Case = GetConVarInt(OpenCost6), casePREFIX = "BaroNN";
  106.         }
  107.        
  108.         Item = itemNum;
  109.         StartOpening(client);
  110.     }
  111. }
  112.  
  113. stock void StartOpening(int client)
  114. {
  115.     if (Store_GetClientCredits(client) >= Case)
  116.     {
  117.         bCase[client] = true;
  118.         ClientCommand(client, "play *caseopening.mp3");
  119.         CreateTimer(0.1, CaseStart, client, TIMER_REPEAT);
  120.         Store_SetClientCredits(client, Store_GetClientCredits(client) - Case);
  121.     }
  122.     else PrintToChat(client, "%s \x03You Dont Have Enough Credits\x10 To Open The \x03%s \x04Case.", PREFIX, casePREFIX);
  123. }
  124.  
  125. public Action CaseStart(Handle timer, any client)
  126. {
  127.     if (IsClientConnected(client) && IsClientInGame(client) && !IsFakeClient(client))
  128.     {
  129.         static int Number = 0;
  130.        
  131.         switch (Item)
  132.         {
  133.             case 0:MIN = GetConVarInt(MinPrice1), MAX = GetConVarInt(MaxPrice1);
  134.             case 1:MIN = GetConVarInt(MinPrice2), MAX = GetConVarInt(MaxPrice2);
  135.             case 2:MIN = GetConVarInt(MinPrice3), MAX = GetConVarInt(MaxPrice3);
  136.             case 3:MIN = GetConVarInt(MinPrice4), MAX = GetConVarInt(MaxPrice4);
  137.             case 4:MIN = GetConVarInt(MinPrice5), MAX = GetConVarInt(MaxPrice5);
  138.             case 5:MIN = GetConVarInt(MinPrice6), MAX = GetConVarInt(MaxPrice6);
  139.         }
  140.        
  141.         if (Number >= 100)
  142.         {
  143.             Number = 0;
  144.             int randomNumber = GetRandomInt(MIN, MAX);
  145.             PrintCenterText(client, "<big><b><font color='#dd2f2f'><center>[%s Case]</center>\n</font><font color='#0000FF'>|| <font color='#15fb00'>%i</font> <font color='#00CCFF'>Credits</font><font color='#0000FF'> ||</font></b></big>", casePREFIX, randomNumber);
  146.             PrintToChat(client, "%s \x01%N \x10Has Opened a \x03%s \x04Case \x10And Found: \x03%i \x01Credits!", PREFIX, client, casePREFIX, randomNumber);
  147.             Store_SetClientCredits(client, Store_GetClientCredits(client) + randomNumber);
  148.             gTime[client] = GetTime() + 10;
  149.             bCase[client] = false;
  150.            
  151.             return Plugin_Stop;
  152.         }
  153.        
  154.         int randomNumber = GetRandomInt(MIN, MAX);
  155.         PrintCenterText(client, "<big><b><font color='#0000FF'>||</font> <font color='#15fb00'>%i</font><font color='#00CCFF'> Credits</font> <font color='#0000FF'>||</font></b></big>", randomNumber);
  156.         Number++;
  157.         return Plugin_Continue;
  158.     }
  159.     return Plugin_Handled;
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement