Jump to content
MakeWebGames

Recommended Posts

Posted

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);)

Posted

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);

}

}
Posted

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?

Posted

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();
?>
Posted

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

Posted

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.

Posted

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.

Posted

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.

Posted

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...

Posted

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');

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...