Advertisement
TheMasterGeneral

Auto-lucky boxes

Mar 31st, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. <?php
  2. /*
  3. Auto Lucky Boxes
  4. TheMasterGeneral
  5. Donator item?
  6. File: /autohex.php
  7.  
  8. Watched be made by: Jacko
  9.  
  10. El SQL:
  11. ALTER TABLE `users` ADD `autobor` INT(11) NOT NULL DEFAULT '0' ;
  12. */
  13. require_once('globals.php');
  14.  
  15.  
  16. //Test for if any autohexbags are redeemed.
  17. if ($ir['autobor'] <= 0)
  18. {
  19. die("You don't have any auto-box of random openers redeemed on your account.");
  20. }
  21. if ($ir['bor'] <= 0)
  22. {
  23. die("You have already opened all your box of random for today. Come back tomorrow, cheapskate.");
  24. }
  25. //No amount specified? NO PROBLEM!
  26. if(!isset($_POST['amount'])) {
  27. print "<form action='autobor.php' method='post'>
  28. Automagically open all your box of random!! How amazing is that?! Enter the amount you wish to open here. <b>You currently have {$ir['autobor']} Auto-Box of Random redeemed on your account</b> <br />
  29. <input type='text' name='amount' placeholder='Enter a valid amount to open' value='2000' />
  30. <input type='submit' value='Open' />
  31. </form>";
  32. }
  33. else //If amount is specified, run this!
  34. {
  35. //Secure the ID input.
  36. $_POST['amount'] = abs((int) $_POST['amount']);
  37. $gid = 16;
  38. $query=$db->query("SELECT `inv_itemid`, `inv_qty` FROM `inventory` where `inv_itemid` = $gid && `inv_userid` = $userid");
  39. $i=mysqli_fetch_array($query);
  40. if(!$i['inv_itemid'] == 16)
  41. {
  42. print "You're either out of boxes to open, or never had any in the first place.";
  43. exit;
  44. }
  45. if($i['inv_qty'] < $_POST['amount'])
  46. {
  47. die('You specified an amount that you do not have in your inventory.');
  48.  
  49. }
  50. if (!$_POST['amount'])
  51. {
  52. echo "Invalid use of file";
  53. }
  54. if ($_POST['amount'] > $ir['bor'])
  55. {
  56. die('Not enough Box of Random avaliable to you.');
  57. }
  58. if ($_POST['amount'] > $ir['autobor'])
  59. {
  60. die('Not enough auto-box of random on your account for the amount you specified.');
  61. }
  62. $hexleft=($_POST['amount']);
  63. while ($hexleft > 0)
  64. {
  65. $db->query(
  66. "UPDATE `users`
  67. SET `bor` = `bor` - 1,
  68. `autobor` = `autobor` - 1
  69. WHERE `userid` = $userid");
  70. $hexleft=($hexleft-1);
  71. $chance = rand(1,115);
  72. if ($chance <= 10)
  73. {
  74. $tokens = rand(10, 50);
  75. echo "You open this box of random and find some silver coins in it! (gained {$tokens} Silver Coins)<br />";
  76. $db->query(
  77. "UPDATE `users`
  78. SET `crystals` = `crystals` + {$tokens}
  79. WHERE `userid` = {$userid}");
  80. }
  81. if (($chance >= 11) && ($chance <= 25))
  82. {
  83. $money = rand(1000, 10000);
  84. echo "Looks like there is some copper coins in this box of random (gained " . ($money) . " Copper Coins)<br />";
  85. $db->query(
  86. "UPDATE `users`
  87. SET `money` = `money` + {$money}
  88. WHERE `userid` = {$userid}");
  89. }
  90. if (($chance >= 26) && ($chance <= 35))
  91. {
  92. $gc = rand(5, 20);
  93. echo "Looks like there is some gold coins in this box of random (gained " . ($gc) . " Gold Coins)<br />";
  94. $db->query(
  95. "UPDATE `users`
  96. SET `goldcoin` = `goldcoin` + {$gc}
  97. WHERE `userid` = {$userid}");
  98. }
  99. if (($chance >= 36) && ($chance <= 37))
  100. {
  101. echo "The item in this box was warm and squishy. You decide to keep it in there.<br />";
  102. }
  103. if (($chance >= 38) && ($chance <= 40))
  104. {
  105. echo "This box of random was empty";
  106. }
  107.  
  108. if (($chance >= 41) && ($chance <= 50))
  109. {
  110. $borid = 12; //Box of Random ID
  111. echo "This box contains a Crate of Blasting Jelly.<br />";
  112. item_add($userid, $borid, 1);
  113. }
  114. if (($chance >= 51) && ($chance <= 55))
  115. {
  116. echo "This box contains a Chivalry Gym Pass. Congratz!!<br />";
  117. item_add($userid, 15, 1);
  118. }
  119. if (($chance >= 56) && ($chance <= 60))
  120. {
  121. echo "This box contains a piece of yummy cooked meat.<br />";
  122. item_add($userid, 35, 1);
  123. }
  124. if (($chance >= 61) && ($chance <= 65))
  125. {
  126. echo "This box contains a piece of yummy cooked venison.<br />";
  127. item_add($userid, 36, 1);
  128. }
  129.  
  130. if (($chance >= 66) && ($chance <= 75))
  131. {
  132. $bamount=rand(1,5);
  133. echo "This box contains {$bamount} Bandages.<br />";
  134. item_add($userid, 28, $bamount);
  135. }
  136. if (($chance >= 76) && ($chance <= 85))
  137. {
  138. $kamount=rand(1,4);
  139. echo "This box contains {$kamount} Cell Key(s)<br />";
  140. item_add($userid, 27, $kamount);
  141. }
  142. if (($chance >= 86) && ($chance <= 90))
  143. {
  144. $samount=rand(1,7);
  145. echo "This box contains {$samount} Stick(s).<br />";
  146. item_add($userid, 6, $samount);
  147. }
  148. if (($chance >= 91) && ($chance <= 95))
  149. {
  150. $ramount=rand(1,3);
  151. echo "This is quite the heavy box. Oh, that makes sense. It had {$ramount} Rock(s) in it.<br />";
  152. item_add($userid, 7, $ramount);
  153. }
  154. if (($chance >= 96) && ($chance <= 100))
  155. {
  156. $gc = rand(2, 15);
  157. echo "This box contained {$gc} Gold Coins.<br />";
  158. $db->query(
  159. "UPDATE `users`
  160. SET `goldcoin` = `goldcoin` + {$gc}
  161. WHERE `userid` = {$userid}");
  162. }
  163. if (($chance >= 101) && ($chance <= 102))
  164. {
  165. echo "This Box of Random had nothing in it.";
  166. }
  167. if (($chance >= 103) && ($chance <= 105))
  168. {
  169. $extrahex= rand(2,3);
  170. echo "This Box of Random contained a voucher for {$extrahex} extra Hex Bags uses! Congratulations!<br />";
  171. $db->query(
  172. "UPDATE `users`
  173. SET `boxes_opened` = `boxes_opened` + {$extrahex}
  174. WHERE `userid` = {$userid}");
  175. }
  176. if (($chance >= 106) && ($chance <= 115))
  177. {
  178. $hosptime=(int) rand(15,30);
  179. echo "Tick, tock... boom<br />";
  180. $reasonhosp = 'Ticking Box';
  181. $db->query("UPDATE users SET hospital=`hospital` + $hosptime WHERE userid=$userid",$c);
  182. $db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$userid",$c);
  183. }
  184. item_remove($userid, $gid, 1);
  185. }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement