-
Notifications
You must be signed in to change notification settings - Fork 21
/
towns.php
393 lines (300 loc) · 22.6 KB
/
towns.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?php // towns.php :: Handles all actions you can do in town.
function inn() { // Staying at the inn resets all expendable stats to their max values.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,innprice FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$townrow = mysql_fetch_array($townquery);
if ($userrow["gold"] < $townrow["innprice"]) { display("You do not have enough gold to stay at this Inn tonight.<br /><br />You may return to <a href=\"index.php\">town</a>, or use the direction buttons on the left to start exploring.", "Inn"); die(); }
if (isset($_POST["submit"])) {
$newgold = $userrow["gold"] - $townrow["innprice"];
$query = doquery("UPDATE {{table}} SET gold='$newgold',currenthp='".$userrow["maxhp"]."',currentmp='".$userrow["maxmp"]."',currenttp='".$userrow["maxtp"]."' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
$title = "Inn";
$page = "You wake up feeling refreshed and ready for action.<br /><br />You may return to <a href=\"index.php\">town</a>, or use the direction buttons on the left to start exploring.";
} elseif (isset($_POST["cancel"])) {
header("Location: index.php"); die();
} else {
$title = "Inn";
$page = "Resting at the inn will refill your current HP, MP, and TP to their maximum levels.<br /><br />\n";
$page .= "A night's sleep at this Inn will cost you <b>" . $townrow["innprice"] . " gold</b>. Is that ok?<br /><br />\n";
$page .= "<form action=\"index.php?do=inn\" method=\"post\">\n";
$page .= "<input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" />\n";
$page .= "</form>\n";
}
display($page, $title);
}
function buy() { // Displays a list of available items for purchase.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,itemslist FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$townrow = mysql_fetch_array($townquery);
$itemslist = explode(",",$townrow["itemslist"]);
$querystring = "";
foreach($itemslist as $a=>$b) {
$querystring .= "id='$b' OR ";
}
$querystring = rtrim($querystring, " OR ");
$itemsquery = doquery("SELECT * FROM {{table}} WHERE $querystring ORDER BY id", "items");
$page = "Buying weapons will increase your Attack Power. Buying armor and shields will increase your Defense Power.<br /><br />Click an item name to purchase it.<br /><br />The following items are available at this town:<br /><br />\n";
$page .= "<table width=\"80%\">\n";
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($itemsrow["type"] == 1) { $attrib = "Attack Power:"; } else { $attrib = "Defense Power:"; }
$page .= "<tr><td width=\"4%\">";
if ($itemsrow["type"] == 1) { $page .= "<img src=\"images/icon_weapon.gif\" alt=\"weapon\" /></td>"; }
if ($itemsrow["type"] == 2) { $page .= "<img src=\"images/icon_armor.gif\" alt=\"armor\" /></td>"; }
if ($itemsrow["type"] == 3) { $page .= "<img src=\"images/icon_shield.gif\" alt=\"shield\" /></td>"; }
if ($userrow["weaponid"] == $itemsrow["id"] || $userrow["armorid"] == $itemsrow["id"] || $userrow["shieldid"] == $itemsrow["id"]) {
$page .= "<td width=\"32%\"><span class=\"light\">".$itemsrow["name"]."</span></td><td width=\"32%\"><span class=\"light\">$attrib ".$itemsrow["attribute"]."</span></td><td width=\"32%\"><span class=\"light\">Already purchased</span></td></tr>\n";
} else {
if ($itemsrow["special"] != "X") { $specialdot = "<span class=\"highlight\">*</span>"; } else { $specialdot = ""; }
$page .= "<td width=\"32%\"><b><a href=\"index.php?do=buy2:".$itemsrow["id"]."\">".$itemsrow["name"]."</a>$specialdot</b></td><td width=\"32%\">$attrib <b>".$itemsrow["attribute"]."</b></td><td width=\"32%\">Price: <b>".$itemsrow["buycost"]." gold</b></td></tr>\n";
}
}
$page .= "</table><br />\n";
$page .= "If you've changed your mind, you may also return back to <a href=\"index.php\">town</a>.\n";
$title = "Buy Items";
display($page, $title);
}
function buy2($id) { // Confirm user's intent to purchase item.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,itemslist FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$townrow = mysql_fetch_array($townquery);
$townitems = explode(",",$townrow["itemslist"]);
if (! in_array($id, $townitems)) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$itemsquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "items");
$itemsrow = mysql_fetch_array($itemsquery);
if ($userrow["gold"] < $itemsrow["buycost"]) { display("You do not have enough gold to buy this item.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=buy\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Items"); die(); }
if ($itemsrow["type"] == 1) {
if ($userrow["weaponid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["weaponid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
$page = "If you are buying the ".$itemsrow["name"].", then I will buy your ".$itemsrow2["name"]." for ".ceil($itemsrow2["buycost"]/2)." gold. Is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
} else {
$page = "You are buying the ".$itemsrow["name"].", is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
}
} elseif ($itemsrow["type"] == 2) {
if ($userrow["armorid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["armorid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
$page = "If you are buying the ".$itemsrow["name"].", then I will buy your ".$itemsrow2["name"]." for ".ceil($itemsrow2["buycost"]/2)." gold. Is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
} else {
$page = "You are buying the ".$itemsrow["name"].", is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
}
} elseif ($itemsrow["type"] == 3) {
if ($userrow["shieldid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["shieldid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
$page = "If you are buying the ".$itemsrow["name"].", then I will buy your ".$itemsrow2["name"]." for ".ceil($itemsrow2["buycost"]/2)." gold. Is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
} else {
$page = "You are buying the ".$itemsrow["name"].", is that ok?<br /><br /><form action=\"index.php?do=buy3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
}
}
$title = "Buy Items";
display($page, $title);
}
function buy3($id) { // Update user profile with new item & stats.
if (isset($_POST["cancel"])) { header("Location: index.php"); die(); }
global $userrow;
$townquery = doquery("SELECT name,itemslist FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$townrow = mysql_fetch_array($townquery);
$townitems = explode(",",$townrow["itemslist"]);
if (! in_array($id, $townitems)) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
$itemsquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "items");
$itemsrow = mysql_fetch_array($itemsquery);
if ($userrow["gold"] < $itemsrow["buycost"]) { display("You do not have enough gold to buy this item.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=buy\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Items"); die(); }
if ($itemsrow["type"] == 1) { // weapon
// Check if they already have an item in the slot.
if ($userrow["weaponid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["weaponid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
} else {
$itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"X");
}
// Special item fields.
$specialchange1 = "";
$specialchange2 = "";
if ($itemsrow["special"] != "X") {
$special = explode(",",$itemsrow["special"]);
$tochange = $special[0];
$userrow[$tochange] = $userrow[$tochange] + $special[1];
$specialchange1 = "$tochange='".$userrow[$tochange]."',";
if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; }
if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; }
}
if ($itemsrow2["special"] != "X") {
$special2 = explode(",",$itemsrow2["special"]);
$tochange2 = $special2[0];
$userrow[$tochange2] = $userrow[$tochange2] - $special2[1];
$specialchange2 = "$tochange2='".$userrow[$tochange2]."',";
if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; }
if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; }
}
// New stats.
$newgold = $userrow["gold"] + ceil($itemsrow2["buycost"]/2) - $itemsrow["buycost"];
$newattack = $userrow["attackpower"] + $itemsrow["attribute"] - $itemsrow2["attribute"];
$newid = $itemsrow["id"];
$newname = $itemsrow["name"];
$userid = $userrow["id"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; }
if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; }
if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; }
// Final update.
$updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', attackpower='$newattack', weaponid='$newid', weaponname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users");
} elseif ($itemsrow["type"] == 2) { // Armor
// Check if they already have an item in the slot.
if ($userrow["armorid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["armorid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
} else {
$itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"X");
}
// Special item fields.
$specialchange1 = "";
$specialchange2 = "";
if ($itemsrow["special"] != "X") {
$special = explode(",",$itemsrow["special"]);
$tochange = $special[0];
$userrow[$tochange] = $userrow[$tochange] + $special[1];
$specialchange1 = "$tochange='".$userrow[$tochange]."',";
if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; }
if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; }
}
if ($itemsrow2["special"] != "X") {
$special2 = explode(",",$itemsrow2["special"]);
$tochange2 = $special2[0];
$userrow[$tochange2] = $userrow[$tochange2] - $special2[1];
$specialchange2 = "$tochange2='".$userrow[$tochange2]."',";
if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; }
if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; }
}
// New stats.
$newgold = $userrow["gold"] + ceil($itemsrow2["buycost"]/2) - $itemsrow["buycost"];
$newdefense = $userrow["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"];
$newid = $itemsrow["id"];
$newname = $itemsrow["name"];
$userid = $userrow["id"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; }
if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; }
if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; }
// Final update.
$updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', defensepower='$newdefense', armorid='$newid', armorname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users");
} elseif ($itemsrow["type"] == 3) { // Shield
// Check if they already have an item in the slot.
if ($userrow["shieldid"] != 0) {
$itemsquery2 = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["shieldid"]."' LIMIT 1", "items");
$itemsrow2 = mysql_fetch_array($itemsquery2);
} else {
$itemsrow2 = array("attribute"=>0,"buycost"=>0,"special"=>"X");
}
// Special item fields.
$specialchange1 = "";
$specialchange2 = "";
if ($itemsrow["special"] != "X") {
$special = explode(",",$itemsrow["special"]);
$tochange = $special[0];
$userrow[$tochange] = $userrow[$tochange] + $special[1];
$specialchange1 = "$tochange='".$userrow[$tochange]."',";
if ($tochange == "strength") { $userrow["attackpower"] += $special[1]; }
if ($tochange == "dexterity") { $userrow["defensepower"] += $special[1]; }
}
if ($itemsrow2["special"] != "X") {
$special2 = explode(",",$itemsrow2["special"]);
$tochange2 = $special2[0];
$userrow[$tochange2] = $userrow[$tochange2] - $special2[1];
$specialchange2 = "$tochange2='".$userrow[$tochange2]."',";
if ($tochange2 == "strength") { $userrow["attackpower"] -= $special2[1]; }
if ($tochange2 == "dexterity") { $userrow["defensepower"] -= $special2[1]; }
}
// New stats.
$newgold = $userrow["gold"] + ceil($itemsrow2["buycost"]/2) - $itemsrow["buycost"];
$newdefense = $userrow["defensepower"] + $itemsrow["attribute"] - $itemsrow2["attribute"];
$newid = $itemsrow["id"];
$newname = $itemsrow["name"];
$userid = $userrow["id"];
if ($userrow["currenthp"] > $userrow["maxhp"]) { $newhp = $userrow["maxhp"]; } else { $newhp = $userrow["currenthp"]; }
if ($userrow["currentmp"] > $userrow["maxmp"]) { $newmp = $userrow["maxmp"]; } else { $newmp = $userrow["currentmp"]; }
if ($userrow["currenttp"] > $userrow["maxtp"]) { $newtp = $userrow["maxtp"]; } else { $newtp = $userrow["currenttp"]; }
// Final update.
$updatequery = doquery("UPDATE {{table}} SET $specialchange1 $specialchange2 gold='$newgold', defensepower='$newdefense', shieldid='$newid', shieldname='$newname', currenthp='$newhp', currentmp='$newmp', currenttp='$newtp' WHERE id='$userid' LIMIT 1", "users");
}
display("Thank you for purchasing this item.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=buy\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Items");
}
function maps() { // List maps the user can buy.
global $userrow, $numqueries;
$mappedtowns = explode(",",$userrow["towns"]);
$page = "Buying maps will put the town in your Travel To box, and it won't cost you as many TP to get there.<br /><br />\n";
$page .= "Click a town name to purchase its map.<br /><br />\n";
$page .= "<table width=\"90%\">\n";
$townquery = doquery("SELECT * FROM {{table}} ORDER BY id", "towns");
while ($townrow = mysql_fetch_array($townquery)) {
if ($townrow["latitude"] >= 0) { $latitude = $townrow["latitude"] . "N,"; } else { $latitude = ($townrow["latitude"]*-1) . "S,"; }
if ($townrow["longitude"] >= 0) { $longitude = $townrow["longitude"] . "E"; } else { $longitude = ($townrow["longitude"]*-1) . "W"; }
$mapped = false;
foreach($mappedtowns as $a => $b) {
if ($b == $townrow["id"]) { $mapped = true; }
}
if ($mapped == false) {
$page .= "<tr><td width=\"25%\"><a href=\"index.php?do=maps2:".$townrow["id"]."\">".$townrow["name"]."</a></td><td width=\"25%\">Price: ".$townrow["mapprice"]." gold</td><td width=\"50%\" colspan=\"2\">Buy map to reveal details.</td></tr>\n";
} else {
$page .= "<tr><td width=\"25%\"><span class=\"light\">".$townrow["name"]."</span></td><td width=\"25%\"><span class=\"light\">Already mapped.</span></td><td width=\"35%\"><span class=\"light\">Location: $latitude $longitude</span></td><td width=\"15%\"><span class=\"light\">TP: ".$townrow["travelpoints"]."</span></td></tr>\n";
}
}
$page .= "</table><br />\n";
$page .= "If you've changed your mind, you may also return back to <a href=\"index.php\">town</a>.\n";
display($page, "Buy Maps");
}
function maps2($id) { // Confirm user's intent to purchase map.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,mapprice FROM {{table}} WHERE id='$id' LIMIT 1", "towns");
$townrow = mysql_fetch_array($townquery);
if ($userrow["gold"] < $townrow["mapprice"]) { display("You do not have enough gold to buy this map.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=maps\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Maps"); die(); }
$page = "You are buying the ".$townrow["name"]." map. Is that ok?<br /><br /><form action=\"index.php?do=maps3:$id\" method=\"post\"><input type=\"submit\" name=\"submit\" value=\"Yes\" /> <input type=\"submit\" name=\"cancel\" value=\"No\" /></form>";
display($page, "Buy Maps");
}
function maps3($id) { // Add new map to user's profile.
if (isset($_POST["cancel"])) { header("Location: index.php"); die(); }
global $userrow, $numqueries;
$townquery = doquery("SELECT name,mapprice FROM {{table}} WHERE id='$id' LIMIT 1", "towns");
$townrow = mysql_fetch_array($townquery);
if ($userrow["gold"] < $townrow["mapprice"]) { display("You do not have enough gold to buy this map.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=maps\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Maps"); die(); }
$mappedtowns = $userrow["towns"].",$id";
$newgold = $userrow["gold"] - $townrow["mapprice"];
$updatequery = doquery("UPDATE {{table}} SET towns='$mappedtowns',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display("Thank you for purchasing this map.<br /><br />You may return to <a href=\"index.php\">town</a>, <a href=\"index.php?do=maps\">store</a>, or use the direction buttons on the left to start exploring.", "Buy Maps");
}
function travelto($id, $usepoints=true) { // Send a user to a town from the Travel To menu.
global $userrow, $numqueries;
if ($userrow["currentaction"] == "Fighting") { header("Location: index.php?do=fight"); die(); }
$townquery = doquery("SELECT name,travelpoints,latitude,longitude FROM {{table}} WHERE id='$id' LIMIT 1", "towns");
$townrow = mysql_fetch_array($townquery);
if ($usepoints==true) {
if ($userrow["currenttp"] < $townrow["travelpoints"]) {
display("You do not have enough TP to travel here. Please go back and try again when you get more TP.", "Travel To"); die();
}
$mapped = explode(",",$userrow["towns"]);
if (!in_array($id, $mapped)) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); }
}
if (($userrow["latitude"] == $townrow["latitude"]) && ($userrow["longitude"] == $townrow["longitude"])) { display("You are already in this town. <a href=\"index.php\">Click here</a> to return to the main town screen.", "Travel To"); die(); }
if ($usepoints == true) { $newtp = $userrow["currenttp"] - $townrow["travelpoints"]; } else { $newtp = $userrow["currenttp"]; }
$newlat = $townrow["latitude"];
$newlon = $townrow["longitude"];
$newid = $userrow["id"];
// If they got here by exploring, add this town to their map.
$mapped = explode(",",$userrow["towns"]);
$town = false;
foreach($mapped as $a => $b) {
if ($b == $id) { $town = true; }
}
$mapped = implode(",",$mapped);
if ($town == false) {
$mapped .= ",$id";
$mapped = "towns='".$mapped."',";
} else {
$mapped = "towns='".$mapped."',";
}
$updatequery = doquery("UPDATE {{table}} SET currentaction='In Town',$mapped currenttp='$newtp',latitude='$newlat',longitude='$newlon' WHERE id='$newid' LIMIT 1", "users");
$page = "You have travelled to ".$townrow["name"].". You may now <a href=\"index.php\">enter this town</a>.";
display($page, "Travel To");
}
?>