Jump to content
MakeWebGames

Recommended Posts

Posted
I'd also make it so they'd have to buy it, but the client gets what the client wants ;)

"You must spread some Reputation around before giving it to Magictallguy again"

I like seeing posts like this. Not sure what else to say so... thanks for helping out a member. :)

Posted
"You must spread some Reputation around before giving it to Magictallguy again"

I like seeing posts like this. Not sure what else to say so... thanks for helping out a member. :)

I second this ( also must spread rep around ).

It's good to see this kind of thing again, it's been a while.

Posted
I second this ( also must spread rep around ).

It's good to see this kind of thing again, it's been a while.

The forums are hopefully on the way up again hopefully, keep it up Magic + rep :)

Posted (edited)

cardealer.php

<?php
include(__DIR__ . '/globals.php');
echo "<!-- Created by Magictallguy -->";
$_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;
$_GET['ID'] = isset($_GET['ID']) && ctype_digit($_GET['ID']) ? abs(@intval($_GET['ID'])) : null;
switch($_GET['action']) {
case 'buy': buyCar(); break;

default: carIndex(); break;
}

function error($msg) {
global $h;
echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>";
$h->endpage();
exit;
}

function success($msg) {
echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>";
}

function format($str, $dec = 0) {
return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str));
}

function carIndex() {
global $db, $ir;
echo "<h3>Cars: Car Dealership</h3>";
$selectGarage = $db->query(sprintf("SELECT `pgID` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	echo "<a href='garage.php'>Buy your own driveway</a>";
}
?><table class='table' width='100%' cellspacing='1'>
	<tr>
		<th width='25%'>Car/Description</th>
		<th width='20%'>Cost</th>
		<th width='50%'>Stats</th>
		<th width='5%'>Links</th>
	</tr><?
$select = $db->query("SELECT * FROM `cars` ORDER BY `cCost` ASC, `cName` ASC");
if(!$db->num_rows($select)) {
	echo "<tr><td colspan='3' class='center'>There are no available cars</td></tr>";
} else {
	while($row = $db->fetch_row($select)) {
		?><tr>
			<td><strong><? echo format($row['cName']); ?></strong><? echo nl2br(format($row['cDesc'])); ?></td>
			<td>$<? echo format($row['cCost']); ?></td>
			<td><table class='table' width='100%' cellspacing='1'>
				<tr>
					<th width='10%'>Speed</th>
					<td width='40%'><? echo format($row['cSpeed']); ?></td>
					<th width='10%'>Handling</th>
					<td width='40%'><? echo format($row['cHandling']); ?></td>
				</tr>
				<tr>
					<th width='10%'>Acceleration</th>
					<td width='40%'><? echo format($row['cAccel']); ?></td>
					<th width='10%'>Braking</th>
					<td width='40%'><? echo format($row['cBrake']); ?></td>
				</tr>
			</table></td>
			<td><? echo ($ir['money'] >= $row['cCost']) ? "<a href='cardealer.php?action=buy&ID=".$row['cID']."'>Buy</a>" : "<span style='color:#444;'><em>Buy</em></span>"; ?></td>
		</tr><?
	}
}
echo "</table>";
}

function buyCar() {
global $db, $ir;
echo "<h3>Cars: Car Dealership: Buying a car</h3>";
if(empty($_GET['ID'])) {
	error("You didn't select a valid car");
}
$selectCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $_GET['ID']));
if(!$db->num_rows($selectCar)) {
	error("That car doesn't exist");
}
$row = $db->fetch_row($selectCar);

$selectGarage = $db->query(sprintf("SELECT `pgCapacity`, `pgType` FROM `playerGarages` WHERE (`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	error("You don't have anywhere to park your car. You must buy a driveway before you can buy a car");
}
$garage = $db->fetch_row($selectGarage);
$selectPlayerCars = $db->query(sprintf("SELECT COUNT(`pcID`) FROM `playerCars` WHERE (`pcUser` = %u)", $ir['userid']));
$getGarageName = $db->query(sprintf("SELECT `gTypeName` FROM `garageTypes` WHERE (`gTypeID` = %u)", $garage['pgType']));
$garageName = $db->fetch_single($getGarageName);
if($db->fetch_single($selectPlayerCars) >= $garage['pgCapacity']) {
	error("Your ".format($garageName)." is full. You must upgrade it before you can fit any more cars");
}

if($ir['money'] < $row['cCost']) {
	error("You don't have enough money to buy the ".format($row['cName']));
}
$db->query(sprintf("INSERT INTO `playerCars` VALUES ('', %u, %u, %u, %u, %u, %u)", $ir['userid'], $_GET['ID'], $row['cSpeed'], $row['cHandling'], $row['cAccel'], $row['cBrake']));
success("You've bought the ".format($row['cName']));
}

