Jump to content


Photo

time problem


  • Please log in to reply
1 reply to this topic

#1 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 29 July 2006 - 10:39 PM

I'm trying to make a timer for part of a game that i am making. If i member does a certain thing it puts them a 'jail'. For this particular instance, i want the timer to start at 40 and countdown, and once the time has passed, they be removed from the jail. Here's what i've got so far.

<?php
if ($got_inmates[1] == 40){
$jail_time = mysql_query("SELECT * FROM JAIL WHERE TIME > DATE_SUB(NOW(), INTERVAL 40 SECOND) AND USERNAME='$got_inmates[0]'");
$jail_time_check = mysql_num_rows($jail_time);
$get_sentence_time = mysql_query("SELECT ADDTIME(TIME, '00:00:40') FROM JAIL WHERE USERNAME='$got_inmates[0]'");
if ($jail_time_check < 1) {
$remove_from_jail = mysql_query("DELETE FROM JAIL WHERE USERNAME='$got_inmates[0]'");
}
if ($jail_time_check > 0) {
$got_sentence_time = mysql_result($get_sentence_time, 0);
$timer1 = date('Y-m-d H:i:s');
$timer2 = strtotime($timer1);
$timer3 = strtotime($got_sentence_timer);
$timer4 = $timer3 - $timer2;
$timer5 = date("s", $timer4);
}
if (empty($timer5)){
$timer5 = "0";
}
}
?>

The problem is that the timer starts at random places, when i want it to start at 40. Can anyone help me out and tell me how to fix it?

Thanks in advance for any help. If you need more info just ask.

#2 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 29 July 2006 - 10:57 PM

I fixed it, it was just a typo in one of the variable names :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users