Jump to content
MakeWebGames

Recommended Posts

Posted
My monorail won't show the citys i create :( any reAson why?

Contact MCCodes Support and they'll issue you with a repaired one.

 

This was a known issue and has been actually repaired in the patched version so they say, However contact them

Posted

ok so did you fix staff citys? if not

find

Minimum Level: <input type='text' name=minlevel' />

 

Replace with

 

Minimum Level: <input type='text' name='minlevel' />

 

if that does not work please explain better or post your files not working is not really a lot of info

Posted

staff_cities.php

<?php
include "sglobals.php";
if($ir['user_level'] > 2)
{
die("403");
}
//This contains city stuffs
switch($_GET['action'])
{
case "addcity": addcity(); break;
case "editcity": editcity(); break;
case "delcity": delcity(); break;
default: print "Error: This script requires an action."; break;
}
function addcity()
{
global $db, $ir, $c, $h, $userid;
$minlevel=abs((int) $_POST['minlevel']);
$name=$_POST['name'];
$desc=$_POST['desc'];
if($minlevel and $desc and $name)
{
	$q=$db->query("SELECT * FROM cities WHERE cityname='{$name}'");
	if($db->num_rows($q))
	{
		print "Sorry, you cannot have two cities with the same name.";
		$h->endpage();
		exit;
	}
	$db->query("INSERT INTO cities VALUES('', '$name', '$desc', '$minlevel')");
	print "City {$name} added to the game.";
	stafflog_add("Created City $name");
}
else
{
	print "<h3>Add City</h3><hr />
	<form action='staff_cities.php?action=addcity' method='post'>
	Name: <input type='text' name='name' />

	Description: <input type='text' name='desc' />

	Minimum Level: <input type='text' name='minlevel' />


	<input type='submit' value='Add City' /></form>";
}
}
function editcity()
{
global $db, $ir, $c, $h, $userid;
switch($_POST['step'])
{
case "2":
$minlevel=abs((int) $_POST['minlevel']);
$name=$_POST['name'];
$desc=$_POST['desc'];
$q=$db->query("SELECT * FROM cities WHERE cityname='{$name}' AND cityid!={$_POST['id']}");
if($db->num_rows($q))
{
print "Sorry, you cannot have two cities with the same name.";
$h->endpage();
exit;
}
$name=$_POST['name'];
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['id']}");
$old=$db->fetch_row($q);
$db->query("UPDATE cities SET cityminlevel=$minlevel, citydesc='$desc', cityname='$name' WHERE cityid={$_POST['id']}");
print "City $name was edited successfully.";
stafflog_add("Edited city $name");
break;
case "1":
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['city']}");
$old=$db->fetch_row($q);
print "<h3>Editing a City</h3><hr />
<form action='staff_cities.php?action=editcity' method='post'>
<input type='hidden' name='step' value='2' />
<input type='hidden' name='id' value='{$_POST['city']}' />
Name: <input type='text' name='name' value='{$old['cityname']}' />

Description: <input type='text' name='desc' value='{$old['citydesc']}' />

Minimum Level: <input type='text' name='minlevel' value='{$old['cityminlevel']}' />

<input type='submit' value='Edit City' /></form>";
break;
default:
print "<h3>Editing a City</h3><hr />
<form action='staff_cities.php?action=editcity' method='post'>
<input type='hidden' name='step' value='1' />
City: ".location_dropdown($c, "city")."

