Advertisement
macquid123560

Top Jailbreak | Lucky Tickets

Mar 23rd, 2016
829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.70 KB | None | 0 0
  1. /* Plugin generated by Top Jailbreak-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fvault>
  6. #include <ColorChat>
  7.  
  8. #define Price 7500
  9. #define MaxTickets 150
  10. #define CD_TASK 101
  11.  
  12.  
  13. new Tickets[33],Running[33],CD[33],PrizeAmount[33],u_All[33];
  14.  
  15. native get_user_cash(index)
  16. native set_user_cash(index,amount)
  17.  
  18.  
  19. public client_connect( id )
  20.     CmdLoad(id)
  21. public client_disconnect( id )
  22.     CmdSave(id)
  23.  
  24. new szVault[] = "luckycardfixeda";
  25.    
  26. public plugin_init() {
  27.     register_plugin("Lucky Ticket","1.0","Built by MJ || Edit by @.TheBomB`")
  28.    
  29.     register_clcmd("say /luckyticket","LuckyMenu");
  30.     register_clcmd("say /luckycard","LuckyMenu");
  31.     register_clcmd("say /lucky","LuckyMenu");
  32.     register_concmd("amx_add_tickets","AddCmd");
  33.     register_concmd("amx_set_tickets","SetCmd");
  34.     register_concmd("amx_remove_tickets","RemoveCmd");
  35.     register_concmd("amx_reset_tickets","ResetCmd");
  36. }
  37.  
  38. public plugin_precache()
  39. {
  40.         precache_sound("Top/JB/Bigwin.wav");
  41. }
  42.        
  43. public plugin_natives()
  44. {
  45.     register_native("get_user_tickets","_get_user_tickets");
  46.     register_native("set_user_tickets","_set_user_tickets");
  47. }
  48.  
  49. public _get_user_tickets(plugin,param)
  50. {
  51.     new index = get_param(1);
  52.     return Tickets[index];
  53. }
  54.  
  55. public _set_user_tickets(plugin,param)
  56. {
  57.     new index = get_param(1);
  58.     new Amount = get_param(2);
  59.     Tickets[index] = Amount;
  60.     return Tickets[index];
  61. }
  62.  
  63. //CallBacks
  64. public buycb(id)
  65. {
  66.     if(get_user_cash(id) < Price || Tickets[id] > 149)
  67.         return ITEM_DISABLED;
  68.     return ITEM_ENABLED;
  69. }
  70.  
  71. public buy10cb(id)
  72. {
  73.     if(get_user_cash(id) < Price*10|| Tickets[id] > 140 || !(get_user_flags(id) & ADMIN_LEVEL_C))
  74.         return ITEM_DISABLED;
  75.     return ITEM_ENABLED;
  76. }
  77.  
  78. public buy100cb(id)
  79. {
  80.     if(get_user_cash(id) < Price*100|| Tickets[id] > 50 || !(get_user_flags(id) & ADMIN_LEVEL_C))
  81.         return ITEM_DISABLED;
  82.     return ITEM_ENABLED;
  83. }
  84.  
  85. public usecb(id)
  86. {
  87.     if((Tickets[id] < 1) || Running[id])
  88.         return ITEM_DISABLED;
  89.     return ITEM_ENABLED;
  90. }
  91.  
  92. public fastusecb(id)
  93. {
  94.     if((Tickets[id] < 1) || Running[id] || !(get_user_flags(id) & ADMIN_LEVEL_C))
  95.         return ITEM_DISABLED;
  96.     return ITEM_ENABLED;
  97. }
  98.  
  99. //End CallBacks
  100. //Menu
  101. public LuckyMenu (id)
  102. {
  103.     new Info[512];
  104.     formatex(Info,charsmax(Info),"Lucky Card\y Menu\w^nYour cash:\y %i\w^nYour tickets:\y %i\d/\r150^n\wBiggest Won: \y500,000",get_user_cash(id),Tickets[id]);
  105.     new hMenu = menu_create(Info,"LuckyHandler");
  106.    
  107.     new bcb = menu_makecallback("buycb");
  108.     new b1cb = menu_makecallback("buy10cb");
  109.     new b10cb = menu_makecallback("buy100cb");
  110.     new ucb = menu_makecallback("usecb");
  111.     new fucb = menu_makecallback("fastusecb");
  112.    
  113.     menu_additem(hMenu,"\yBuy \wTicket \r(\y7,500\w cash\r)",.callback=bcb);
  114.     menu_additem(hMenu,"\yUse \wTicket",.callback=ucb);
  115.     menu_additem(hMenu,"\ySell\w Tickets \r(\wfor \y5,000\w cash\r)^n^n\d- \rPremium Gets:",.callback=ucb);
  116.     menu_additem(hMenu,"\yBuy \w10 Tickets \r(\y75,000\w cash\r)",.callback=b1cb);
  117.     menu_additem(hMenu,"\yBuy \w100 Tickets \r(\y750,000\w cash\r)",.callback=b10cb);
  118.     menu_additem(hMenu,"\yFast Use \wTicket",.callback=fucb);
  119.     menu_additem(hMenu,"\yUse \wAll Tickets",.callback=fucb);  
  120.     menu_display(id,hMenu);
  121.     return 1;
  122. }
  123. public LuckyHandler (id,hMenu,Item)
  124. {
  125.     new sellticket = 5000
  126.     switch (Item)
  127.     {
  128.         case MENU_EXIT: menu_destroy(hMenu);
  129.         case 0:
  130.         {
  131.             if(get_user_cash(id) < Price) return 1;
  132.             Tickets[id] ++;
  133.             set_user_cash(id,get_user_cash(id) -Price)
  134.             return LuckyMenu(id);
  135.         }
  136.         case 1:
  137.         {
  138.             if ((Tickets[id] < 1) || Running[id]) return 1;
  139.             Tickets[id] --;
  140.             Running[id] = true;
  141.             CD[id] = 5;
  142.             StartLotto(id);
  143.             return LuckyMenu(id);
  144.         }
  145.         case 2:
  146.         {
  147.             if ((Tickets[id] < 1)) return 1;
  148.             Tickets[id] --;
  149.             set_user_cash(id, get_user_cash(id) + sellticket);
  150.             return LuckyMenu(id);
  151.         }
  152.         case 3:
  153.         {
  154.             if(get_user_cash(id) < Price*10) return 1;
  155.             Tickets[id] +=10;
  156.             set_user_cash(id,get_user_cash(id) -Price*10)
  157.             return LuckyMenu(id);
  158.         }
  159.         case 4:
  160.         {
  161.             if(get_user_cash(id) < Price*100) return 1;
  162.             Tickets[id] +=100;
  163.             set_user_cash(id,get_user_cash(id) -Price*100)
  164.             return LuckyMenu(id);
  165.         }
  166.         case 5:
  167.         {
  168.             if ((Tickets[id] < 1) || Running[id]) return 1;
  169.             Tickets[id] --;
  170.             Running[id] = true;
  171.             CD[id] = 0;
  172.             StartLotto(id);
  173.             return LuckyMenu(id);
  174.         }
  175.         case 6:
  176.         {
  177.             if ((Tickets[id] < 1) || Running[id]) return 1;
  178.             Running[id] = true;
  179.             CD[id] = 3;
  180.             u_All[id] = true;
  181.             StartLotto(id);
  182.             return LuckyMenu(id);          
  183.         }
  184.     }
  185.     return 1;
  186. }
  187. //Prize Chance
  188. public CheckPrize (id)
  189. {
  190.     new Number[33];
  191.     Number[id] = random_num(1,100)
  192.     if (Number[id] > 0 && Number[id] < 26)
  193.    
  194.         PrizeAmount[id] = random_num(0,500);
  195.     if (Number[id] > 25 && Number[id] < 46)
  196.    
  197.         PrizeAmount[id] = random_num(500,1000);
  198.     if (Number[id] > 45 && Number[id] < 66)
  199.    
  200.         PrizeAmount[id] = random_num(1000,3000);
  201.     if (Number[id] > 65 && Number[id] < 86)
  202.    
  203.         PrizeAmount[id] = random_num(3000,5000);
  204.     if (Number[id] > 80 && Number[id] < 91)
  205.    
  206.         PrizeAmount[id] = random_num(5000,15000);
  207.     if (Number[id] > 90 && Number[id] < 95)
  208.    
  209.         PrizeAmount[id] = random_num(15000,30000);
  210.     if(Number[id] > 94 && Number[id] < 99)
  211.    
  212.         PrizeAmount[id] = random_num(30000,50000);
  213.     if(Number[id] > 98 && Number[id] < 100)
  214.         PrizeAmount[id] = random_num(50000,150000);
  215.        
  216.     if(Number[id] == 100)
  217.     {
  218.         new Chance[33];
  219.         Chance[id] = random_num(1,4)
  220.         if (Chance[id] == 1)
  221.         {
  222.             PrizeAmount[id] = 500000;
  223.             client_cmd(0,"spk Top/JB/Bigwin.wav");
  224.         }
  225.         else
  226.             PrizeAmount[id] = random_num(50000,150000);
  227.  
  228.            
  229.     }
  230.     return PrizeAmount[id];
  231. }
  232. //Prize Messages
  233. public StartLotto(id)
  234. {
  235.     new t_Prize[33];
  236.     if(CD[id] < 1)
  237.     {
  238.         set_hudmessage(21, 157, 144, -1.0, 0.20, 1, 6.0, 15.0,_,_,4)
  239.         if (u_All[id])
  240.         {
  241.             new times[33];
  242.             for(new i; i < Tickets[id]; i++)
  243.             {
  244.                 CheckPrize(id);
  245.                 times[id] ++;
  246.                 t_Prize[id] += CheckPrize(id);
  247.                 continue;
  248.             }
  249.             Tickets[id] = 0;
  250.             if(times[id] > 1)
  251.                 ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^3Premium %s ^1has won ^3%d ^1cash from ^3%d ^4Lucky Tickets^1 ^1(%s%d Cash).",get_name(id),t_Prize[id],times[id],t_Prize[id]-(times[id]*Price) > 0 ? "+" : "" ,t_Prize[id]-(times[id]*Price));
  252.             else
  253.                 ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] You ^1have won ^3%d ^1cash from ^3%d ^4Lucky Tickets^1 ^1(%s%d Cash).",t_Prize[id],times[id],t_Prize[id]-(times[id]*Price) > 0 ? "+" : "",t_Prize[id]-(times[id]*Price));
  254.             u_All[id] = false;
  255.         }
  256.         else
  257.         {
  258.             CheckPrize(id);
  259.             show_hudmessage(id, "Congratulation, You won %d Cash!",PrizeAmount[id]);
  260.             if (PrizeAmount[id] > 49999 && !u_All[id])
  261.                 ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] %s ^1has won ^3%d ^1cash from the ^4Lucky Ticket^1.",get_name(id),PrizeAmount[id]);
  262.             if (PrizeAmount[id] < 49999 && !u_All[id])
  263.                 ColorChat(id,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] You ^1have won ^3%d ^1cash from the ^4Lucky Ticket^1.",PrizeAmount[id]);
  264.             t_Prize[id] = PrizeAmount[id];
  265.         }  
  266.         set_user_cash(id,get_user_cash(id)+t_Prize[id])
  267.         remove_task(id);
  268.         Running[id] = false;
  269.         return 1;
  270.     }
  271.     new szVox[10];
  272.     set_hudmessage(21, 157, 144, -1.0, 0.20, 1, 6.0, 3.0,_,_,4)
  273.     show_hudmessage(id, "You will get your prize amount in %d seconds",CD[id] );
  274.     num_to_word( CD[id], szVox, charsmax( szVox ) );
  275.     client_cmd( id, "spk ^"vox/%s^"", szVox );
  276.     CD[id]--;
  277.     set_task(1.0,"StartLotto",id);
  278.     return 1;
  279. }
  280. //Cmds Add/Set/Remove/Save Tickets
  281. public AddCmd(id)
  282. {
  283.     if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
  284.     new Args[128],aTarget[32],aTicket[32];
  285.     read_args(Args,charsmax(Args));
  286.     remove_quotes( Args );
  287.     parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
  288.     if( equali( aTarget, "" ) || equali( aTicket, "" ) )
  289.         return console_print(id,"Usage: amx_add_tickets <Nick> <Tickets>");
  290.     new iPlayer = cmd_target( iPlayer, aTarget,8);
  291.     if(!is_str_num(aTicket))
  292.         return console_print(id,"You need to fill numbers in the Tickets Amount");
  293.     if(!iPlayer)
  294.         return console_print(id,"The Player has not found");
  295.     new iTicket = str_to_num( aTicket );
  296.     if( iTicket < 1)
  297.         return console_print(id,"The Minimum of the value to add ticket is 1");
  298.     if( iTicket > 150)
  299.         return console_print(id,"The Maximum of the value to add ticket is 150");
  300.     Tickets[iPlayer] += iTicket;
  301.     ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3added ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
  302.     if (Tickets[iPlayer] > 150)
  303.         Tickets[iPlayer] = 150;
  304.     return 1;
  305. }
  306.  
  307. public RemoveCmd(id)
  308. {
  309.     if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
  310.     new Args[128],aTarget[32],aTicket[32];
  311.     read_args(Args,charsmax(Args));
  312.     remove_quotes( Args );
  313.     parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
  314.     if( equali( aTarget, "" ) || equali( aTicket, "" ) )
  315.         return console_print(id,"Usage: amx_remove_tickets <Nick> <Tickets>");
  316.     new iPlayer = cmd_target( iPlayer, aTarget,8);
  317.     if(!is_str_num(aTicket))
  318.         return console_print(id,"You need to fill numbers in the Tickets Amount");
  319.     if(!iPlayer)
  320.         return console_print(id,"The Player has not found");
  321.     new iTicket = str_to_num( aTicket );
  322.     if( iTicket < 1)
  323.         return console_print(id,"The Minimum of the value to remove ticket is 1");
  324.     if( iTicket > 150)
  325.         return console_print(id,"The Maximum of the value to remove ticket is 150");
  326.     Tickets[iPlayer] -= iTicket;
  327.     ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3removed ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
  328.     if (Tickets[iPlayer] < 0)
  329.         Tickets[iPlayer] = 0;
  330.     return 1;
  331. }
  332.  
  333. public SetCmd(id)
  334. {
  335.     if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
  336.     new Args[128],aTarget[32],aTicket[32];
  337.     read_args(Args,charsmax(Args));
  338.     remove_quotes( Args );
  339.     parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
  340.     if( equali( aTarget, "" ) || equali( aTicket, "" ) )
  341.         return console_print(id,"Usage: amx_set_tickets <Nick> <Tickets>");
  342.     new iPlayer = cmd_target( iPlayer, aTarget,8);
  343.     if(!is_str_num(aTicket))
  344.         return console_print(id,"You need to fill numbers in the Tickets Amount");
  345.     if(!iPlayer)
  346.         return console_print(id,"The Player has not found");
  347.     new iTicket = str_to_num( aTicket );
  348.     if( iTicket < 0)
  349.         return console_print(id,"The Minimum of the value to set ticket is 0");
  350.     if( iTicket > 150)
  351.         return console_print(id,"The Maximum of the value to set ticket is 150");
  352.     Tickets[iPlayer] = iTicket;
  353.     ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3setted ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
  354.     return 1;
  355. }
  356.  
  357. public ResetCmd(id)
  358. {
  359.     for (new i; i < get_maxplayers(); i++)
  360.     {
  361.         if(!is_user_connected(i)) continue;
  362.         Tickets[i] = 5;
  363.     }
  364.     ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3resetted ^4all online players ^1lucky tickets to^4 5",get_name(id));
  365.     return 1;
  366. }
  367. public CmdSave(id)
  368. {
  369.     new szData[ 100 ],szAuth[ 60 ];
  370.     formatex(szAuth,charsmax(szAuth),"%s",GetAuth(id))
  371.    
  372.     formatex( szData, charsmax( szData ), "%d", Tickets[ id ] );
  373.     fvault_set_data( szVault,szAuth, szData );
  374.    
  375.     return 1;
  376. }
  377. public CmdLoad(id)
  378. {
  379.     // cash
  380.     new sztData[ 100 ],szAuth[ 60 ];
  381.     formatex(szAuth,charsmax(szAuth),"%s",GetAuth(id))
  382.     // tickets
  383.     if( ! ( fvault_get_data( szVault, szAuth, sztData, charsmax( sztData ) ) ) )
  384.     {
  385.         fvault_set_data( szVault, szAuth, "2" );
  386.         Tickets[ id ] = 2;
  387.     }
  388.     else
  389.         Tickets[ id ] = str_to_num( sztData );
  390. }
  391. //Stocks
  392. stock get_name(index)
  393. {
  394.     new szName[32];
  395.     get_user_name(index,szName,charsmax(szName))
  396.     return szName;
  397. }
  398. stock GetAuth( id )
  399. {
  400.     static szAuth[ 60 ];
  401.     get_user_authid( id, szAuth, charsmax( szAuth ) );
  402.     if( contain( szAuth, "VALVE_" ) != -1 || contain( szAuth, "ID_LAN" ) != -1 )
  403.         get_user_ip( id, szAuth, charsmax( szAuth ), 1 );
  404.     return szAuth;
  405. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement