Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //what to do when they have landed $_GET['gid'] $_GET['uid']
- /*
- =========================Key=============================
- Key for what to return and when |
- --------------------------------------------------------
- |TAX |For a tax that has been levied |
- |GO |For passing go |
- |Free |For an empty square such as jail |
- |Chance |Landed on a chance |
- |Chest |Landed on a comunity chest sqr |
- |Jailed |Landed on goto jail |
- |Mortgaged |The property is owned but under mortgage |
- |Rent#n |Where n is the build status of the property|
- |fair |The property is not yet owned |
- ---------------------------------------------------------
- =========================================================
- */
- // Create connection to database
- include 'sql.php';
- //get users position and other items from the X table
- $qur = "SELECT * FROM x" . $_GET['gid'] . " WHERE id = " . $_GET['uid'];
- $result = mysqli_query($con,$qur);
- while($row = mysqli_fetch_array($result))
- {
- $position = $row['Position'];
- $Money = $row['Money'];
- $Liberty = $row['Liberty'];
- $Property = $row['Property'];
- }
- if($Liberty = 1){
- //get property information
- $qur = "SELECT * FROM Properties WHERE ID=" . $position;
- $result = mysqli_query($con,"SELECT * FROM Properties WHERE ID=" . $position);
- while($row = mysqli_fetch_array($result))
- {
- //take all the data from the server
- $prop = $row;
- echo $row['ID'];
- }
- echo $prop['ID'];
- //check what type of property it is
- if($Prop['Band']=null){
- //its not a property
- switch($Prop['Name']){
- case "Chance":
- //chance card
- break;
- case "Chest":
- //comunity chest
- break;
- case "Go":
- //passing go
- echo "GO";
- UpMoney($Money + 200);
- break;
- case "Income tax":
- //tax $200
- echo "TAX";
- UpMoney($Money - 200);
- break;
- case "GOTO Jail":
- //Liberty is removed
- echo "Jailed";
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Liberty=0 WHERE id='" . $_GET['uid'] . "'");
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Position=10 WHERE id='" . $_GET['uid'] . "'");
- break;
- case "Super tax":
- //taxed $100
- echo "TAX";
- UpMoney($Money - 100);
- break;
- default:
- //free parking or visiting jail
- echo "Free";
- }
- }else{
- //its a property
- //have a variable to look if its owned
- $owned = false;
- //look to see if the property is owned by someone
- $result = mysqli_query($con,"SELECT * FROM x" . $_GET['gid']);
- //WARNING!!! Script allows for money to go negative!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- while($row = mysqli_fetch_array($result))
- {
- //stop the program looking at the current users file
- if($row['id']!=$_GET['uid']){
- //if the property is not owned
- if(substr($row['Property'],$position,1)!=0){
- $owned=true;
- switch(substr($row['Property'],$position,1)){
- case 1:
- //morgaged
- echo "Mortgaged";
- break;
- case 2:
- //owned - basic rent
- echo "Rent#" . $prop['Rent0'];
- UpMoney($Money - $prop['Rent0']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent0']) . " WHERE id='" . $row['id'] . "'");
- break;
- case 3:
- //1 house
- echo "Rent#" . $prop['Rent1'];
- UpMoney($Money - $prop['Rent1']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent1']) . " WHERE id='" . $row['id'] . "'");
- break;
- case 4:
- //2 houses
- echo "Rent#" . $prop['Rent2'];
- UpMoney($Money - $prop['Rent2']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent2']) . " WHERE id='" . $row['id'] . "'");
- break;
- case 5:
- //3 houses
- echo "Rent#" . $prop['Rent3'];
- UpMoney($Money - $prop['Rent3']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent3']) . " WHERE id='" . $row['id'] . "'");
- break;
- case 6:
- //4 houses
- echo "Rent#" . $prop['Rent4'];
- UpMoney($Money - $prop['Rent4']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['Rent4']) . " WHERE id='" . $row['id'] . "'");
- break;
- case 7:
- //A hotel
- echo "Rent#" . $prop['RentH'];
- UpMoney($Money - $prop['RentH']);
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . ($row['Money'] + $prop['RentH']) . " WHERE id='" . $row['id'] . "'");
- break;
- default:
- //error
- }
- }else{
- //not owned by this person
- }
- }
- }
- if($owned=false){
- //the property is fair game to be purchased
- echo "fair";
- }
- }
- }else{
- //in jail
- echo "In Jail";
- }
- ?>
- <?php
- function UpMoney($newamount){
- include 'sql.php';
- mysqli_query($con,"UPDATE x" . $_GET['gid'] . " SET Money=" . $newamount . " WHERE id='" . $_GET['uid'] . "'");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment