legrolls Posted May 30, 2009 Posted May 30, 2009 How would I make it so you need to be playing at a certain time to get something? Say 7:00 PM, how would I make it so something happens at that specific time? Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? if(date('h') == '07' || date('h') == '19') { give item } Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? How would I make it so from 7 to 9 PM, you can get a certain item? And what does your "give item" mean? The script of giving the item itself? (in this case, $itemid = 59; item_add($userid, $itemid, 1);) Quote
Faz` Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Why use a variable if you can just put the direct number inside? item_add($userid,59,1); Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? Ok, but what about the time itself? Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? if(date('h') <= '19' || date('h') => '21') { item_add($ir['userid'], 59, 1); } That will run all the time from 19 (7pm) all the way to 21 (9pm) but that will always be giving an item, make a mt_rand around it like this... if(mt_rand(1,100) == 49) { if(date('h') <= '19' || date('h') => '21') { item_add($ir['userid'], 59, 1); } } Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? <php include "globals.php"; if(mt_rand(1,100) == 49) { if(date('h') <= '19' || date('h') => '21') { item_add($ir['userid'], 59, 1); } } ?> This is my code right now, it's not working. I must be doing something wrong, can you help me fix it? Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? <= '19' || date('h') => '21') { item_add($ir['userid'], 59, 1); } } ?> This is what I get when I go on the time.php Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? <?php include_once('globals.php'); if(mt_rand(1,100) == 49) { if(date('h') <= '19' || date('h') >= '21') { item_add($ir['userid'], 59, 1); echo 'You just been given the item x'; } } $h->endpage(); ?> Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? It seems I get the item now, but no text. Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Post being updated with correct one Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? Now it doesn't seem to work at all? :? Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? <?php include_once('globals.php'); if(mt_rand(1,100) == 49) { if(date('g') <= '7' && date('g') >= '9') { echo 'You just been given the item x'; item_add($ir['userid'], 59, 1); } } $h->endpage(); ?> Try that one :P Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? Still not working. Can you make the script from 3PM to 7PM? Just wondering. And now, I'm not even getting the item. Quote
AbsentCrisis Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Add to the header file so it actually is apart of the game not just a file that would never be used. Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? <?php include_once('globals.php'); $mt = mt_rand(1, 100); if($mt == 49) { if(date('g') <= 7 && date('g') >= 9) { echo 'You landed it, and it is the right time! You just found item x'; item_add($ir['userid'], 59, 1); } else { echo 'You landed it, but it just was not the right time.'; } } else { echo 'Damn, you never landed it! You landed '.$mt.'. You need a 49.'; } $h->endpage(); ?> There i added some bit's to show which error message is showing. Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? Damn, you never landed it! You landed 74. You need a 49. Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? If you take away the mt_rand bit your member's will have fun by refreshing the page and gaining tons of these item's, and i can assure you, one can gain over a million items over 2 hour's. Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? So what am I supposed to do? :? Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Add this bit: $mt = mt_rand(1, 100); if($mt == 49) { if(date('g') <= 7 && date('g') >= 9) { echo 'You landed it, and it is the right time! You just found item x'; item_add($ir['userid'], 59, 1); } else { echo 'You landed it, but it just was not the right time.'; } } else { echo 'Damn, you never landed it! You landed '.$mt.'. You need a 49.'; } To header and then they can get a chance per click on your game. Quote
legrolls Posted May 30, 2009 Author Posted May 30, 2009 Re: Using time? It didn't do anything. Here's what I want: I want it so you get an item at a certain amount of time. The item is item 59, and the time is from 4PM to 7PM. I changed the times... Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Ok, but you will need to add a cron & a sql field. I will post it all now :] Quote
Haunted Dawg Posted May 30, 2009 Posted May 30, 2009 Re: Using time? Add the bellow code to header: if(!$ir['item_recieved']) { if(date('g') <= 7 && date('g') >= 9) { echo 'You landed it, and it is the right time! You just found item x'; item_add($ir['userid'], 59, 1); } } Run this SQL: ALTER TABLE `users` ADD `item_recieved` TINYINT(2) NOT NULL DEFAULT '0'; Add this code to cron day: mysql_query('UPDATE `users` SET `item_recieved` = 0 WHERE `item_recieved` = 1'); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.