Jump to content

apw

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by apw

  1. Hello Hello, when a member logins into my game, I'm pulling information from my database and this information, depending on what actions the member does, either increases or decrease certin information in the database, this in turn is displayed to the member. However, in order for this information to be displayed, the member must refresh the screen. Is there ANY way I can display the new, current information to the member without them constantly hitting the refresh button? The member usually sits on one section of the screen but I am aware that if they leave that screen and go to something else and return the new information will appear, but what if the member just sits on one screen, without hitting the refresh can I still display the new updated information to them? Thanks
  2. Hello Hello, I was wondering if you could give me your suggestions on simplifying some code I had written. What I'm attempting to do is the following: I created a database table called barn, I added a few rows in the barn (as tests) called .. slot1_name to slot5_name in each of these i filled as different foods such as potatoes, carrots, tomatoes, pumpkins and grapes (as examples) now my question is, after i query my DB as follows: $barnstats="SELECT * from fw_barn where playername='$player'"; $barnstats2=mysql_query($barnstats) or die("Could not get user stats"); $barnstats3=mysql_fetch_array($barnstats2); I now have all my slots loaded into my $barnstats3 (i think) but my question is ... Say player A wants to buy another food from the vendor, the script has all the current foods that player A has in their barn .. but needs to check to see if any available slot1 to slot5 are empty .. what I did was I wrote 5 different if statements checking to see if those slots are already filled .. is there just one if statement I can write instead to check all slot1 to slot5 to see if they are either empty OR have something already inside them? Thanks in advance for your help
  3. Thanks for your help
  4. Hello I wrote a simple but effective countdown script .. you simply plug in the time (*nix time) that you want the script to end and it will countdown from now using the time(); function .. which is all good in a way, however here is what I'm running into the problem. I included the code below that I use for this simple script but as the time goes on, poor player has to keep hitting refresh for the time to update. This is because I store the time(); in my database along with the future time. Instead of poor player A having to keep hitting the refresh button is there a way I can script this to where no refresh is needed and the time continues to update then when the $ctime (current time) hits $etime (future time) the script stops and say it updates the database? I figured $etime by taking this and doing a simple: $etime = 30; Time I want to advance the current real time. So .. then I subtracted $etime - $ctime to get the difference But you already knew that .. If you could give me a hand, I'd greatly appreciate it, even simpilify my messy code to possibly get the result I'm looking for .. How about a javascript .. would that work as well? I have an exaple below the first set of code the code runs until the timer reaches 0 then restarts .. instead of restarting maybe have the code just end and preform a DB update? // Sets and posts current time to DB $my_time=time(); // current time $update_time="update bbg_timers set ctime='$my_time' where username='$username'"; mysql_query($update_time) or die("could not query"); $time_remain2=$etime-$ctime; // $time_remain2=$ctime-$etime; $difference=$time_remain2; $difference=$time_remain2; $hours_difference = floor($difference / 3600); $difference = $difference % 3600; $minutes_difference = floor($difference / 60); $seconds_difference = $difference % 60; $secshow = false; $timeleft = ''; if ($hours_difference > 0) { $timeleft .= $hours_difference . 'h '; } else { $secshow = true; } if ($diff > 60) { $timeleft .= $minutes_difference . 'm '; } elseif ($diff > 60 && !$seconds) { $timeleft = '<1m'; } if ($secshow) { $timeleft .= $seconds_difference . 's '; } if ($diff < 0) { print "Diff is < 0"; } if (($diff * 60) < 15) { // print "You have $hours_difference hours, $minutes_difference minutes, and $seconds_difference remaining"; } } Here is the other javascript code I was talking about -- I took this from the footer file of my bnt game (giving credit) so I'm not exactly sure what some of the code means // Update counter $res = $db->Execute("SELECT last_run FROM $dbtables[scheduler] LIMIT 1"); $result = $res->fields; $mySEC = ($sched_ticks * 60) - (TIME()-$result[last_run]); ?> <script language="javascript" type="text/javascript"> var myi = <?=$mySEC?>; setTimeout("rmyx();",1000); function rmyx() { myi = myi - 1; if (myi <= 0) { myi = <? echo ($sched_ticks * 60); echo "\n";?> } document.getElementById("myx").innerHTML = myi; setTimeout("rmyx();",1000); } </script> <? echo " <b><span id=myx>$mySEC</span></b> $l_footer_until_update <br>\n"; // End update counter Thanks again
×
×
  • 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.