$h->endpage();
?>

 

Bloody hell your quick - I've always said it but this is ridiculous! xD

I'm slowing down due to family getting in the way lol

Edited by Magictallguy
Added quote, bug fixes
Posted
^^^^ Calls this slow! xD

Indeed, considering the family are now demanding time with me preventing me from doing what I want to .. again xD

I'll finish up tomorrow.

Coming soon:

  • Garage Types (staff side)
  • Upgrade Garage
  • Upgrade Car
  • Sell Car
  • Races
    • Fun
    • Bet
    • Pinks

     

  • Like 1
Posted
"You must spread some Reputation around before giving it to Magictallguy again"

I like seeing posts like this. Not sure what else to say so... thanks for helping out a member. :)

 

I second this ( also must spread rep around ).

It's good to see this kind of thing again, it's been a while.

Rep given with comment On Behalf of DJK and Dom

  • Like 1
Posted
"You must spread some Reputation around before giving it to Magictallguy again"

I like seeing posts like this. Not sure what else to say so... thanks for helping out a member. :)

 

I second this ( also must spread rep around ).

It's good to see this kind of thing again, it's been a while.

Anybody know the way that works? How many before you can hit someone else with one again?

 

Bollocks. -2short-
Posted

Thanks for the work so far MTG! Ill test it all out tomorrow when ill have free time. Will deffinatly offer you some finances for this when its done for doing such a great job :).

Posted (edited)

garage.php

<?php
include(__DIR__ . '/globals.php');
echo "<!-- Created by Magictallguy -->";
$_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;
switch($_GET['action']) {
case 'buy': buyGarage(); break;
case 'upgradegarage': upgradeGarage(); break;
case 'upgrade': upgradeCar(); break;
case 'sell': sellCar(); break;

default: carIndex(); break;
}

function error($msg) {
global $h;
echo "<div style='color: #D8000C;background-color: #FFBABA;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>ERROR!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>";
$h->endpage();
exit;
}

function success($msg) {
   echo "<div style='color: #4F8A10;background-color: #DFF2BF;border: 1px solid;background-repeat: no-repeat;background-position: 10px center;width: 40%;border-radius: 15px;margin: 10px 0;padding: 15px 10px 15px 50px;'><strong>Success!</strong><br />",$msg,"<br /><a onclick='window.history.go(-1);' style='cursor:pointer;'>Back</a> · <a href='index' style='color:black;'>Home</a></div>";
}

function format($str, $dec = 0) {
   return ctype_digit($str) ? number_format($str, $dec) : stripslashes(htmlspecialchars($str));
}

function carIndex() {
global $db, $ir;
$selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " .
									"FROM `playerGarages` AS `pg` " .
									"LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " .
									"WHERE (`pg`.`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	header("Location: garage.php?action=buy");
	exit;
}
$garage = $db->fetch_row($selectGarage);
$selectCars = $db->query(sprintf("SELECT `pc`.*, `c`.`cName`, `c`.`cDesc` " .
									"FROM `playerCars` AS `pc` " .
									"LEFT JOIN `cars` AS `c` ON (`c`.`cID` = `pc`.`pcCarID`) " .
									"WHERE (`pc`.`pcUser` = %u) " .
									"ORDER BY `c`.`cName` ASC", $ir['userid']));
?><h3>Cars: Your <? echo format($garage['gTypeName']); ?></h3>
<a href='garage.php?action=upgradegarage'>Upgrade your <? echo format($garage['gTypeName']); ?></a><br />
You have <? echo format($db->num_rows($selectCars)),'/',format($garage['pgCapacity']); ?> cars<br />
<table class='table' width='100%' cellspacing='1'>
	<tr>
		<th width='45%'>Car/Description</th>
		<th width='45%'>Stats</th>
		<th width='10%'>Links</th>
	</tr><?
