Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.51 KB | None | 0 0
  1. #include <sdktools>
  2. #include <store>
  3.  
  4. new bool:Low[66];
  5. new bool:Medium[66];
  6. new bool:High[66];
  7. new bool:Gamble[66];
  8. new bool:InsideLow[66];
  9. new bool:InsideMedium[66];
  10. new bool:InsideHigh[66];
  11. new Handle:g_hJackpotLow;
  12. new Handle:g_hJackpotMedium;
  13. new Handle:g_hJackpotHigh;
  14. new g_iSpendLow[66];
  15. new g_iSpendMedium[66];
  16. new g_iSpendHigh[66];
  17.  
  18. public Plugin:myinfo =
  19. {
  20.     name = "jackpot",
  21.     description = "Gamble system for store!",
  22.     author = "liljekvist",
  23.     version = "1.2",
  24.     url = ""
  25. };
  26.  
  27.  
  28. public void:OnPluginStart()
  29. {
  30.     RegConsoleCmd("sm_gamble", OnGamble, "[Gamble] Enter the gambling area!", 0);
  31.     RegConsoleCmd("sm_bet", OnBet, "[Gamble] Place a bet!", 0);
  32.     RegConsoleCmd("sm_jackpot", OnJackpot, "[Gamble] Show current jackpots", 0);
  33.     g_hJackpotLow = CreateArray(1, 0);
  34.     g_hJackpotMedium = CreateArray(1, 0);
  35.     g_hJackpotHigh = CreateArray(1, 0);
  36.     return void:0;
  37. }
  38.  
  39. public OnGambleMenu(client)
  40. {
  41.     Gamble[client] = 1;
  42.     new String:jackpot[128];
  43.     new String:info[128];
  44.     new String:playerbet[128];
  45.     new potlow = GetArraySize(g_hJackpotLow);
  46.     new potmedium = GetArraySize(g_hJackpotMedium);
  47.     new pothigh = GetArraySize(g_hJackpotHigh);
  48.     new CurrentCredits = Store_GetClientCredits(client);
  49.     if (Low[client] >= true)
  50.     {
  51.         Format(info, 128, "This is (Low pot) area! Jackpot draw in: 30\n!bet <1-10.000> Credits: %d", CurrentCredits);
  52.         if (InsideLow[client] >= true)
  53.         {
  54.             Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendLow[client], float(g_iSpendLow[client]) / float(GetArraySize(g_hJackpotLow)) * 100.0);
  55.             Format(jackpot, 128, "Jackpot: %d", potlow);
  56.         }
  57.         else
  58.         {
  59.             Format(jackpot, 128, "Currently no one betting in here!");
  60.         }
  61.     }
  62.     else
  63.     {
  64.         if (Medium[client] >= true)
  65.         {
  66.             Format(info, 128, "This is (Medium pot) area! Jackpot draw in: 30\n!bet <1-100.000> Credits: %d", CurrentCredits);
  67.             if (InsideMedium[client] >= true)
  68.             {
  69.                 Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendMedium[client], float(g_iSpendMedium[client]) / float(GetArraySize(g_hJackpotMedium)) * 100.0);
  70.                 Format(jackpot, 128, "Jackpot: %d", potmedium);
  71.             }
  72.             else
  73.             {
  74.                 Format(jackpot, 128, "Currently no one betting in here!");
  75.             }
  76.         }
  77.         if (High[client] >= true)
  78.         {
  79.             Format(info, 128, "This is (High pot) area! Jackpot draw in: 30\n!bet <1-1.000.000> Credits: %d", CurrentCredits);
  80.             if (InsideHigh[client] >= true)
  81.             {
  82.                 Format(playerbet, 128, "%N: %d (%.2f%%)", client, g_iSpendHigh[client], float(g_iSpendHigh[client]) / float(GetArraySize(g_hJackpotHigh)) * 100.0);
  83.                 Format(jackpot, 128, "Jackpot: %d", pothigh);
  84.             }
  85.             else
  86.             {
  87.                 Format(jackpot, 128, "Currently no one betting in here!");
  88.             }
  89.         }
  90.         Format(info, 128, "Welcome to gambling area! Select a pot to continue!");
  91.     }
  92.     new Handle:panel = CreatePanel(Handle:0);
  93.     SetPanelTitle(panel, info, false);
  94.     DrawPanelItem(panel, "Low pot - 2. Medium pot - 3. High pot", 0);
  95.     DrawPanelItem(panel, "", 8);
  96.     DrawPanelItem(panel, playerbet, 2);
  97.     DrawPanelItem(panel, jackpot, 2);
  98.     DrawPanelItem(panel, "", 8);
  99.     SetPanelCurrentKey(panel, 8);
  100.     DrawPanelItem(panel, "Leave gambling area\n ", 0);
  101.     SetPanelCurrentKey(panel, 9);
  102.     DrawPanelItem(panel, "Close", 0);
  103.     SetPanelKeys(panel, 391);
  104.     SendPanelToClient(panel, client, Gambles, 100000);
  105.     return 0;
  106. }
  107.  
  108. public Gambles(Handle:panel, MenuAction:action, client, param2)
  109. {
  110.     if (action == MenuAction:4)
  111.     {
  112.         if (param2 == 1)
  113.         {
  114.             Low[client] = 1;
  115.             Medium[client] = 0;
  116.             High[client] = 0;
  117.             OnGambleMenu(client);
  118.         }
  119.         if (param2 == 2)
  120.         {
  121.             Medium[client] = 1;
  122.             High[client] = 0;
  123.             Low[client] = 0;
  124.             OnGambleMenu(client);
  125.         }
  126.         if (param2 == 3)
  127.         {
  128.             High[client] = 1;
  129.             Medium[client] = 0;
  130.             Low[client] = 0;
  131.             OnGambleMenu(client);
  132.         }
  133.         if (param2 == 8)
  134.         {
  135.             CloseHandle(panel);
  136.             PrintToChat(client, "%s You have left the gambling area!", " \x08[\x07Gamble\x08]");
  137.             Gamble[client] = 0;
  138.             High[client] = 0;
  139.             Medium[client] = 0;
  140.             Low[client] = 0;
  141.             InsideHigh[client] = 0;
  142.             InsideMedium[client] = 0;
  143.             InsideLow[client] = 0;
  144.         }
  145.         if (param2 == 9)
  146.         {
  147.             CloseHandle(panel);
  148.             PrintToChat(client, "%s You'r still inside Gambling area, type \x07!gamble\x08 to open the menu again or make a bet!", " \x08[\x07Gamble\x08]");
  149.         }
  150.         if (false <= Gamble[client])
  151.         {
  152.             return 0;
  153.         }
  154.     }
  155.     return 0;
  156. }
  157.  
  158. public Action:OnBet(client, args)
  159. {
  160.     if (!(Gamble[client] >= true))
  161.     {
  162.         PrintToChat(client, "%s You need to enter the gambling area before you can make a bet!(\x07!gamble\x08)", " \x08[\x07Gamble\x08]");
  163.     }
  164.     new var1;
  165.     if (args < 1 && Gamble[client] >= true)
  166.     {
  167.         PrintToChat(client, "%s Usage: \x07sm_bet\x08 <\x07amount\x08>", " \x08[\x07Gamble\x08]");
  168.         return Action:0;
  169.     }
  170.     new String:arg1[16];
  171.     GetCmdArg(1, arg1, 15);
  172.     new arg1int = StringToInt(arg1, 10);
  173.     new Credss = Store_GetClientCredits(client);
  174.     if (Credss < arg1int)
  175.     {
  176.         PrintToChat(client, "%s Not enough credits! Current: \x07%d \x08credits", " \x08[\x07Gamble\x08]", Credss);
  177.         return Action:0;
  178.     }
  179.     new String:buffer[32];
  180.     GetCmdArg(1, buffer, 32);
  181.     new credits = StringToInt(buffer, 10);
  182.     new credits2 = Store_GetClientCredits(client);
  183.     new var2;
  184.     if (Low[client] >= true && Gamble[client] >= true)
  185.     {
  186.         if (credits < 1)
  187.         {
  188.             PrintToChat(client, "%s You have to spend atleast \x04%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
  189.             return Action:0;
  190.         }
  191.         if (credits > 10000)
  192.         {
  193.             PrintToChat(client, "%s You can't spend that much credits (\x04Max: %d\x08).", " \x08[\x07Gamble\x08]", 10000);
  194.             return Action:0;
  195.         }
  196.         if (Gamble[client] >= true)
  197.         {
  198.             CreateTimer(30.0, TimerLow, any:0, 0);
  199.             OnGambleMenu(client);
  200.             g_iSpendLow[client] = arg1int;
  201.             Store_SetClientCredits(client, credits2 - arg1int);
  202.             new i;
  203.             while (i < arg1int)
  204.             {
  205.                 PushArrayCell(g_hJackpotLow, client);
  206.                 i++;
  207.             }
  208.             new i = 1;
  209.             while (i <= MaxClients)
  210.             {
  211.                 if (Gamble[client] >= true)
  212.                 {
  213.                     new Handle:packlow = CreateDataPack();
  214.                     WritePackCell(packlow, client);
  215.                     WritePackCell(packlow, credits);
  216.                 }
  217.                 k++;
  218.             }
  219.         }
  220.         new i = 1;
  221.         while (i <= MaxClients)
  222.         {
  223.             if (Gamble[i] >= true)
  224.             {
  225.                 OnGambleMenu(i);
  226.                 InsideLow[i] = 1;
  227.             }
  228.             i++;
  229.         }
  230.         PrintToChatAll("%s \x04%N\x08 has entered the (\x04Low pot\x08) with \x04%d\x08 credits!(\x08Chance: \x04%.2f%%% \x08Jackpot: \x04%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendLow[client], float(g_iSpendLow[client]) / float(GetArraySize(g_hJackpotLow)) * 100.0, GetArraySize(g_hJackpotLow));
  231.         OnGambleMenu(client);
  232.     }
  233.     new var3;
  234.     if (Medium[client] >= true && Gamble[client] >= true)
  235.     {
  236.         if (credits < 1)
  237.         {
  238.             PrintToChat(client, "%s You have to spend atleast \x07%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
  239.             return Action:0;
  240.         }
  241.         if (credits > 100000)
  242.         {
  243.             PrintToChat(client, "%s You can't spend that much credits (\x07Max: %d\x08).", " \x08[\x07Gamble\x08]", 100000);
  244.             return Action:0;
  245.         }
  246.         if (Gamble[client] >= true)
  247.         {
  248.             CreateTimer(30.0, TimerMedium, any:0, 0);
  249.             g_iSpendMedium[client] = arg1int;
  250.             Store_SetClientCredits(client, credits2 - arg1int);
  251.             new i;
  252.             while (i < arg1int)
  253.             {
  254.                 PushArrayCell(g_hJackpotMedium, client);
  255.                 i++;
  256.             }
  257.             new i = 1;
  258.             while (i <= MaxClients)
  259.             {
  260.                 if (Gamble[client] >= true)
  261.                 {
  262.                     new Handle:packmedium = CreateDataPack();
  263.                     WritePackCell(packmedium, client);
  264.                     WritePackCell(packmedium, credits);
  265.                 }
  266.                 i++;
  267.             }
  268.         }
  269.         new i = 1;
  270.         while (i <= MaxClients)
  271.         {
  272.             if (Gamble[i] >= true)
  273.             {
  274.                 OnGambleMenu(i);
  275.                 InsideMedium[i] = 1;
  276.             }
  277.             i++;
  278.         }
  279.         PrintToChatAll("%s \x09%N\x08 has entered the (\x09Medium pot\x08) with \x09%d\x08 credits!(\x08Chance: \x09%.2f%%% \x08Jackpot: \x09%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendMedium[client], float(g_iSpendMedium[client]) / float(GetArraySize(g_hJackpotMedium)) * 100.0, GetArraySize(g_hJackpotMedium));
  280.         OnGambleMenu(client);
  281.     }
  282.     new var4;
  283.     if (High[client] >= true && Gamble[client] >= true)
  284.     {
  285.         if (credits < 1)
  286.         {
  287.             PrintToChat(client, "%s You have to spend atleast \x07%d\x08 credits.", " \x08[\x07Gamble\x08]", 1);
  288.             return Action:0;
  289.         }
  290.         if (credits > 1000000)
  291.         {
  292.             PrintToChat(client, "%s You can't spend that much credits (\x07Max: %d\x08).", " \x08[\x07Gamble\x08]", 1000000);
  293.             return Action:0;
  294.         }
  295.         if (Gamble[client] >= true)
  296.         {
  297.             CreateTimer(30.0, TimerHigh, any:0, 0);
  298.             g_iSpendHigh[client] = arg1int;
  299.             Store_SetClientCredits(client, credits2 - arg1int);
  300.             new i;
  301.             while (i < arg1int)
  302.             {
  303.                 PushArrayCell(g_hJackpotHigh, client);
  304.                 i++;
  305.             }
  306.             new i = 1;
  307.             while (i <= MaxClients)
  308.             {
  309.                 if (Gamble[client] >= true)
  310.                 {
  311.                     new Handle:packhigh = CreateDataPack();
  312.                     WritePackCell(packhigh, client);
  313.                     WritePackCell(packhigh, credits);
  314.                 }
  315.                 i++;
  316.             }
  317.         }
  318.         new i = 1;
  319.         while (i <= MaxClients)
  320.         {
  321.             if (Gamble[i] >= true)
  322.             {
  323.                 OnGambleMenu(i);
  324.                 InsideHigh[i] = 1;
  325.             }
  326.             i++;
  327.         }
  328.         PrintToChatAll("%s \x07%N\x08 has entered the (\x07High pot\x08) with \x07%d\x08 credits!(\x08Chance: \x07%.2f%%% \x08Jackpot: \x07%d \x08credits)", " \x08[\x07Gamble\x08]", client, g_iSpendHigh[client], float(g_iSpendHigh[client]) / float(GetArraySize(g_hJackpotHigh)) * 100.0, GetArraySize(g_hJackpotHigh));
  329.         OnGambleMenu(client);
  330.     }
  331.     return Action:0;
  332. }
  333.  
  334. public Action:OnGamble(client, args)
  335. {
  336.     if (Gamble[client] >= true)
  337.     {
  338.         OnGambleMenu(client);
  339.         PrintToChat(client, "%s You have already entered the gambling area!", " \x08[\x07Gamble\x08]");
  340.         return Action:0;
  341.     }
  342.     OnGambleMenu(client);
  343.     PrintToChat(client, "%s You have entered the gambling area(\x07100%% at own risk!\x08)", " \x08[\x07Gamble\x08]");
  344.     return Action:0;
  345. }
  346.  
  347. public Action:TimerLow(Handle:timer)
  348. {
  349.     new jackpot = GetArraySize(g_hJackpotLow);
  350.     if (0 >= jackpot)
  351.     {
  352.         return Action:0;
  353.     }
  354.     new winner = GetArrayCell(g_hJackpotLow, GetRandomInt(0, jackpot + -1), 0, false);
  355.     new ticket = GetRandomInt(12425, 192849);
  356.     new var1;
  357.     if (winner == -1 || !IsClientInGame(winner))
  358.     {
  359.         PrintToChatAll("%s Winner has left the game but won \x07%d\x08 credits on \x07low\x08 pot!", " \x08[\x07Gamble\x08]", jackpot);
  360.     }
  361.     else
  362.     {
  363.         PrintToChatAll("%s Jackpot (\x04Low pot\x08) winner: \x04%N\x08 (Ticket: \x04#%d\x08) (Chance: \x04%.2f%%\x08) Jackpot: \x04%d\x08 credits", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendLow[winner]) / float(GetArraySize(g_hJackpotLow)) * 100.0, jackpot);
  364.     }
  365.     IsClientInGame(winner);
  366.     new creds = Store_GetClientCredits(winner);
  367.     Store_SetClientCredits(winner, jackpot + creds);
  368.     new i = 1;
  369.     while (i <= MaxClients)
  370.     {
  371.         g_iSpendLow[i] = 0;
  372.         InsideLow[i] = 0;
  373.         if (Gamble[i] >= true)
  374.         {
  375.             OnGambleMenu(i);
  376.         }
  377.         i++;
  378.     }
  379.     ClearArray(g_hJackpotLow);
  380.     return Action:0;
  381. }
  382.  
  383. public Action:TimerMedium(Handle:timer)
  384. {
  385.     new jackpot = GetArraySize(g_hJackpotMedium);
  386.     if (0 >= jackpot)
  387.     {
  388.         return Action:0;
  389.     }
  390.     new winner = GetArrayCell(g_hJackpotMedium, GetRandomInt(0, jackpot + -1), 0, false);
  391.     new ticket = GetRandomInt(12425, 192849);
  392.     new var1;
  393.     if (winner == -1 || !IsClientInGame(winner))
  394.     {
  395.         PrintToChatAll("%s Winner has left the game but won \x07%d\x08 credits on \x07medium\x08 pot!", " \x08[\x07Gamble\x08]", jackpot);
  396.     }
  397.     else
  398.     {
  399.         PrintToChatAll("%s Jackpot (\x09Medium pot\x08) winner: \x09%N\x08 (Ticket: \x09#%d\x08) (Chance: \x09%.2f%%\x08) Jackpot: \x09%d\x08", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendMedium[winner]) / float(GetArraySize(g_hJackpotMedium)) * 100.0, jackpot);
  400.     }
  401.     IsClientInGame(winner);
  402.     new creds = Store_GetClientCredits(winner);
  403.     Store_SetClientCredits(winner, jackpot + creds);
  404.     new i = 1;
  405.     while (i <= MaxClients)
  406.     {
  407.         g_iSpendMedium[i] = 0;
  408.         InsideMedium[i] = 0;
  409.         if (Gamble[i] >= true)
  410.         {
  411.             OnGambleMenu(i);
  412.         }
  413.         i++;
  414.     }
  415.     ClearArray(g_hJackpotMedium);
  416.     return Action:0;
  417. }
  418.  
  419. public Action:TimerHigh(Handle:timer)
  420. {
  421.     new jackpot = GetArraySize(g_hJackpotHigh);
  422.     if (0 >= jackpot)
  423.     {
  424.         return Action:0;
  425.     }
  426.     new winner = GetArrayCell(g_hJackpotHigh, GetRandomInt(0, jackpot + -1), 0, false);
  427.     new ticket = GetRandomInt(12425, 192849);
  428.     if (IsClientInGame(winner))
  429.     {
  430.         PrintToChatAll("%s Jackpot (\x07High pot\x08) winner: \x07%N\x08 (Ticket: \x07#%d\x08) (Chance: \x07%.2f%%\x08) \x08Jackpot: \x07%d\x08", " \x08[\x07Gamble\x08]", winner, ticket, float(g_iSpendHigh[winner]) / float(GetArraySize(g_hJackpotHigh)) * 100.0, jackpot);
  431.     }
  432.     else
  433.     {
  434.         PrintToChatAll("%s Winner has left the game, no one won the pot! Jackpot was: \x07%d\x08", " \x08[\x07Gamble\x08]", jackpot);
  435.     }
  436.     IsClientInGame(winner);
  437.     new creds = Store_GetClientCredits(winner);
  438.     Store_SetClientCredits(winner, jackpot + creds);
  439.     new i = 1;
  440.     while (i <= MaxClients)
  441.     {
  442.         g_iSpendHigh[i] = 0;
  443.         InsideHigh[i] = 0;
  444.         if (Gamble[i] >= true)
  445.         {
  446.             OnGambleMenu(i);
  447.         }
  448.         i++;
  449.     }
  450.     ClearArray(g_hJackpotHigh);
  451.     return Action:0;
  452. }
  453.  
  454. public Action:OnJackpot(client, args)
  455. {
  456.     if (Gamble[client] >= true)
  457.     {
  458.         new LowPot = GetArraySize(g_hJackpotLow);
  459.         new MediumPot = GetArraySize(g_hJackpotMedium);
  460.         new HighPot = GetArraySize(g_hJackpotHigh);
  461.         PrintToChat(client, "%s (\x04Low pot\x08) - \x04%d\x08 credits!", " \x08[\x07Gamble\x08]", LowPot);
  462.         PrintToChat(client, "%s (\x09Medium pot\x08) - \x09%d\x08 credits!", " \x08[\x07Gamble\x08]", MediumPot);
  463.         PrintToChat(client, "%s (\x07High pot\x08) - \x07%d\x08 credits!", " \x08[\x07Gamble\x08]", HighPot);
  464.     }
  465.     else
  466.     {
  467.         PrintToChat(client, "%s You need to enter the gambling area before you can see the jackpots!(\x07!gamble\x08)", " \x08[\x07Gamble\x08]");
  468.     }
  469.     return Action:3;
  470. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement