Advertisement
B2SX

[Store] Roulette (With Hirsw0w)

Oct 12th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.87 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <baronnhud>
  4. #include <colors>
  5.  
  6. #pragma semicolon 1
  7. #define MIN_CREDITS 499
  8. #define SMIN_CREDITS 500
  9. #define MAX_CREDITS 200000
  10. #define PREFIX "\x01[\x04Roulette\x01]"
  11.  
  12. native Store_GetClientCredits(client);
  13. native Store_SetClientCredits(client, credits);
  14.  
  15. int roll = 48;
  16. int cNum;
  17.  
  18. int rStatus = 0;
  19. int green[33], blue[33], red[33];
  20.  
  21. public Plugin myinfo =
  22. {
  23.     name = "[Store] Roulette",
  24.     author = "BaroNN & Hirsw0w",
  25.     description = "",
  26.     version = "1.4",
  27.     url = ""
  28. };
  29.  
  30. public void OnPluginStart()
  31. {
  32.     RegConsoleCmd("sm_roulette", Command_Roulette);
  33.     CreateTimer(10.0, Timer_Roullete);
  34. }
  35.  
  36. public Action Timer_Roullete(Handle timer)
  37. {
  38.     if(rStatus == 0)
  39.     {
  40.         rStatus = 1;
  41.         BNShowHudAll("255 255 255", "5.0", "120 Seconds To Place Bets, /roulette [red/blue/green] <Amount>", "0.20", "1.0");
  42.         for (int i = 1; i <= 32;i++)
  43.         {
  44.             green[i] = 0;
  45.             red[i] = 0;
  46.             blue[i] = 0;
  47.         }
  48.     }
  49.     else if(rStatus == 1)
  50.     {
  51.         CreateTimer(1.0 / 48.0, rSpin);
  52.         cNum = GetRandomInt(0, 14);
  53.         roll = 45;
  54.         rStatus = 2;
  55.         BNShowHudAll("255 255 255", "5.0", "Placing bets time is over, let it roll!", "0.20", "1.0");
  56.     }
  57.     CreateTimer(120.0, Timer_Roullete);
  58. }
  59.  
  60. public Action Command_Roulette(int client, int args)
  61. {
  62.     if(rStatus != 1)
  63.     {
  64.         PrintToChat(client, "%s \x10The roullete placing bets time is over, \x3wait for the next one to start.", PREFIX);
  65.         return Plugin_Handled;
  66.     }
  67.    
  68.     char arg1[32], arg2[32], Name[32];
  69.     GetClientName(client, Name, 32);
  70.     GetCmdArg(1, arg1, 32);
  71.     GetCmdArg(2, arg2, 32);
  72.    
  73.     int price = StringToInt(arg2);
  74.     if(arg1[0] == '\0' || arg2[0] == '\0')
  75.     {
  76.         PrintToChat(client, "%s \x10Usage: /roulette \x1[\x2red\x01/\x03blue\x01/\x4green\x1] \x1[\x10Credits\x1]", PREFIX);
  77.         return Plugin_Handled;
  78.     }
  79.     if(price > Store_GetClientCredits(client))
  80.     {
  81.         PrintToChat(client, "%s \x2You don't have enough credits to place a bet on the roulette.", PREFIX);
  82.         return Plugin_Handled;
  83.     }
  84.     if(price < MIN_CREDITS)
  85.     {
  86.         PrintToChat(client, "%s \x04You have to spend at least \x02%d \x04credits.", PREFIX, SMIN_CREDITS);
  87.         return Plugin_Handled;
  88.     }
  89.     else if(price > MAX_CREDITS)
  90.     {
  91.         PrintToChat(client, "%s \x04You can't spend that much credits (Max: \x02%d\x04).", PREFIX, MAX_CREDITS);
  92.         return Plugin_Handled;
  93.     }
  94.    
  95.     if(!strcmp(arg1,"green",true))
  96.     {
  97.         green[client] += price;
  98.         Store_SetClientCredits(client, Store_GetClientCredits(client) - price);
  99.         PrintToChat(client, "%s \x10You Placed %d Credits On The Color: \x04Green!", PREFIX, price);
  100.     }
  101.     else if(!strcmp(arg1,"blue",true))
  102.     {
  103.         blue[client] += price;
  104.         Store_SetClientCredits(client, Store_GetClientCredits(client) - price);
  105.         PrintToChat(client, "%s \x10You Placed %d Credits On The Color: \x03Blue!", PREFIX, price);
  106.     }
  107.     else if(!strcmp(arg1,"red",true))
  108.     {
  109.         red[client] += price;
  110.         Store_SetClientCredits(client, Store_GetClientCredits(client) - price);
  111.         PrintToChat(client, "%s \x10You Placed %d Credits On The Color: \x02Red!", PREFIX, price);
  112.     }
  113.    
  114.     return Plugin_Handled;
  115. }
  116.  
  117. public Action rSpin(Handle timer)
  118. {
  119.     cNum++;
  120.     if (cNum == 15)cNum = 0;
  121.    
  122.     if(cNum == 0)PrintHintTextToAll("<big><b>\t\t<font color='#00FF00'>0</font>\n\t\t^</b></big>");
  123.     else if(cNum % 2 == 0)PrintHintTextToAll("<big><b>\t\t<font color='#0000FF'>%d</font>\n\t\t^</b></big>",cNum);
  124.     else PrintHintTextToAll("<big><b>\t\t<font color='#FF0000'>%d</font>\n\t\t^</b></big>",cNum);
  125.    
  126.     if (roll != 0)
  127.     {
  128.         roll--;
  129.         CreateTimer(1.0 / float(roll+1), rSpin);
  130.     }
  131.     else if(roll == 0)
  132.     {
  133.         rStatus = 0;
  134.         char name[9];
  135.         if (cNum == 0) Format(name,9, "green");
  136.         else if (cNum % 2 == 0)Format(name,9, "blue");
  137.         else Format(name,9, "red");
  138.         BNShowHudAll("255 102 51", "5.0", "Winning Number Is %d, Winning color %s", "0.20", "1.0", cNum, name);
  139.         for (int i = 1; i <= 32;i++)
  140.         {
  141.             if (!IsClientConnected(i))continue;
  142.            
  143.             if(green[i] > 0)
  144.             {
  145.                 if(cNum == 0)
  146.                 {
  147.                     PrintToChat(i,"%s \x04You have \x04Won! \x01 %d\x04credits on green.", PREFIX, green[i], green[i] * 14);
  148.                     Store_SetClientCredits(i, Store_GetClientCredits(i) + green[i] * 14);
  149.                 }
  150.                 else PrintToChat(i, "%s \x04You have \x02Lost\x01 %d \x04credits on green.", PREFIX, green[i]);
  151.             }
  152.             if(blue[i] > 0)
  153.             {
  154.                 if(cNum % 2 == 0)
  155.                 {
  156.                     PrintToChat(i,"%s \x03You have \x04won!\x01 %d\x03credits on blue.", PREFIX, blue[i] * 2);
  157.                     Store_SetClientCredits(i, Store_GetClientCredits(i) + blue[i] * 2);
  158.                 }
  159.                 else PrintToChat(i, "%s \x03You have \x02Lost\x01 %d \x03credits on blue.", PREFIX, blue[i]);
  160.             }
  161.             if(red[i] > 0)
  162.             {
  163.                 if(cNum % 2 != 0)
  164.                 {
  165.                     PrintToChat(i,"%s \x02You have Won \x01 %d\x02credits on red.", PREFIX, red[i] * 2);
  166.                     Store_SetClientCredits(i, Store_GetClientCredits(i) + red[i] * 2);
  167.                 }
  168.                 else PrintToChat(i, "%s \x02You have Lost \x01 %d\x02credits on red.", PREFIX, red[i]);
  169.             }
  170.         }
  171.     }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement