Jump to content
MakeWebGames

Recommended Posts

Posted

im making a new mod and in there im using timestamps but as ive never used timestamps before i was wondering if what ive done is correct and will work im just going to post the the code for the timestamp check rather than the whole function ifs its wrong would you peeps be able to point me in the right direction?

what i want is if the money been in the bank longer than 6 hours the user is allowed to remove it if not they have to wait some more thanks skal.

 

$q=$db->query("SELECT * FROM drugs_bank WHERE db_time = (unix_timestamp + 3600*60) WHERE userid = $userid");
if(mysql_num_rows($q) == 0)
{
echo"The time limit has expired yet please wait some more time";
}
Posted

for 6 hours, you need to calculate

60 seconds x 60 mins x 6 hours = 21600 seconds

So you want to find out if its been been longer then current time (unix_timestamp) minus 21600 seconds.

 

$q=$db->query("SELECT * FROM drugs_bank WHERE db_time < unix_timestamp() - 21600 WHERE userid = $userid");
if(mysql_num_rows($q) == 0)
{
   echo"The time limit has expired yet please wait some more time";
}

Posted

Actually i might be wrong

"The time limit has expired yet please wait some more time"

 

Do you mean "hasnt"

 

if so, you need to invert the < to a >

when db_time is set, is it set to current time or a future time stamp?

Posted

You're only displaying a message, you're not killing the page too ;)

$q = $db->query("SELECT * FROM drugs_bank WHERE ((db_time = unix_timestamp - 21600) AND (userid = $userid))");

if(!$db->num_rows($q)) {

echo "The time limit has expired yet please wait some more time";

$h->endpage();

exit;

}

Posted
You're only displaying a message, you're not killing the page too ;)

 

      $q = $db->query("SELECT * FROM `drugs_bank` WHERE ((`db_time` = unix_timestamp - 21600) AND (`userid` = $userid))");
if( $db->num_rows($q) == 0 ) {
  echo '
     The time limit has expired yet please wait some more time
  ';
     $h->endpage();
     exit;
}

seems about right MTG.

fbiss => C:\dos , C:\dos\run , run\dos\run still cracks me up when i read it lol

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...