Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Auto Lucky Boxes
- TheMasterGeneral
- Donator item?
- File: /autohex.php
- Watched be made by: Jacko
- El SQL:
- ALTER TABLE `users` ADD `autobor` INT(11) NOT NULL DEFAULT '0' ;
- */
- require_once('globals.php');
- //Test for if any autohexbags are redeemed.
- if ($ir['autobor'] <= 0)
- {
- die("You don't have any auto-box of random openers redeemed on your account.");
- }
- if ($ir['bor'] <= 0)
- {
- die("You have already opened all your box of random for today. Come back tomorrow, cheapskate.");
- }
- //No amount specified? NO PROBLEM!
- if(!isset($_POST['amount'])) {
- print "<form action='autobor.php' method='post'>
- 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 />
- <input type='text' name='amount' placeholder='Enter a valid amount to open' value='2000' />
- <input type='submit' value='Open' />
- </form>";
- }
- else //If amount is specified, run this!
- {
- //Secure the ID input.
- $_POST['amount'] = abs((int) $_POST['amount']);
- $gid = 16;
- $query=$db->query("SELECT `inv_itemid`, `inv_qty` FROM `inventory` where `inv_itemid` = $gid && `inv_userid` = $userid");
- $i=mysqli_fetch_array($query);
- if(!$i['inv_itemid'] == 16)
- {
- print "You're either out of boxes to open, or never had any in the first place.";
- exit;
- }
- if($i['inv_qty'] < $_POST['amount'])
- {
- die('You specified an amount that you do not have in your inventory.');
- }
- if (!$_POST['amount'])
- {
- echo "Invalid use of file";
- }
- if ($_POST['amount'] > $ir['bor'])
- {
- die('Not enough Box of Random avaliable to you.');
- }
- if ($_POST['amount'] > $ir['autobor'])
- {
- die('Not enough auto-box of random on your account for the amount you specified.');
- }
- $hexleft=($_POST['amount']);
- while ($hexleft > 0)
- {
- $db->query(
- "UPDATE `users`
- SET `bor` = `bor` - 1,
- `autobor` = `autobor` - 1
- WHERE `userid` = $userid");
- $hexleft=($hexleft-1);
- $chance = rand(1,115);
- if ($chance <= 10)
- {
- $tokens = rand(10, 50);
- echo "You open this box of random and find some silver coins in it! (gained {$tokens} Silver Coins)<br />";
- $db->query(
- "UPDATE `users`
- SET `crystals` = `crystals` + {$tokens}
- WHERE `userid` = {$userid}");
- }
- if (($chance >= 11) && ($chance <= 25))
- {
- $money = rand(1000, 10000);
- echo "Looks like there is some copper coins in this box of random (gained " . ($money) . " Copper Coins)<br />";
- $db->query(
- "UPDATE `users`
- SET `money` = `money` + {$money}
- WHERE `userid` = {$userid}");
- }
- if (($chance >= 26) && ($chance <= 35))
- {
- $gc = rand(5, 20);
- echo "Looks like there is some gold coins in this box of random (gained " . ($gc) . " Gold Coins)<br />";
- $db->query(
- "UPDATE `users`
- SET `goldcoin` = `goldcoin` + {$gc}
- WHERE `userid` = {$userid}");
- }
- if (($chance >= 36) && ($chance <= 37))
- {
- echo "The item in this box was warm and squishy. You decide to keep it in there.<br />";
- }
- if (($chance >= 38) && ($chance <= 40))
- {
- echo "This box of random was empty";
- }
- if (($chance >= 41) && ($chance <= 50))
- {
- $borid = 12; //Box of Random ID
- echo "This box contains a Crate of Blasting Jelly.<br />";
- item_add($userid, $borid, 1);
- }
- if (($chance >= 51) && ($chance <= 55))
- {
- echo "This box contains a Chivalry Gym Pass. Congratz!!<br />";
- item_add($userid, 15, 1);
- }
- if (($chance >= 56) && ($chance <= 60))
- {
- echo "This box contains a piece of yummy cooked meat.<br />";
- item_add($userid, 35, 1);
- }
- if (($chance >= 61) && ($chance <= 65))
- {
- echo "This box contains a piece of yummy cooked venison.<br />";
- item_add($userid, 36, 1);
- }
- if (($chance >= 66) && ($chance <= 75))
- {
- $bamount=rand(1,5);
- echo "This box contains {$bamount} Bandages.<br />";
- item_add($userid, 28, $bamount);
- }
- if (($chance >= 76) && ($chance <= 85))
- {
- $kamount=rand(1,4);
- echo "This box contains {$kamount} Cell Key(s)<br />";
- item_add($userid, 27, $kamount);
- }
- if (($chance >= 86) && ($chance <= 90))
- {
- $samount=rand(1,7);
- echo "This box contains {$samount} Stick(s).<br />";
- item_add($userid, 6, $samount);
- }
- if (($chance >= 91) && ($chance <= 95))
- {
- $ramount=rand(1,3);
- echo "This is quite the heavy box. Oh, that makes sense. It had {$ramount} Rock(s) in it.<br />";
- item_add($userid, 7, $ramount);
- }
- if (($chance >= 96) && ($chance <= 100))
- {
- $gc = rand(2, 15);
- echo "This box contained {$gc} Gold Coins.<br />";
- $db->query(
- "UPDATE `users`
- SET `goldcoin` = `goldcoin` + {$gc}
- WHERE `userid` = {$userid}");
- }
- if (($chance >= 101) && ($chance <= 102))
- {
- echo "This Box of Random had nothing in it.";
- }
- if (($chance >= 103) && ($chance <= 105))
- {
- $extrahex= rand(2,3);
- echo "This Box of Random contained a voucher for {$extrahex} extra Hex Bags uses! Congratulations!<br />";
- $db->query(
- "UPDATE `users`
- SET `boxes_opened` = `boxes_opened` + {$extrahex}
- WHERE `userid` = {$userid}");
- }
- if (($chance >= 106) && ($chance <= 115))
- {
- $hosptime=(int) rand(15,30);
- echo "Tick, tock... boom<br />";
- $reasonhosp = 'Ticking Box';
- $db->query("UPDATE users SET hospital=`hospital` + $hosptime WHERE userid=$userid",$c);
- $db->query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$userid",$c);
- }
- item_remove($userid, $gid, 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement