Hi,
I'm Making a online game i'm Done With Everything Except Times.
What I mean is (Example):
Like Player Send a Car to deliver something And When Car Is back player Get Money And experience . i want to Make A time for car so when Player Send a Car, 20 minutes After, player get money and experience not at the moment
My Online Game Is A Text-Based
Any Idea?
Thanks
Help Me With My Online Game [SOLVED]
Help Me With My Online Game [SOLVED]
Last edited by amir on Thu Apr 05, 2012 3:01 pm, edited 1 time in total.
(: (Please excuse my bad English) 
- Foofighter
- Posts: 121
- Joined: Sun Mar 04, 2012 1:52 pm
Re: Help Me With My Online Game
Hi,
there are 2 simple ways , with Javascript or without.
without Javascript you can basically save (timestamp + drivetimecar) in your DB when the car starts, then check the following timestamp - time() == 0 .
br
Foo
there are 2 simple ways , with Javascript or without.
without Javascript you can basically save (timestamp + drivetimecar) in your DB when the car starts, then check the following timestamp - time() == 0 .
br
Foo
Re: Help Me With My Online Game
hiFoofighter wrote:Hi,
there are 2 simple ways , with Javascript or without.
without Javascript you can basically save (timestamp + drivetimecar) in your DB when the car starts, then check the following timestamp - time() == 0 .
br
Foo
Thanks For Replying but can you give me more details please
(: (Please excuse my bad English) 
- Foofighter
- Posts: 121
- Joined: Sun Mar 04, 2012 1:52 pm
Re: Help Me With My Online Game
Code: Select all
<?php
$stats_get = mysql_query("SELECT * FROM `xyz` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error());
$stats = mysql_fetch_assoc($stats_get);
$zeit = time();
if (isset($_POST['drive']))
{
$zeit=time() + 1200;
mysql_query("UPDATE xyz SET car_time = $zeit WHERE id ='".$_SESSION['uid']."'");
}
//----------------------------------------------------------------------------------------------------------
if($stats[''car_time']>0)
{
$rest = $stats['car_time'] - time();
if($rest == 0)
{
mysql_query("UPDATE xyz SET EXP = EXP + x , money = money + y, car_time = 0, WHERE id ='".$_SESSION['uid']."'");
}
}
?>
//---------------------------------------------------------------------------------------------------------
Car: <?php echo $stats['car']; ?><br>
<?php if ($stats['car_time'] > 0)
{
?> estimated arrival of car: <?php $rest= $stats['car_time] - time(); if ($rest <0){$rest = 0;} echo"$rest"?> <?php
}
else
{ ?>
<form action="#" method="post">
<input type="submit" value="Send car" name="drive" >
</form>
<?php } ?>
the 1200 is the value in seconds for your 20min.
br
Foo
Re: Help Me With My Online Game
HiFoofighter wrote:Thats how i do it i just adapted it for your example, but thats for sure not the best way cause iam pretty much a beginner at this..Code: Select all
<?php $stats_get = mysql_query("SELECT * FROM `xyz` WHERE `id`='".$_SESSION['uid']."'") or die(mysql_error()); $stats = mysql_fetch_assoc($stats_get); $zeit = time(); if (isset($_POST['drive'])) { $zeit=time() + 1200; mysql_query("UPDATE xyz SET car_time = $zeit WHERE id ='".$_SESSION['uid']."'"); } //---------------------------------------------------------------------------------------------------------- if($stats[''car_time']>0) { $rest = $stats['car_time'] - time(); if($rest == 0) { mysql_query("UPDATE xyz SET EXP = EXP + x , money = money + y, car_time = 0, WHERE id ='".$_SESSION['uid']."'"); } } ?> //--------------------------------------------------------------------------------------------------------- Car: <?php echo $stats['car']; ?><br> <?php if ($stats['car_time'] > 0) { ?> estimated arrival of car: <?php $rest= $stats['car_time] - time(); if ($rest <0){$rest = 0;} echo"$rest"?> <?php } else { ?> <form action="#" method="post"> <input type="submit" value="Send car" name="drive" > </form> <?php } ?>
the 1200 is the value in seconds for your 20min.
br
Foo
Wow Amazing I don't know how to say thanks , it's really amazing
thanks
(: (Please excuse my bad English) 