<input type='submit' value='Edit City' /></form>";
break;
}
}
function delcity()
{
global $db,$ir,$c,$h,$userid;
if($_POST['city'])
{
$q=$db->query("SELECT * FROM cities WHERE cityid={$_POST['city']}");
$old=$db->fetch_row($q);
if($old['cityid']==1)
{
die("This city cannot be deleted.");
}

$db->query("UPDATE users SET location=1 WHERE location={$old['cityid']}");
$db->query("UPDATE shops SET shopLOCATION=1 WHERE shopLOCATION={$old['cityid']}");
$db->query("DELETE FROM cities WHERE cityid={$old['cityid']}");
print "City {$old['cityname']} deleted.";
stafflog_add("Deleted city {$old['cityname']}");
}
else
{
print "<h3>Delete City</h3><hr />
Deleting a city is permanent - be sure. Any users and shops that are currently in the city you delete will be moved to the default city (ID 1).<form action='staff_cities.php?action=delcity' method='post'>
City: ".location_dropdown($c, "city")."

<input type='submit' value='Delete City' /></form>";
}
}
function report_clear()
{
global $db,$ir,$c,$h,$userid;
if($ir['user_level'] > 3)
{
die("403");
}
$_GET['ID'] = abs((int) $_GET['ID']);
$_GET['ID']=mysql_safe($_GET['ID']);
stafflog_add("Cleared player report ID {$_GET['ID']}");
$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");
print "Report cleared and deleted!

[url='staff_users.php?action=reportsview']> Back[/url]";
}
$h->endpage();
?>

 

monorail.php

<?php


include "globals.php";


$ticketprice = 1000; // Set this to the price, you would like the players to pay, to travel between cities


echo <<<EOFS1

<style type="text/css">

 .success { color: green; }

 .fail { color: red; }

 table { text-align: center; }

</style>

EOFS1;

$_GET['to'] = (!empty($_GET['to']) && ctype_digit($_GET['to']) && isset($_GET['to']) ? abs(@intval($_GET['to'])) : FALSE);


if(!$_GET['to'])

{

 echo" <h1> Welcome to the Monorail Station. </h1>";

 echo "<h3> It costs \$$ticketprice for a ticket </h3>";

 echo "<h3> Where would you like to travel today?</h3>";

 $get_cities = sprintf("SELECT * FROM `cities` WHERE `cityid` != %d AND `cityminlevel` <= %d", $ir['location'], $ir['level']);

 $q = mysql_query($get_cities);

 if($q === FALSE) { echo "".mysql_error().""; }

echo <<<EOF1

 <table style="width:75%;border-spacing:1">

<tr>

 	<th> Name </th>

 	<th> Description </th>

 	<th> Min Level </th>

 	<th>   </th>

</tr>

EOF1;

 while($r = $db->fetch_row($q))

 {

echo <<<EOF2

<tr>

 	<td> {$r['cityname']} </td>

 	<td> {$r['citydesc']} </td>

 	<td> {$r['cityminlevel']} </td>

 	<td> [url='monorail.php?to={$r[']Go[/url] </td>

</tr>

EOF2;

 }

 echo "</table>";

}

else

{

 if($ir['money'] < $ticketprice)

 {

echo "<h3 class='fail'> You don't have enough money </h3>";

 }

 else if($_GET['to'] != $_GET['to'])

 {

echo "<h3 class='fail'> Invalid city ID </h3>";

 }

 else

 {

$select_cities = sprintf("SELECT * FROM `cities` WHERE `cityid` = %d AND `cityminlevel` <= %d", $_GET['to'], $ir['level']);

$q = mysql_query($select_cities);

if($q === FALSE) { echo "".mysql_error().""; }

if(!$db->num_rows($q))

{

 	echo "<h3 class='fail'> Error, this city either does not exist or you cannot go there </h3>";

}

else

{

 	$update_query = sprintf("UPDATE `users` SET `money` = `money` - %d, `location` = %d WHERE `userid` = %u", $ticketprice, $_GET['to'], abs(@intval($userid)));

 	$foo = mysql_query($update_query);

 	if($foo === FALSE) { echo "".mysql_error().""; }

 	$r = $db->fetch_row($q);

 	printf("<h3 class='success'> Congratulations, you paid \$%d and travelled to %s on the monorail! </h3>", $ticketprice, $r['cityname']);

}

 }

}



$h->endpage();


?>

 

SQL

[mysql]CREATE TABLE `cities` (

`cityid` int(11) NOT NULL auto_increment,

`cityname` varchar(255) NOT NULL default '',

`citydesc` longtext NOT NULL,

`cityminlevel` int(11) NOT NULL default '0',

PRIMARY KEY (`cityid`)

) ENGINE=MyISAM ;

INSERT INTO `cities` VALUES('1', 'Default City', 'A standard city added to start you off', 1);[/mysql]

Thats the files :/

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...