if(!$db->num_rows($selectCars)) {
	echo "<tr><td colspan='3' class='center'>You don't have any cars<br /><a href='cardealer.php'>Go buy one</a></td></tr>";
} else {
	while($car = $db->fetch_row($selectCars)) {
		?><tr>
			<td><? echo format($car['cName']); ?><br /><br /><? echo nl2br(format($car['cDesc'])); ?></td>
			<td><table class='table' width='100%' cellspacing='1'>
				<tr>
					<th width='20%'>Speed</th>
					<td width='30%'><? echo format($car['pcSpeed']); ?></td>
					<th width='20%'>Handling</th>
					<td width='30%'><? echo format($car['pcHandling']); ?></td>
				</tr>
				<tr>
					<th width='20%'>Acceleration</th>
					<td width='30%'><? echo format($car['pcAccel']); ?></td>
					<th width='20%'>Braking</th>
					<td width='30%'><? echo format($car['pcBrake']); ?></td>
				</tr>
			</table></td>
			<td><a href='garage.php?action=upgrade&ID=<? echo $car['pcID']; ?>'>Upgrade</a> · <a href='garage.php?action=sell&ID=<? echo $car['pcID']; ?>'>Sell</a><br /><a href='carrace.php?ID=<? echo $car['pcID']; ?>'>Race</a></td>
		</tr><?
	}
}
echo "</table>";
}

