These games were converted over from GRPG v1 for MCCodes v2 I have added some things to it from the original code like a way to remove bets
Start by running these SQL queries
--
-- Table structure for table `5050game`
--
CREATE TABLE `5050game` (
`id` int(11) NOT NULL,
`owner` int(11) NOT NULL DEFAULT '0',
`amount` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `5050game2`
--
CREATE TABLE `5050game2` (
`id` int(11) NOT NULL,
`owner` int(11) NOT NULL DEFAULT '0',
`amount` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Indexes for table `5050game`
--
ALTER TABLE `5050game`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `5050game2`
--
ALTER TABLE `5050game2`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for table `5050game`
--
ALTER TABLE `5050game`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `5050game2`
--
ALTER TABLE `5050game2`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
After you've ran the SQL queries create a file called 5050.php and add this code
<?php
include "globals.php";
$get = $db->query("SELECT * FROM 5050game");
if (array_key_exists('makebet', $_POST)) {
if($ir['money'] < $_POST['amount']) {
echo" You do not have enough cash to place that bet ";
$h->endpage();
exit;
}
if(!$_POST['amount']) {
echo" You did not place a valid bet ";
$h->endpage();
exit;
}
if($_POST['amount'] < 1000) {
echo" $1,000 is the miniumum bet for 50/50. ";
$h->endpage();
exit;
}
echo"You placed a bet for ".money_formatter($_POST['amount']).". Good Luck! ";
$db->query("UPDATE users SET money = GREATEST(money - {$_POST['amount']}, 0) WHERE userid=".$ir['userid']);
$db->query("INSERT INTO 5050game VALUES('',{$ir['userid']},{$_POST['amount']})");
}
if (array_key_exists('takebet', $_GET)) {
$_GET['id'] = array_key_exists('id', $_GET) && ctype_digit($_GET['id']) && $_GET['id'] > 0 ? $_GET['id'] : null;
$betget = $db->query("SELECT * FROM 5050game WHERE id=".$_GET['id']);
$betgot = $db->fetch_row($betget);
if(!$_GET['id']) {
echo" This bet does not exist or was already taken ";
$h->endpage();
exit;
}
if($ir['money'] < $betgot['amount']) {
echo" You do not have enough money for this bet. ";
$h->endpage();
exit;
}
if($ir['userid'] == $betgot['owner']) {
echo" What would be the point of taking your own bet. ";
$h->endpage();
exit;
}
$winner = mt_rand(0,1);
if($winner == 1) {
$outcome = "won";
}
if($winner == 0) {
$outcome = "lost";
}
if($winner == 1) {
event_add($betgot['owner'],"Someone took your bet and you lost.");
$db->query("UPDATE users SET money = money + {$betgot['amount']} WHERE userid=".$ir['userid']);
}
else {
event_add($betgot['owner'],"Someone took your bet and you won.");
$db->query("UPDATE users SET money = money + {$betgot['amount']} WHERE userid=".$betgot['owner']);
}
$db->query("DELETE FROM 5050game WHERE id = ".$_GET['id']);
echo" You took a bet for ".money_formatter($betgot['amount'])." and {$outcome}! ";
}
if (array_key_exists('removebet', $_GET)) {
$_GET['id'] = array_key_exists('id', $_GET) && ctype_digit($_GET['id']) && $_GET['id'] > 0 ? $_GET['id'] : null;
$betget = $db->query("SELECT * FROM 5050game WHERE id=".$_GET['id']);
$betgot = $db->fetch_row($betget);
if(!$_GET['id']) {
echo" This bet does not exist or was already taken ";
$h->endpage();
exit;
}
if($ir['userid'] != $betgot['owner']) {
echo" You cannot remove anything but your own bet. ";
$h->endpage();
exit;
}
$db->query("UPDATE users SET money = money + {$betgot['amount']} WHERE userid = ".$betgot['owner']);
$db->query("DELETE FROM 5050game WHERE id = ".$_GET['id']);
echo" You removed your bet for ".money_formatter($betgot['amount'])."! ";
}
?>
<div class='generalinfo_txt'>
<div><img src='images/info_left.jpg' alt='' /></div>
<div class='info_mid'><h2 style='padding-top:10px;'> 50/50 Money</h2></div>
<div><img src='images/info_right.jpg' alt='' /></div> </div>
<div class='generalinfo_simple'><br> <br><br>
<table class='table' width='100%'>
<tr>
<td>
This game is simple.<br> 2 people bet the same amount of money, then a winner is randomly picked.<br> The winner recieves all of the money!
</td>
</tr>
<tr>
<td >
<form action="5050.php" method="post">
<fieldset>
<div>
<label for="amount">Amount of money to bid (minimum of <?php echo money_formatter(1000); ?> bet)</label>
$<input type="text" name="amount" id="amount" size="10" maxlength="20" value="<?php echo $ir['money']; ?>" />
</div>
</fieldset>
<div >
<br><button type="submit" name="makebet">Make Bet</button><br>
</div>
</form>
</td>
</tr>
</table>
<br><hr><br>
<table class='table' width='100%'>
<tr>
<th colspan="3">Current Bets</th>
</tr>
<?php
while($got = $db->fetch_row($get)) {
$got['owner'] = $db->fetch_single($db->query("SELECT username FROM users WHERE userid=".$got['owner'])); ?>
<tr>
<th>Owner</th>
<th>Amount</th>
<th>Action</th>
</tr>
<tr>
<td><?php echo $got['owner'] ?></td>
<td><?php echo money_formatter($got['amount']) ?></td>
<td><a href="5050.php?takebet&id=<?php echo $got['id'] ?>">Take Bet</a><br><?php if($ir['username'] == $got['owner']) { ?>
<a href="5050.php?removebet&id=<?php echo $got['id'] ?>">Remove Bet <?php } ?></td>
</tr>
<?php } ?>
</table>
Create a file called 5050coin.php
<?php
include "globals.php";
$get = $db->query("SELECT * FROM 5050game2");
if (array_key_exists('makebet', $_POST)) {
if($ir['crystals'] < $_POST['amount']) {
echo" You do not have enough coins to place that bet ";
$h->endpage();
exit;
}
if(!$_POST['amount']) {
echo" You did not place a valid bet ";
$h->endpage();
exit;
}
if($_POST['amount'] < 10) {
echo" 10 is the miniumum bet for 50/50 coins. ";
$h->endpage();
exit;
}
echo"You placed a bet for ".number_format($_POST['amount'])." coins. Good Luck! ";
$db->query("UPDATE users SET crystals = GREATEST(crystals - {$_POST['amount']}, 0) WHERE userid=".$ir['userid']);
$db->query("INSERT INTO 5050game2 VALUES('',{$ir['userid']},{$_POST['amount']})");
}
if (array_key_exists('takebet', $_GET)) {
$_GET['id'] = array_key_exists('id', $_GET) && ctype_digit($_GET['id']) && $_GET['id'] > 0 ? $_GET['id'] : null;
$betget = $db->query("SELECT * FROM 5050game2 WHERE id=".$_GET['id']);
$betgot = $db->fetch_row($betget);
if(!$betgot['id']) {
echo" This bet does not exist or was already taken ";
$h->endpage();
exit;
}
if($ir['crystals'] < $betgot['amount']) {
echo" You do not have enough coins for this bet. ";
$h->endpage();
exit;
}
if($ir['userid'] == $betgot['owner']) {
echo" What would be the point of taking your own bet. ";
$h->endpage();
exit;
}
$winner = mt_rand(0,1);
if($winner == 1) {
$outcome = "won";
}
if($winner == 0) {
$outcome = "lost";
}
if($winner == 1) {
event_add($betgot['owner'],"Someone took your coin bet and you lost.");
$db->query("UPDATE users SET crystals = crystals + ({$betgot['amount']} * 2) WHERE userid=".$ir['userid']);
}
else {
event_add($betgot['owner'],"Someone took your coin bet and you won.");
$db->query("UPDATE users SET crystals = crystals + ({$betgot['amount']} * 2) WHERE userid=".$betgot['owner']);
$db->query("UPDATE users SET crystals = crystals - GREATEST({$betgot['amount']} * 2, 0) WHERE userid=".$ir['userid']);
}
$db->query("DELETE FROM 5050game2 WHERE id = ".$_GET['id']);
echo" You took a bet for ".number_format($betgot['amount'])." coins and {$outcome}! ";
}
if (array_key_exists('removebet', $_GET)) {
$_GET['id'] = array_key_exists('id', $_GET) && ctype_digit($_GET['id']) && $_GET['id'] > 0 ? $_GET['id'] : null;
$betget = $db->query("SELECT * FROM 5050game2 WHERE id=".$_GET['id']);
$betgot = $db->fetch_row($betget);
if(!$_GET['id']) {
echo" This bet does not exist or was already taken ";
$h->endpage();
exit;
}
if($ir['userid'] != $betgot['owner']) {
echo" You cannot remove anything but your own bet. ";
$h->endpage();
exit;
}
$db->query("UPDATE users SET crystals = crystals + {$betgot['amount']} WHERE userid = ".$betgot['owner']);
$db->query("DELETE FROM 5050game2 WHERE id = ".$_GET['id']);
echo" You removed your bet for ".number_format($betgot['amount'])." coins! ";
}
?>
<div class='generalinfo_txt'>
<div><img src='images/info_left.jpg' alt='' /></div>
<div class='info_mid'><h2 style='padding-top:10px;'> 50/50 Coins</h2></div>
<div><img src='images/info_right.jpg' alt='' /></div> </div>
<div class='generalinfo_simple'><br> <br><br>
<table class='table' width='100%'>
<tr>
<td>
This game is simple.<br> 2 people bet the same amount of coins, then a winner is randomly picked.<br> The winner recieves all of the coins!
</td>
</tr>
<tr>
<td >
<form action="5050coin.php" method="post">
<fieldset>
<div>
<label for="amount">Amount of coins to bid (minimum of <?php echo number_format(10); ?> bet)</label>
<input type="text" name="amount" id="amount" size="10" maxlength="20" value="<?php echo $ir['crystals']; ?>" />
</div>
</fieldset>
<div >
<br><button type="submit" name="makebet">Make Bet</button><br>
</div>
</form>
</td>
</tr>
</table>
<br><hr><br>
<table class='table' width='100%'>
<tr>
<th colspan="3">Current Bets</th>
</tr>
<?php
while($got = $db->fetch_row($get)) {
$got['owner'] = $db->fetch_single($db->query("SELECT username FROM users WHERE userid=".$got['owner'])); ?>
<tr>
<th>Owner</th>
<th>Amount</th>
<th>Action</th>
</tr>
<tr>
<td><?php echo $got['owner'] ?></td>
<td><?php echo number_format($got['amount']) ?> Coins</td>
<td><a href="5050coin.php?takebet&id=<?php echo $got['id'] ?>">Take Bet</a><?php if($ir['username'] == $got['owner']) { ?>
<a href="5050coin.php?removebet&id=<?php echo $got['id'] ?>">Remove Bet <?php } ?></td>
</tr>
<?php } ?>
</table>
And that's it, features minimum bet, way to remove bet.
Need any assistance just shoot me a message I'd be happy to help