Queso
echo 'Web Developer';
- Nov 29, 2016
- 232
- 72
Hello DevBest, today I will be releasing a small addon which I made for my old hotel a couple months ago.
This script is basically just a system that allows a player to buy a crate which can contain items that have the value set to 1 in the database.
Basically just add the above code to the page you want the script at.
Finally, run this query.
P.S I do believe if you plan to use this script, the way I have it is it sends a gift to the user from your user, so you may have to send a gift to yourself and copy the extra_data and replace mine with yours so this script works properly, if you do need help, let me know.
Done.
If you have any questions or need help, PM me, and I can try to help you. Don't really care if you think this poorly coded or anything, I'm not a professional web developer, nor do I really know of ways this can be sql injected, so yeah. This was just something I wanted to have on my hotel.
This script is basically just a system that allows a player to buy a crate which can contain items that have the value set to 1 in the database.
Code:
<center>
<b>Loot Crates</b> are boxes that you can purchase, and they can contain various items, such as rares, diamonds, and even badges!<br>
Loot crates cost <b>50</b> diamonds!<br>
<img src="PLACEIMAGEHERE"><br>
<?php
$lootcrate = mysql_fetch_assoc(mysql_query("SELECT `vip_points`,`lootcrates_bought` FROM `users` WHERE `id` = '".$_SESSION['user']['id']."'"));
?>
<?php
$userstuff = mysql_query("SELECT * FROM `users` WHERE id='".$_SESSION['user']['id']."'");
$crate = mysql_query("SELECT id FROM furniture WHERE loot_crate = '1' ORDER BY RAND() LIMIT 1");
while ($selectcrate= mysql_fetch_array($crate)){
while ($onlineuser= mysql_fetch_array($userstuff)){
if ($onlineuser['online'] == 0){
if(isset($_POST['lootCrate'])){
if($lootcrate['vip_points'] >= 50){
$iDs = rand(0,9594553674);
mysql_query("INSERT INTO `crate_logs` (`username`, `userid`, `item_id`) VALUES ('".$_SESSION['user']['username']."', '".$_SESSION['user']['id']."', '".$selectcrate['id']."')");
mysql_query("INSERT INTO `items` (`id`, `user_id`, `base_item`, `extra_data`) VALUES ('".$iDs."', '".$_SESSION['user']['id']."', '920020', 'JoeThank you for purchasing a loot crate, double click to open!643246337249')");
mysql_query("UPDATE users SET `vip_points` = `vip_points` - 50 WHERE username = '".$_SESSION['user']['username']."' LIMIT 1");
mysql_query("INSERT INTO `user_presents` (`item_id`, `base_id`, `extra_data`) VALUES ('".$iDs."', '".$selectcrate['id']."', '0')");
mysql_query("UPDATE `users` SET `lootcrates_bought` = `lootcrates_bought` +1 WHERE username = '".$_SESSION['user']['username']."' LIMIT 1");
echo "You bought a <b>loot crate</b>, check your inventory to open your crate!<br>";
}
else{
echo "You do not have 50 diamonds to redeem for a Loot Crate!<br>";
}
}
}
else{
echo "You must log out of the client!<br>";
}
}
}
?><br>
<form method="post">
<input type="submit" name="lootCrate" value="Buy a Loot Crate">
</form>
</center>
</ul>
Finally, run this query.
Code:
ALTER TABLE furniture ADD loot_crate enum('1','0')DEFAULT '0';
Done.
If you have any questions or need help, PM me, and I can try to help you. Don't really care if you think this poorly coded or anything, I'm not a professional web developer, nor do I really know of ways this can be sql injected, so yeah. This was just something I wanted to have on my hotel.