function upgradeCar() {
global $db, $ir;
$selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " .
									"FROM `playerGarages` AS `pg` " .
									"LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " .
									"WHERE (`pg`.`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	header("Location: garage.php?action=buy");
	exit;
}
$garage = $db->fetch_row($selectGarage);
if(empty($_GET['ID'])) {
	error("You didn't select a valid car");
}
$selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID` = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid']));
if(!$db->num_rows($selectMyCar)) {
	error("You don't own that car");
}
$myCar = $db->fetch_row($selectMyCar);

$selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID']));
if(!$db->num_rows($selectStandardCar)) {
	error("That car doesn't exist - message a staff member to inform them about this");
}
$car = $db->fetch_row($selectStandardCar);
?><h3>Cars: Upgrading your <? echo format($car['cName']); ?></h3><?
$tuneArray = array('speed', 'handling', 'accel', 'brake');
$_GET['tune'] = isset($_GET['tune']) && ctype_alpha($_GET['tune']) && in_array($_GET['tune'], $tuneArray) ? strtolower(trim($_GET['tune'])) : null;
if(empty($_GET['tune'])) {
	?><table class='table' width='75%' cellspacing='1'>
		<tr>
			<th width='20%'>Stat</th>
			<th width='60%'>Amount</th>
			<th width='20%'>Tune</th>
		</tr>
		<tr>
			<th>Speed</th>
			<td><? echo format($myCar['pcSpeed']); ?></td>
			<td>Cost: <? echo format($myCar['pcSpeed'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=speed'>Tune</a></td>
		</tr>
		<tr>
			<th>Handling</th>
			<td><? echo format($myCar['pcHandling']); ?></td>
			<td>Cost: <? echo format($myCar['pcHandling'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=handling'>Tune</a></td>
		</tr>
		<tr>
			<th>Acceleration</th>
			<td><? echo format($myCar['pcAccel']); ?></td>
			<td>Cost: <? echo format($myCar['pcAccel'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=accel'>Tune</a></td>
		</tr>
		<tr>
			<th>Braking</th>
			<td><? echo format($myCar['pcBrake']); ?></td>
			<td>Cost: <? echo format($myCar['pcBrake'] * 2); ?><br /><a href='garage.php?action=upgrade&ID=<? echo $_GET['ID']; ?>&tune=brake'>Tune</a></td>
		</tr>
	</table><?
} else {
	$rand = mt_rand(1, 5);
	$uhOh = '';
	switch($_GET['tune']) {
		case 'speed':
			if(($myCar['pcSpeed'] * 2) > $ir['money']) {
				error("You don't have enough to pay for that upgrade");
			}
			if($rand >= 3) {
				$tuneThis = array('handling', 'accel', 'brake');
				shuffle($tuneThis);
				$randReturn = $tuneThis[0];
				$db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID']));
				if($randReturn == 'accel') {
					$randString = 'acceleration';
				} else if($randReturn == 'brake') {
					$randString = 'braking';
				} else {
					$randString = $randReturn;
				}
				$uhOh .= ' at the cost of your '.$randString;
			}
			$db->query(sprintf("UPDATE `playerCars` SET `pcSpeed` = `pcSpeed` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID']));
			$db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcSpeed'] * 2), $ir['userid']));
			success("You've upgraded your speed".$uhOh);
		break;
		case 'handling':
			if(($myCar['pcHandling'] * 2) > $ir['money']) {
				error("You don't have enough to pay for that upgrade");
			}
			if($rand >= 3) {
				$tuneThis = array('speed', 'accel', 'brake');
				shuffle($tuneThis);
				$randReturn = $tuneThis[0];
				$db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID']));
				if($randReturn == 'accel') {
					$randString = 'acceleration';
				} else if($randReturn == 'brake') {
					$randString = 'braking';
				} else {
					$randString = $randReturn;
				}
				$uhOh .= ' at the cost of your '.$randString;
			}
			$db->query(sprintf("UPDATE `playerCars` SET `pcHandling` = `pcHandling` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID']));
			$db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcHandling'] * 2), $ir['userid']));
			success("You've upgraded your handling".$uhOh);
		break;
		case 'accel':
			if(($myCar['pcAccel'] * 2) > $ir['money']) {
				error("You don't have enough to pay for that upgrade");
			}
			if($rand >= 3) {
				$tuneThis = array('speed', 'handling', 'brake');
				shuffle($tuneThis);
				$randReturn = $tuneThis[0];
				$db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID']));
				if($randReturn == 'accel') {
					$randString = 'acceleration';
				} else if($randReturn == 'brake') {
					$randString = 'braking';
				} else {
					$randString = $randReturn;
				}
				$uhOh .= ' at the cost of your '.$randString;
			}
			$db->query(sprintf("UPDATE `playerCars` SET `pcAccel` = `pcAccel` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID']));
			$db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcAccel'] * 2), $ir['userid']));
			success("You've upgraded your acceleration".$uhOh);
		break;
		case 'brake':
			if(($myCar['pcBrake'] * 2) > $ir['money']) {
				error("You don't have enough to pay for that upgrade");
			}
			if($rand >= 3) {
				$tuneThis = array('speed', 'handling', 'accel');
				shuffle($tuneThis);
				$randReturn = $tuneThis[0];
				$db->query(sprintf("UPDATE `playerCars` SET `pc%s` = GREATEST(`pc%s` - %u, 0) WHERE (`pcID` = %u)", ucfirst($randReturn), ucfirst($randReturn), mt_rand(10, 50), $_GET['ID']));
				if($randReturn == 'accel') {
					$randString = 'acceleration';
				} else if($randReturn == 'brake') {
					$randString = 'braking';
				} else {
					$randString = $randReturn;
				}
				$uhOh .= ' at the cost of your '.$randString;
			}
			$db->query(sprintf("UPDATE `playerCars` SET `pcBrake` = `pcBrake` + %u WHERE (`pcID` = %u)", (mt_rand(25, 100) * $ir['level']), $_GET['ID']));
			$db->query(sprintf("UPDATE `users` SET `money` = `money` - %u WHERE (`userid` = %u)", ($myCar['pcBrake'] * 2), $ir['userid']));
			success("You've upgraded your braking".$uhOh);
		break;
	}
}
}

function upgradeGarage() {
global $db, $ir;
$selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " .
									"FROM `playerGarages` AS `pg` " .
									"LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " .
									"WHERE (`pg`.`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	header("Location: garage.php?action=buy");
	exit;
}
$garage = $db->fetch_row($selectGarage);
if(!empty($_GET['ID'])) {
	$select = $db->query(sprintf("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = %u)", $_GET['ID']));
	if(!$db->num_rows($select)) {
		error("That upgrade doesn't exist");
	}
	$gar = $db->fetch_row($select);
	if($gar['gTypeCost'] > $ir['money']) {
		error("You don't have enough money for that");
	}
	$db->query(sprintf("UPDATE `playerGarages` SET `pgType` = %u WHERE (`pgUser` = %u)", $_GET['ID'], $ir['userid']));
	success("You've bought the ".format($gar['gTypeName']));
}
$getGarageUpgrades = $db->query(sprintf("SELECT * FROM `garages` WHERE (`gTypeID` > %u)", $garage['gTypeID']));
?><h3>Cars: Upgrading your <? echo format($garage['gTypeName']); ?></h3>
<table class='table' width='75%' cellspacing='1'>
	<tr>
		<th width='40%'>Upgrade</th>
		<th width='40%'>Cost</th>
		<th width='20%'>Links</th>
	</tr><?
if(!$db->num_rows($getGarageUpgrades)) {
	echo "<tr><td colspan='3' class='center'>There are no upgrades available</td></tr>";
} else {
	while($upg = $db->fetch_row($getGarageUpgrades)) {
		?><tr>
			<td><? echo format($upg['gTypeName']); ?></td>
			<td>$<? echo format($upg['gTypeCost']); ?></td>
			<td><? echo ($ir['money'] >= $upg['gTypeCost']) ? "<a href='garage.php?action=upgradegarage&ID=".$upg['gTypeID']."'>Buy</a>" : "<span style='color:#444;'>Buy</span>"; ?></td>
		</tr><?
	}
}
echo "</table>";
}

