Beste CP'ers,
Ik probeer nu al een uur lang de Criminolz plattegrond te rippen, maar zonder resultaat.
De javascript werkt weer eens niet.
Voorbeeld hier:
http://www.pretpark-online.nl/townmap.php#
De pijlen werken beide niet
Ik hoop dat iemand me kan helpen, de scripts zijn hier:
townmap.php
PHP
<?php
session_start();
include "config.php";
include "functions.php";
$empty = 'empty' . @$_SESSION['empty'];
if(empty($_GET['x'])) {
$_GET['x'] = 0;
}
if(empty($_GET['y'])) {
$_GET['y'] = 0;
}
echo'
<div id="content_top"> </div>
<script type="text/javascript">
var x = 0;
var y = 0;
function gotox(value) {
destination = (250 - value) * -1;
if(destination <= 249) {
if(destination >= -249) {
if(destination != x) {
x = destination;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
} else if(x != -249) {
x = -249;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
} else if(x != 249) {
x = 249;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
}
function gotoy(value) {
destination = (250 - value) * -1;
if(destination <= 249) {
if(destination >= -249) {
if(destination != y) {
y = destination;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
} else if(y != -249) {
y = -249;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
} else if(y != 249) {
y = 249;
sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');
}
}
</script>
<div id="content">
<h1 class="titel">Plattegrond van ' . $steden[$own['stad']] . '</h1>
Hier staan jouw woningen en woningen geplaatst door anderen. Klik op een woning om naar het profiel te gaan, waar je de woningen kunt aanvallen of repareren. Klik op een stukje grond om er een woning te plaatsen.<br /><br />
<center>Ga naar: <input type="text" onkeyup="gotox(value)" size="3" value="250" class="input"> x <input type="text" onkeyup="gotoy(value)" size="3" value="250" class="input"></center>
<div style="float: left"><a href="#" onclick="if(y > -249) {sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + (y - 1) + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');y--;} return false;"><img src="images/map/arrow_up.gif" border="0"></a><br /><br /><a href="#" onclick="if(y < 249) {sendReq(\'ajax/townmap.php?x=\' + x + \'&y=\' + (y + 1) + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');y++;} return false;"><img src="images/map/arrow_down.gif" border="0"></a></div>
<div id="map">
<table cellpadding="0" cellspacing="0" align="center">';
$xcenter = 250;
$ycenter = 250;
$i = $ycenter - 1;
while($i <= $ycenter + 1) {
echo'
<tr>
<td width="30">' . $i . '</td>';
$j = $xcenter - 1;
while($j <= $xcenter + 1) {
echo'
<td style="background: url(images/map/' . $empty . '.jpg) no-repeat; width: 100px; height: 100px;">';
$house2 = mysql_query("SELECT soort, eigenaar, id, prijs, kraam FROM woningen WHERE geplaatst = 'Ja' AND coordinaten_y = '" . $i . "' AND coordinaten_x = '" . $j . "'");
$house = mysql_fetch_array($house2);
if(!empty($house)) {
$woning2 = mysql_query("SELECT naam FROM woningenmarkt WHERE id = '" . $house2['soort'] . "'");
$woning = mysql_fetch_array($woning2);
if($house['eigenaar'] == $own['login']) {
$plaatje = 'house_' . ($house['soort'] - 1) . 'stars_own.gif';
$titel = 'Jouw ' . strtolower($woning['naam']);
} else {
$plaatje = 'house_' . ($house['soort'] - 1) . 'stars.gif';
$titel = $woning['naam'] . ' van ' . $house['eigenaar'];
}
echo'<a href="index.php?p=woning&id=' . $house['id'] . '"><img src="images/map/' . $plaatje . '" title="' . $titel . '" border="0"></a>';
} else {
echo'<a href="index.php?p=build&x=' . $j . '&y=' . $i . '"><img src="images/map/' . $empty . '.jpg" border="0"></a>';
}
echo'</td>';
$j++;
}
echo'
</tr>';
$i++;
}
echo'
<tr>
<td> </td>';
$j = $xcenter - 1;
while($j <= $xcenter + 1) {
echo'<td align="center">' . $j . '</td>';
$j++;
}
echo'
</tr>
</table>
</div>
<table align="center">
<tr>
<td align="center"><a href="#" onclick="if(x > -249) {sendReq(\'ajax/townmap.php?x=\' + (x - 1) + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');x--;} return false;"><img src="images/map/arrow_left.gif" border="0"></a></td>
<td align="center"><a href="#" onclick="if(x < 249) {sendReq(\'ajax/townmap.php?x=\' + (x + 1) + \'&y=\' + y + \'&ajaxsession=' . rand(10000, 99999) . '\', \'map\');x++;} return false;"><img src="images/map/arrow_right.gif" border="0"></a></td>
</tr>
</table><br />
<a href="index.php?p=listbuildings&owner=' . $own['id'] . '">Mijn woningen weergeven</a>';
echo'
</div>
<div id="content_bottom"> </div>';
?>
Toon Meer
ajax/townmap.php
PHP
<?php
include "config.php";
include "functions.php";
$ajax = "true";
if(@$_SESSION['empty'] == "2") {
$_SESSION['empty'] = "";
} else {
$_SESSION['empty'] = "2";
}
$empty = 'empty' . $_SESSION['empty'];
echo' <table cellpadding="0" cellspacing="0" align="center">';
$xcenter = 250 + number_format(round(@$_GET['x']), 0, "", "");
$ycenter = 250 + number_format(round(@$_GET['y']), 0, "", "");
if($xcenter < 1) {
$xcenter = 1;
}
if($xcenter > 499) {
$xcenter = 499;
}
if($ycenter < 1) {
$ycenter = 1;
}
if($ycenter > 499) {
$ycenter = 499;
}
$i = $ycenter - 1;
while($i <= $ycenter + 1) {
echo'
<tr>
<td width="30">' . $i . '</td>';
$j = $xcenter - 1;
while($j <= $xcenter + 1) {
echo'
<td style="background: url(images/map/' . $empty . '.jpg) no-repeat; width: 100px; height: 100px;">';
$house2 = mysql_query("SELECT soort, eigenaar, id, prijs, kraam FROM woningen WHERE geplaatst = 'Ja' AND coordinaten_y = '" . $i . "' AND coordinaten_x = '" . $j . "'");
$house = mysql_fetch_array($house2);
if(!empty($house)) {
$woning2 = mysql_query("SELECT naam FROM woningenmarkt WHERE id = '" . $house2['soort'] . "'");
$woning = mysql_fetch_array($woning2);
if($house['eigenaar'] == $own['login']) {
$plaatje = 'house_' . ($house['soort'] - 1) . 'stars_own.gif';
$titel = 'Jouw ' . strtolower($woning['naam']);
} else {
$plaatje = 'house_' . ($house['soort'] - 1) . 'stars.gif';
$titel = $woning['naam'] . ' van ' . $house['eigenaar'];
}
echo'<a href="index.php?p=woning&id=' . $house['id'] . '"><img src="images/map/' . $plaatje . '" title="' . $titel . '" border="0"></a>';
} else {
echo'<a href="index.php?p=build&x=' . $j . '&y=' . $i . '"><img src="images/map/' . $empty . '.jpg" border="0"></a>';
}
echo'</td>';
$j++;
}
echo'
</tr>';
$i++;
}
echo'
<tr>
<td> </td>';
$j = $xcenter - 1;
while($j <= $xcenter + 1) {
echo'<td align="center">' . $j . '</td>';
$j++;
}
echo'
</tr>
</table>';
?>
Toon Meer
bedankt alvast!