Jump to content

apw

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by apw

  1. helloi'm desperately trying to create a simple chatbox for my website using php and whateverthe logged in user posts to there box then gets wrote to a sql database called km_babble and then displayed in the room for others to read. the max number of posts per box should be like 15 or so .. can someone assist me or lead me to docs that will help? thanks much in advance
  2. Im trying to write a very simple code that uses date("U") such as $thetime=date("U"); $timelimit=$thetime-3600*; which throws out 1265005026 but how do i change this to a hour/minute/second? Thanks
  3. Hello i run a webbased game with players using both mobile phones and computers and would like to have the php code tell the difference in my mobile users and pc users and have the game pages compatable for both .. This possible
  4. Database dump: -- phpMyAdmin SQL Dump -- version 3.2.0.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Sep 25, 2009 at 04:21 PM -- Server version: 5.1.37 -- PHP Version: 5.3.0 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `dk` -- -- -------------------------------------------------------- -- -- Table structure for table `dk_user_buildings` -- CREATE TABLE IF NOT EXISTS `dk_user_buildings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(10) NOT NULL, `level` int(10) NOT NULL, `building_name` varchar(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; -- -- Dumping data for table `dk_user_buildings` -- INSERT INTO `dk_user_buildings` (`id`, `username`, `level`, `building_name`) VALUES (2, 'playerB', 1, 'cottage'), (1, 'hugoland', 1, 'cottage'); The actual php code (that isn't working) function manage() { // Manages built buildings. global $userrow; $boo = doquery("SELECT * FROM {{table}} WHERE id='".$userrow["username"]."' LIMIT 1", "user_buildings"); $boo2 = mysql_fetch_array($boo); // trying to pull the users "charname" from the user database with $userrow["username"] $page = "The following are your available buildings:<br /><br />\n"; $page .= "<table width=\"80%\">\n"; $page .= "<td width=\"20%\"><b><a href=\"index.php?do=manage2:".$boo2["id"]."\">".$boo2["building_name"]."</a>$specialdot</b></td> <td width=\"50%\">Level:".$boo2["level"]."</b></td> <td width=\"50%\">Name".$boo2["building_name"]."</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); }
  5. Hello im looking for a simple countdown timer that starts only when a player clicks on the upgrade image but somehow must also run a simple .php script as well is this possible or do i need a 3rd-party code to help or what would i also need?
  6. Each player shares the uk_user_building which holds what every building each player has built if i use * it shows every player what i want to do is limit so playerA sees only their buildingsB and so on
  7. Would your example pull all the fields id, charname, level, building_name for that specific player so playerB doesnt see what playerA has
  8. Yes, playerA is charname .. Ive tried doing where by id and by charname but get no results
  9. Hello im trying to preform a simple query im trying to pull all the fields in the column yet only those by the players name. The table is my uk_user_buildings and contain the fields id, charname, level and building_name the table cnntains every player buildings but i only want say playerA buildings and not players B and C. How would i query the database to do this?
  10. index.php <?php // index.php :: Primary program script, iinclude('lib.php'); include('cookies.php'); $link = opendb(); $controlquery = doquery("SELECT * FROM {{table}} WHERE id='1' LIMIT 1", "control"); $controlrow = mysql_fetch_array($controlquery); // Login (or verify) if not logged in. $userrow = checkcookies(); if ($userrow == false) { if (isset($_GET["do"])) { if ($_GET["do"] == "verify") { header("Location: users.php?do=verify"); die(); } } header("Location: login.php?do=login"); die(); } // Close game. if ($controlrow["gameopen"] == 0) { display("The game is currently closed for maintanence. Please check back later.","Game Closed"); die(); } // Force verify if the user isn't verified yet. if ($controlrow["verifyemail"] == 1 && $userrow["verify"] != 1) { header("Location: users.php?do=verify"); die(); } // Block user if he/she has been banned. if ($userrow["authlevel"] == 2) { die("Your account has been blocked. Please try back later."); } if (isset($_GET["do"])) { $do = explode(":",$_GET["do"]); // Town functions. if ($do[0] == "inn") { include('towns.php'); inn(); } elseif ($do[0] == "buy") { include('towns.php'); buy(); } elseif ($do[0] == "buy2") { include('towns.php'); buy2($do[1]); } elseif ($do[0] == "buy3") { include('towns.php'); buy3($do[1]); } elseif ($do[0] == "sell") { include('towns.php'); sell(); } // Build Buildings Functions elseif ($do[0] == "build") { include('towns.php'); build(); } elseif ($do[0] == "buy2") { include('towns.php'); build2($do[1]); } elseif ($do[0] == "buy3") { include('towns.php'); build($do[1]); } // Misc functions. elseif ($do[0] == "verify") { header("Location: users.php?do=verify"); die(); } elseif ($do[0] == "showgold") { showgold(); } //Gold Popup elseif ($do[0] == "showpop") { showpop(); } //PopulTION Popup elseif ($do[0] == "showfood") { showfood(); } //food popup elseif ($do[0] == "showlumber") { showlumber(); } //lumber popup elseif ($do[0] == "showiron") { showiron(); } //iron popup elseif ($do[0] == "showstone") { showstone(); } //stone popup elseif ($do[0] == "onlinechar") { onlinechar($do[1]); } elseif ($do[0] == "showmap") { showmap(); } elseif ($do[0] == "babblebox") { babblebox(); } elseif ($do[0] == "ninja") { ninja(); } } else { donothing(); } function donothing() { global $userrow; if ($userrow["currentaction"] == "In Town") { $page = dotown(); $title = "In Town"; } elseif ($userrow["currentaction"] == "Exploring") { $page = doexplore(); $title = "Exploring"; } elseif ($userrow["currentaction"] == "Fighting") { $page = dofight(); $title = "Fighting"; } display($page, $title); } function dotown() { // Spit out the main town page. global $userrow, $controlrow; $townquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns"); if (mysql_num_rows($townquery) == 0) { display("There is an error with your user account, or with the town data. Please try again.","Error"); } $townrow = mysql_fetch_array($townquery); // News box. Grab latest news entry and display it. Something a little more graceful coming soon maybe. if ($controlrow["shownews"] == 1) { $newsquery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 1", "news"); $newsrow = mysql_fetch_array($newsquery); $townrow["news"] = "<table width=\"95%\"><tr><td class=\"title\">Latest News</td></tr><tr><td>\n"; $townrow["news"] .= "<span class=\"light\">[".prettydate($newsrow["postdate"])."]</span><br />".nl2br($newsrow["content"]); $townrow["news"] .= "</td></tr></table>\n"; } else { $townrow["news"] = ""; } // Who's Online. Currently just members. Guests maybe later. if ($controlrow["showonline"] == 1) { $onlinequery = doquery("SELECT * FROM {{table}} WHERE UNIX_TIMESTAMP(onlinetime) >= '".(time()-600)."' ORDER BY charname", "users"); $townrow["whosonline"] = "<table width=\"95%\"><tr><td class=\"title\">Who's Online</td></tr><tr><td>\n"; $townrow["whosonline"] .= "There are <b>" . mysql_num_rows($onlinequery) . "</b> user(s) online within the last 10 minutes: "; while ($onlinerow = mysql_fetch_array($onlinequery)) { $townrow["whosonline"] .= "<a href=\"index.php?do=onlinechar:".$onlinerow["id"]."\">".$onlinerow["charname"]."</a>" . ", "; } $townrow["whosonline"] = rtrim($townrow["whosonline"], ", "); $townrow["whosonline"] .= "</td></tr></table>\n"; } else { $townrow["whosonline"] = ""; } if ($controlrow["showbabble"] == 1) { $townrow["babblebox"] = "<table width=\"95%\"><tr><td class=\"title\">Babble Box</td></tr><tr><td>\n"; $townrow["babblebox"] .= "<iframe src=\"index.php?do=babblebox\" name=\"sbox\" width=\"100%\" height=\"250\" frameborder=\"0\" id=\"bbox\">Your browser does not support inline frames! The Babble Box will not be available until you upgrade to a newer <a href=\"http://www.mozilla.org\" target=\"_new\">browser</a>.</iframe>"; $townrow["babblebox"] .= "</td></tr></table>\n"; } else { $townrow["babblebox"] = ""; } $page = gettemplate("towns"); $page = parsetemplate($page, $townrow); return $page; } function doexplore() { // Just spit out a blank exploring page. // Exploring without a GET string is normally when they first log in, or when they've just finished fighting. $page = <<<END <table width="100%"> <tr><td class="title"><img src="images/title_exploring.gif" alt="Exploring" /></td></tr> <tr><td> You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus. </td></tr> </table> END; return $page; } function dofight() { // Redirect to fighting. header("Location: index.php?do=fight"); } function showchar() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["experience"] = number_format($userrow["experience"]); $userrow["gold"] = number_format($userrow["gold"]); if ($userrow["expbonus"] > 0) { $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; } elseif ($userrow["expbonus"] < 0) { $userrow["plusexp"] = "<span class=\"light\">(".$userrow["expbonus"]."%)</span>"; } else { $userrow["plusexp"] = ""; } if ($userrow["goldbonus"] > 0) { $userrow["plusgold"] = "<span class=\"light\">(+".$userrow["goldbonus"]."%)</span>"; } elseif ($userrow["goldbonus"] < 0) { $userrow["plusgold"] = "<span class=\"light\">(".$userrow["goldbonus"]."%)</span>"; } else { $userrow["plusgold"] = ""; } $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels"); $levelrow = mysql_fetch_array($levelquery); if ($userrow["level"] < 99) { $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]); } else { $userrow["nextlevel"] = "<span class=\"light\">None</span>"; } if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; } elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; } elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; } if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; } elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; } elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; } $spellquery = doquery("SELECT id,name FROM {{table}}","spells"); $userspells = explode(",",$userrow["spells"]); $userrow["magiclist"] = ""; while ($spellrow = mysql_fetch_array($spellquery)) { $spell = false; foreach($userspells as $a => $b) { if ($b == $spellrow["id"]) { $spell = true; } } if ($spell == true) { $userrow["magiclist"] .= $spellrow["name"]."<br />"; } } if ($userrow["magiclist"] == "") { $userrow["magiclist"] = "None"; } // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showchar"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function onlinechar($id) { global $controlrow; $userquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "users"); if (mysql_num_rows($userquery) == 1) { $userrow = mysql_fetch_array($userquery); } else { display("No such user.", "Error"); } // Format various userrow stuffs. $userrow["experience"] = number_format($userrow["experience"]); $userrow["gold"] = number_format($userrow["gold"]); if ($userrow["expbonus"] > 0) { $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; } elseif ($userrow["expbonus"] < 0) { $userrow["plusexp"] = "<span class=\"light\">(".$userrow["expbonus"]."%)</span>"; } else { $userrow["plusexp"] = ""; } if ($userrow["goldbonus"] > 0) { $userrow["plusgold"] = "<span class=\"light\">(+".$userrow["goldbonus"]."%)</span>"; } elseif ($userrow["goldbonus"] < 0) { $userrow["plusgold"] = "<span class=\"light\">(".$userrow["goldbonus"]."%)</span>"; } else { $userrow["plusgold"] = ""; } $levelquery = doquery("SELECT ". $userrow["charclass"]."_exp FROM {{table}} WHERE id='".($userrow["level"]+1)."' LIMIT 1", "levels"); $levelrow = mysql_fetch_array($levelquery); $userrow["nextlevel"] = number_format($levelrow[$userrow["charclass"]."_exp"]); if ($userrow["charclass"] == 1) { $userrow["charclass"] = $controlrow["class1name"]; } elseif ($userrow["charclass"] == 2) { $userrow["charclass"] = $controlrow["class2name"]; } elseif ($userrow["charclass"] == 3) { $userrow["charclass"] = $controlrow["class3name"]; } if ($userrow["difficulty"] == 1) { $userrow["difficulty"] = $controlrow["diff1name"]; } elseif ($userrow["difficulty"] == 2) { $userrow["difficulty"] = $controlrow["diff2name"]; } elseif ($userrow["difficulty"] == 3) { $userrow["difficulty"] = $controlrow["diff3name"]; } $charsheet = gettemplate("onlinechar"); $page = parsetemplate($charsheet, $userrow); display($page, "Character Information"); } function showmap() { global $userrow; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $page = $xml . gettemplate("minimal"); $array = array("content"=>"<center><img src=\"images/map.gif\" alt=\"Map\" /></center>", "title"=>"Map"); echo parsetemplate($page, $array); die(); } function showgold() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showchar"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function showpop() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showpop"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function showfood() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showfood"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function showlumber() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showlumber"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function showstone() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showstone"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function showiron() { global $userrow, $controlrow; // Format various userrow stuffs. $userrow["gold"] = number_format($userrow["gold"]); $userrow["plusexp"] = "<span class=\"light\">(+".$userrow["expbonus"]."%)</span>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $charsheet = gettemplate("showiron"); $page = $xml . gettemplate("minimal"); $array = array("content"=>parsetemplate($charsheet, $userrow), "title"=>"Character Information"); echo parsetemplate($page, $array); die(); } function babblebox() { global $userrow; if (isset($_POST["babble"])) { $safecontent = makesafe($_POST["babble"]); if ($safecontent == "" || $safecontent == " ") { //blank post. do nothing. } else { $insert = doquery("INSERT INTO {{table}} SET id='',posttime=NOW(),author='".$userrow["charname"]."',babble='$safecontent'", "babble"); } header("Location: index.php?do=babblebox"); die(); } $babblebox = array("content"=>""); $bg = 1; $babblequery = doquery("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 20", "babble"); while ($babblerow = mysql_fetch_array($babblequery)) { if ($bg == 1) { $new = "<div style=\"width:98%; background-color:#eeeeee;\">[<b>".$babblerow["author"]."</b>] ".$babblerow["babble"]."</div>\n"; $bg = 2; } else { $new = "<div style=\"width:98%; background-color:#ffffff;\">[<b>".$babblerow["author"]."</b>] ".stripslashes($babblerow["babble"])."</div>\n"; $bg = 1; } $babblebox["content"] = $new . $babblebox["content"]; } $babblebox["content"] .= "<center><form action=\"index.php?do=babblebox\" method=\"post\"><input type=\"text\" name=\"babble\" size=\"15\" maxlength=\"120\" /><br /><input type=\"submit\" name=\"submit\" value=\"Babble\" /> <input type=\"reset\" name=\"reset\" value=\"Clear\" /></form></center>"; // Make page tags for XHTML validation. $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n" . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n"; $page = $xml . gettemplate("babblebox"); echo parsetemplate($page, $babblebox); die(); } function ninja() { header("Location: http://www.jardano.com/img/shirtninja.jpg"); } ?>
  11. Hello I'm needing soneone to take a look at my build code and explain to me what I'm doing wrong. The php isn't showing errors during the first page, however the second page is just blank. The code is below that is in question: Once the first build function runs (which works) it displays a list of available buildings. When I click on the name of the building to preform the upgrade, the page just goes blank. towns.php function build() { // Displays a list of available buildings. global $userrow; $buildquery = doquery("SELECT charname,itemslist FROM {{table}}", "buildings"); //query buildings $userquery = doquery("SELECT * FROM {{table}}", "users"); // query users if (mysql_num_rows($buildquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); } $buildrow = mysql_fetch_array($buildquery); // build query $userrow = mysql_fetch_array($userquery); // query users $itemslist = explode(",",$buildrow["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", "build"); $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)) { $page .= "<tr><td width=\"4%\">"; if ($itemsrow["level"] == 1) { $page .= "<img src=\"images/upgrade.gif\" alt=\"upgrade!\" /></td>"; } if ($userrow["food"] < $buildrow["food_cost"] || $userrow["lumber"] < $itemsrow["cost_lumber"] || $userrow["iron"] < $itemsrow["cost_stone"]) { $page .= "<td width=\"32%\"><span class=\"light\">".$itemsrow["name"]."</span></td> <td width=\"32%\"><span class=\"light\">".$itemsrow["cost_food"]."</span></td> <td width=\"32%\"><span class=\"light\">Already purchased</span></td></tr>\n"; } else { $page .= "<td width=\"32%\"><b><a href=\"index.php?do=build2:".$itemsrow["id"]."\">".$itemsrow["name"]."</a></td> <td width=\"2%\"></td> <td width=\"50%\">Price:".$itemsrow["cost_food"]." food; ".$itemsrow["cost_lumber"]." lumber; ".$itemsrow["cost_iron"]." iron; ".$itemsrow["cost_stone"]." stone</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 build2($id) { // Confirm user's intent to build building. global $userrow; $buildquery = doquery("SELECT charname,itemslist FROM {{table}}", "buildings"); $userquery = doquery("SELECT * FROM {{table}}", "users"); if (mysql_num_rows($buildquery) != 1) { display("Cheat attempt detected.<br /><br />Get a life, loser.", "Error"); } $buildrow = mysql_fetch_array($buildquery); $userrow = mysql_fetch_array($userquery); $itemslist = explode(",",$buildrow["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", "build"); $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)) { $page .= "<tr><td width=\"4%\">"; if ($itemsrow["level"] == 1) { $page .= "<img src=\"images/upgrade.gif\" alt=\"upgrade!\" /></td>"; } if ($userrow["food"] < $buildrow["food_cost"] || $userrow["lumber"] < $itemsrow["cost_lumber"] || $userrow["iron"] < $itemsrow["cost_stone"]) { $page .= "<td width=\"32%\"><span class=\"light\">".$itemsrow["name"]."</span></td> <td width=\"32%\"><span class=\"light\">".$itemsrow["cost_food"]."</span></td> <td width=\"32%\"><span class=\"light\">Already purchased</span></td></tr>\n"; } else { $page .= "<td width=\"32%\"><b><a href=\"index.php?do=build2:".$itemsrow["id"]."\">".$itemsrow["name"]."</a></td> <td width=\"2%\"></td> <td width=\"50%\">Price:".$itemsrow["cost_food"]." food; ".$itemsrow["cost_lumber"]." lumber; ".$itemsrow["cost_iron"]." iron; ".$itemsrow["cost_stone"]." stone</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); } ?> index.php // Build Buildings Functions elseif ($do[0] == "build") { include('towns.php'); build(); } elseif ($do[0] == "buy2") { include('towns.php'); build2($do[1]); } elseif ($do[0] == "buy3") { include('towns.php'); build($do[1]); } Any help would be greatly appreciated!!
  12. Im actually trying just find the current time the player click the upgrade button then whatever time that is to add 15-minutes to that time so when the 15-minutes passes the player gets the upgrade! Any suggestions
  13. Hello i created an image called upgrade, also two fields in my database: starttime and endtime. When my happy player clicks on that button, i need the exact time the player did this, i also need an extra 15-minutes to be added to that time the happy player clicked the upgrade button. Can someone explain how this would be done? Thanks in advance
  14. Hello im trying to use the now() to capture the time a player clicks on the upgrade button. Once the player has done that i would like to add time that now() has captured. If now() has 07:15:00 i want to add an extra 15-minutes to this time then compare the two times to see if the 15-minutes has passed for an event to occur! How would you do this? Thanks!
  15. With the database workings posted, would it still be possible to keep the orginial idea of using 'real-time' for buildings? For player to reach level-1 cottage status, upon clicking the UPGRADE button would take 1-minute.30seconds, level-2 would take 4.minutes etc? Thanks again
  16. Hello I'm working on a game that players research/upgrade buildings. So far I've created a new table in the database called buildings and filled this database with fields such as: id charname (characters name) buildingname currentlevel (current level player has upgraded to) nextlevel (next level for the building upgrade) 1_level_cottage (how much time takes to upgrade - 1.minute) 2_level_cottagen (these are stamped in the database as datetime 3_level_cottage 4_level_cottage 5_level_cottage What I'm having an issue is with the following: 1. Instead of making a table called buildings, would it be better to create individual tables for EACH building or keep everything into one table? 2. I'm not sure how to go about doing the times for each upgrade. For example, for player to reach level-1 upgrade (after clicking the UPGRADE button) it would take the player 1.minute of real-time before the upgrade happens. I know I would need to stamp the exact time the player clicked the UPGRADE button into the database but how would I add say 1.minute or 60.minutes or even 3.hours to the exact time the player clicked the UPGRADE button? Thanks for your help!
  17. Hello im getting an error when running a scripts install program that stats: allow_url_include is on and should be turned off! I added a line in my .htacces to turn that off and when i redid the install the same error shows up. What can i do to fix this problem? Thanks
  18. apw

    php question

    Hello Hello I'm not sure if this is the right place for this or not but I'm looking for the name of the software package that has apache web server, sql and php aill bumdled into one package. I've search the internet and havent been able to find this package for windows. Thanks
  19. Geudrik, i wasnt aware that i was able to store simple times such as 40 seconds or 1minute-30 in a database but i do se what your saying about stamping the time then adding an end-time of x-min/sec to this which would work also im just not sure about the js countdown being fed the times through my database yet
  20. The real-time for the game would actually be a countdown timer at differemt times based on the level the player has gained on certin buildings such as level 1 would be 40 seconds then the next would be 1minute-30 and so on ..
  21. Hello im working on a script for a web-based game that uses real-time for player building, production, etc. My question is this possible with php or would i need a 3rd party script such as java to do these real-time actions. The times would be hard-coded and not in the datbase
  22. Could you recommend a book or two that would be helpful yet easy to understand for someone new to flash
  23. Thats great havent done much research into using flash/action-script but im sure theres +plenty+ of free guides online for help
  24. Hello i was interested in doing a project creating the isometric graghics and coding for a browser-based massive multiplayer online game using real-time with flash and have seen many of you talk about "action script" would this what i meed to purchase/download to begin this project?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.