PHP - Mmorpg Style Timer Help.
Ok guys, I'm gonna have to throw a question out there. I am building a mmorpg. And I could use some help with some coding.
I have two cron files that run every hour and every day(24 hrs ) My question is, how can I add a visual countdown based on server time to show how long the cron has left to tick? I have tried many countdowns but most of them reset once I leave the page. So basically I need a countdown timer to show the user how long till he getts more food or whatever. Any help would be greatly appreciated. Thank you in advance for taking time to read and/or help. Similar Tutorialsim currently making a mmorpg i have a bank php script and i want donator intrest to be higher then normal players intrest Code: [Select] $interest= $ir['bankmoney']/100*2 ; $interests=money_formatter($interest); $balance=money_formatter($ir['bankmoney']); ^^^ i want that changed so if ($ir['donatordays'] > 0) donator days are higher then 0 then its 100*6 but normal intrest is 100*2 i can upload more of the bank code if needed but need help with this one as cant figure it out i am a noob and learning so if u have a snippet for it would you be able to explain the code to make this work i do not expect to be spoonfed information but any help u could give would be great thanks Hey Guy's
I need a quick fix to solve an urgent problem..
I used to do some coding years ago but the old grey matter is not so responsive these days and I have been up all night trying to resolve a problem.
I have built a website for my daughters and created a simple web form but I have come unstuck. All those skills I once took for granted are gone.
So here's where I am at. I've created an input form_mail.html, a contact.php and a reply.html page uploaded them to the Server and hit an error when I tried to send a message. The problem it seems is with the PHP.ini File.
In short I don't have one Duh! Yes I know I should go back and study and that much I intend to do I am currently installing xxampp, MySQL and php on my new laptop.
But in the meantime I need your help urgently..
What code do I need in the php.ini file to make the Form Mail work?
Is there somewhere on the web where I can see a simple code, I am just too tired to wade through heavy docs right now.
Your help would be much appreciated at this time.
Sincerely
Tam
Hello. Well i'm trying to make a timer to execute some code. Basically I want 3 minutes, every 3 minutes a piece of code is activated, then another 3 minutes later it does so again. But I have tried different ways of doing this, I tried with cookies and found out the person with the cookie is the only one that can refresh the page to activate the code. Same with sessions. And all the others are usually interrupted and start the timer again when the page reset. So yeah, I don't want it to be interrupted by refreshing. So any help please? I also tried with timestamps, this has proven to be the best way but I can never get it working 100% Can someone show me the way? I am creating a online examination with time pressured. For example Part I of examination is only good for 20 mins. now if 20 mins is over it will be lock or good as submit. How will I do that? tnx everyone. How am i able to setup a countdown timer? I use the time(); function and want to compare that time with another time that is 8 hours ahead to form a countdown timer, how am i able to do this using php? onkeydown="this.style.fontStyle='normal';"How can I add color: #000; to this? Thanks, Here's the code for the countdown timer. It works. At the end of the countdown, it's suppose to show the message "EXPIRED". But that message only shows once I reload the page. The countdown itself stops at 00:00:01. Is there a way to automatically show the message after that, instead of reloading the page to show it? <style> div#counter{ margin: 100px auto; width: 305px; padding:20px; border:1px solid #000000; } div#counter span{ background-color: #00CAF6; padding:5px; margin:1px; font-size:30px; } </style> <?php $target_date = '2019-01-12 05:40:00'; $timeLeft = (strtotime($target_date) - time()) * 1000; ?> <script src="javascripts/timer.js"></script> <script> $(document).ready(function(){ var timeLeft = <?php echo $timeLeft ; ?>; var timer = new Timer($('#counter'), timeLeft); if (timeLeft <= 0) { $('#counter').text('EXPIRED'); } }); </script> <div id="counter"> <span class="hour">00</span> <span class="min">00</span> <span class="sec">00</span> </div> Edited January 11, 2019 by imgrooot Can anyone help me with a 60 second timer for my website. I want to display the following text to my customers at the top of the page: "You will be automatically redirected to homepage in [timer]" In my header I have the following code: <meta http-equiv="refresh" content="61;url=home.php"> Hi, I'm new to the forum, I have a slight issue with my script. Basically, I need to figure out a script that will allow me to do the following: - The user defines x amount of ours to count down (ie. 16 hours, 8 hours, 4 hours) - The script then starts the count down of the x hours - I need the script to count between 08:00 - 20:00 after 20:00 it needs to stop, then start again at 08:00 - The script also need to stop throughout the weekend (ie counts until 20:00 on friday, stops saturday & sunday, then starts 08:00 on monday) Can this be done? If so, any pointers or help? Many thanks, Lewis. Hi im trying to Make a Timer count down in this code function getTime($host, $user, $pass, $db, $hours, $ip, $serverId) { $c = @mysql_connect($host, $user, $pass); if(mysql_select_db($db, $c)) { $dateQ = mysql_query('SELECT MAX(date) AS lastVoteDate FROM `'. $db .'`.`votes` WHERE ip="'. $ip .'"') or die(mysql_error()); $getDate = mysql_fetch_assoc($dateQ); $diffrence = time() - strtotime($getDate['lastVoteDate']); $hours = number_format(($diffrence / 60 / 60)); $minutes = number_format(($hours / 60)); if(!$hours < 1){ return ("". $hours .""); } else { return ("0"); } } else { return array(1, "Error connecting to DB."); } } Can anyone help me to make a countdown timer in php? so basically i've made a quiz.. but i want it to have a time of 1 hour 30 mins.. but i dont have any idea of how to make a timer I am looking for a tutorial or advice wherein I can create a timer for my auction items. You can see those timers on the site like quibids.com The concept is like this. I post and auction and set an end time for the auction. When the auction is live, The timer will start and will show how many hours and seconds are remaining. If any one has a class or some link to a tutorial site, that'll be a great help. Thanks a lot. I am currently in the process of creating an online time based game. One of the big things is that users get gold every half an hour :00 & :30. What I am trying to do is offer a physical clock so that users can see how much time is left before they more more gold. I have been trying to do this using PHP. All I have currently is the time, but would like something like "$minutes until more gold". This is currently what I have now: (added 1 hour for EST.) <?php echo date("h:i A",time()+60*60); ?> Hi all, I would like to create a timer showing a countdown from 0% to 100% (representing "power") ending at noon GMT on Sunday 4th September. The countdown started a few weeks ago, hence as of 1pm GMT on Tuesday 1st March, the countdown should be at 15% The "power" increases by 5% every 11 days so by my calculations, the percentage in our countdown should increase by 0.01% every 1900.8 seconds. So, with this theory, how would I go about coding it? I guess since I use GMT, I need to take a timestamp in GMT first, then calculate the difference between this and Sunday 4th September at 12.00pm. I am not sure though which format of time/date is best to do the calculation. Would it be better to use Unix time? Any help, suggestions and/or code is greatly appreciated. Skulty I don't know if this can be done in PHP, but what I'm wanting to do is calculate the amount of time a user has spent in a session. I am planning on making a script that allows users to race through questions and the person who does it the fastest is the winner. Could someone help me out with this? Thanks Newbie PHP user here, so go easy on me . I've been trying to make a timer that starts on an arbitrary number of seconds, say 10 for example, then counts down to 0 (and refreshes itself every second for the user to see how much time is remaining), and then some more code is executed when 0 is reached. I attempted to do something like: <?php $goal = time() + 10; while($goal - time() >= 0) { echo "$goal - time()"; sleep(1); } ?> This didn't seem to work as my page just took a while to load - I suspect it was going through the entire while loop before displaying anything rather than just dynamically updating the timer every second. Also when I chose 100 instead of 10, the webpage didn't seem to even finish loading. Also it displayed a lot of odd text - not a timer at all! Help would be much appreciated ! Hi Guys! Hoping someone can help me with this. I need to produce a timer which I can embed on a website. It needs to count down the remaining hours until 7pm during the weekdays, then at the weekends count down until 7pm on Monday. Any ideas or points in the right direction would be greatly appreciated! I'm a bit of a newbie! Hey guys and gals!
I am currently working on implementing the following functionality in one of my pages:
Whenever a person with a specific IP address visits the page, an internal countdown timer of 2 hours should be started. Until that timer is active, the only response from the page ANYONE can get would be a predefined echo value. Once the timer has run out, the normal script execution of the rest of the page should be restored.
Any pointers and tips on how to approach that would be greatly appreciated.
I have a loop creating a block_vars array for displaying records from a database. (In this case auction listings). The following code creates this array: // get random selection of 6 items for home page display $query = "SELECT id, title, current_bid, pict_url, ends, num_bids, minimum_bid, bn_only, buy_now, subtitle, starts, ends, reserve_price FROM " . $DBPrefix . "auctions WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . " ORDER BY RAND() DESC LIMIT 6"; $res = mysql_query($query); $system->check_mysql($res, $query, __LINE__, __FILE__); $showendtime = false; $has_ended = false; $k = 0; while($row = mysql_fetch_assoc($res)) { $ends = $row['ends']; $difference = $ends - time(); if ($difference > 0) { $ends_string = FormatTimeLeft($difference); } else { $ends_string = $MSG['911']; } $high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid']; $high_bid = ($row['bn_only'] == 'y') ? $row['buy_now'] : $high_bid; //determine whether the auction has a Buy Now price, show if appropriate. if($row['buy_now'] == '0.0000') { $bnamount = ""; } else { $bnamount = "<a href='" . $system->SETTINGS['siteurl'] . "buy_now.php?id=" . $row['id'] ."'>$" . substr($row['buy_now'], 0, -2) . "<br />" . "Buy Now</a>"; } //determine if the auction has a reserve set and if it has been met. display appropriate symbol if($row['reserve_price'] == '0.0000' && $row['bn_only'] == 'n' && ($row['current_bid'] < $row['minimum_bid'])) { $flag = '<img src="images/noreserve.gif" alt="No Reserve">'; $flagdesc = " No Reserve!"; $bnonly = "Current Bid<br />"; } else { if($row['current_bid'] >= $row['reserve_price']) { $flag = '<img src="images/reservemet.gif" alt="Reserve Met">'; $flagdesc = " Reserve Met!"; $bnonly = "Current Bid<br />"; } else { $flag = '<img src="images/noflag.gif">'; $flagdesc = ""; $bnonly = "Current Bid<br />"; } } if($row['reserve_price'] == '0.0000' && $row['bn_only'] == 'y') { $flag = '<img src="images/noflag.gif">'; $flagdesc = ""; $bnonly = "Asking Price "; $bnamount = ""; } $template->assign_block_vars('randomitems', array( 'ID' => $row['id'], 'BID' => $bnonly . "$" . substr($high_bid, 0, -2), 'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg', 'TITLE' => $row['title'], 'BUY_NOW' => $bnamount, 'SUBTITLE' => $row['subtitle'], 'TIMELEFT' => $ends_string, 'NUMBIDS' => $row['num_bids'], 'FLAG' => $flag, 'FLAGDESC' => $flagdesc )); $k++; } Pretty straightforward. You will see I have a TIMELEFT value which will show on my home page as no.days, no.hours, no.mins until it closes etc. Here is the html in the tpl file: Code: [Select] <!-- BEGIN randomitems --> <div style="float:left;display:block;width:99%;border-bottom:#CCCCCC 1px solid;padding:2px;"> <div style="display:block;"> <table width="100%"> <tr> <td align="center" style="vertical-align:middle;width:120px" > <a href="{SITEURL}item.php?id={randomitems.ID}"><img src="{randomitems.IMAGE}" alt="{randomitems.TITLE}" style="border: none;width:120px"></a> </td> <td align="left" width="40%"> <table style="width:100%; vertical-align:middle; margin:0 auto"> <tr> <td><a id="itemdesc" href="{SITEURL}item.php?id={randomitems.ID}">{randomitems.TITLE}</a><br /> {randomitems.SUBTITLE}</td> </tr> <tr> <td id="closes">Closes in:{randomitems.TIMELEFT}</td> </tr> <tr> <td>{randomitems.FLAG}{randomitems.FLAGDESC}</td> </tr> </table> </td> <td id="buynow" align="center" width="15%"> {randomitems.BUY_NOW} </td> <td id="currentbid" align="center" width="25%"> {randomitems.BID} </td> </tr> </table> </div> </div> <!-- END randomitems --> This works quite nicely for me. What I want, and cannot manage thus far is to have the TIMELEFT value count down. The closest I have come is using a function like this: Code: [Select] <script type="text/javascript"> $(document).ready(function() { var currenttime = '{randomitems.TIMELEFT}'; function padlength(what) { var output=(what.toString().length == 1)? '0' + what : what; return output; } function displaytime() { currenttime -= 1; if (currenttime > 0){ var hours = Math.floor(currenttime / 3600); var mins = Math.floor((currenttime - (hours * 3600)) / 60); var secs = Math.floor(currenttime - (hours * 3600) - (mins * 60)); var timestring = padlength(hours) + ':' + padlength(mins) + ':' + padlength(secs); $("#ending_counter").html(timestring); setTimeout(displaytime, 1000); } else { $("#ending_counter").html('<span class="errfont">{L_911}</span>'); } } setTimeout(displaytime, 1000); }); </script> This code is placed in the tpl file and I simply give an html element the appropriate ID. The problem with this is that it would only show a countdown timer for the first item returned, which is no good as there are always six items returned. Can anyone offer a suggestion on how I could go about this? I can PM anyone with suggestions with a link to my development site so you know what I am raving about. Hey guys. My question is simple. I have a time value of the future, in seconds, that I extract from MySQL. time(); How do I make an interactive countdown timer using it? It should show the numbers ticking away. I tried Javascript, but it doesn't go with the php time layout. Can anyone help me here? Thanks! |