function sellCar() {
global $db, $ir;
$selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " .
									"FROM `playerGarages` AS `pg` " .
									"LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " .
									"WHERE (`pg`.`pgUser` = %u)", $ir['userid']));
if(!$db->num_rows($selectGarage)) {
	header("Location: garage.php?action=buy");
	exit;
}
if(empty($_GET['ID'])) {
	error("You didn't select a valid car");
}
$selectMyCar = $db->query(sprintf("SELECT * FROM `playerCars` WHERE ((`pcID = %u) AND (`pcUser` = %u))", $_GET['ID'], $ir['userid']));
if(!$db->num_rows($selectMyCar)) {
	error("You don't own that car");
}
$myCar = $db->fetch_row($selectMyCar);

$selectStandardCar = $db->query(sprintf("SELECT * FROM `cars` WHERE (`cID` = %u)", $myCar['pcCarID']));
if(!$db->num_rows($selectStandardCar)) {
	error("That car doesn't exist - message a staff member to inform them about this");
}
$stdCar = $db->fetch_row($selectStandardCar);
$myTotalStats = $myCar['pcSpeed'] + $myCar['pcHandling'] + $myCar['pcAccel'] + $myCar['pcBrake'];
$stdTotalStats = $stdCar['cSpeed'] + $stdCar['cHandling'] + $stdCar['cAccel'] + $stdCar['cBrake'];
if(($myTotalStats >= $stdTotalStats) && ($myTotalStats <= ($stdTotalStats + 500))) {
	$cost = $stdCar['cCost'] / 2;
} else if(($myTotalStats >= ($stdTotalStats + 501)) && $myTotalStats <= ($stdTotalStats + 1500)) {
	$cost = $stdCar['cCost'];
} else if(($myTotalStats >= ($stdTotalStats + 1501)) && $myTotalStats <= ($stdTotalStats * 2)) {
	$cost = ($stdCar['cCost'] * 2) - (($stdCar['cCost'] / 100) * 33);
} else if(($myTotalStats >= ($stdTotalStats * 2) + 1) && $myTotalStats <= ($stdTotalStats * 5)) {
	$cost = $stdCar['cCost'] * 3;
} else if(($myTotalStats >= ($stdTotalStats * 5) + 1) && $myTotalStats <= ($stdTotalStats * 10)) {
	$cost = $stdCar['cCost'] * 3;
} else if($myTotalStats >= ($stdTotalStats * 10) + 1) {
	$cost = $stdCar['cCost'] * 5;
}
?><h3>Cars: Selling your <? echo format($stdCar['cName']); ?></h3><?
if(!isset($_GET['ans'])) {
	?>If you sell your car, you will receive $<? echo format($cost); ?><br />
	Are you sure you want to do this?<br />
	<a href='garage.php?action=sell&ID=<? echo $_GET['ID']; ?>&ans=yes'>Yes</a> · <a href='garage.php'>No</a><?
} else {
	$db->query(sprintf("DELETE FROM `playerCars` WHERE (`pcID` = %u)", $_GET['ID']));
	$db->query(sprintf("UPDATE `users` SET `money` = `money` + %u WHERE (`userid` = %u)", $cost, $ir['userid']));
	success("You've sold your ".format($stdCar['cName'])." for \$".format($cost));
}
}

function buyGarage() {
global $db, $ir;
$selectGarage = $db->query(sprintf("SELECT `pg`.`pgCapacity`, `g`.* " .
									"FROM `playerGarages` AS `pg` " .
									"LEFT JOIN `garages` AS `g` ON (`pg`.`pgType` = `g`.`gTypeID`) " .
									"WHERE (`pg`.`pgUser` = %u)", $ir['userid']));
if($db->num_rows($selectGarage)) {
	header("Location: garage.php");
	exit;
}
$select = $db->query("SELECT `gTypeName`, `gTypeCost` FROM `garages` WHERE (`gTypeID` = 1)");
$gar = $db->fetch_row($select);
?><h3>Cars: Buying your first <? echo format($gar['gTypeName']); ?></h3><?
if($gar['gTypeCost'] > $ir['money']) {
	error("You don't have enough money to do that. It costs ".format($gar['gTypeCost']));
}
$db->query(sprintf("INSERT INTO `playerGarages` VALUES ('', %u, 1, 1)", $ir['userid']));
success("You've bought your ".format($gar['gTypeName']));
}

$h->endpage();
?>
Edited by Magictallguy
Added in "Race" link
  • 5 months later...
  • 5 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...