PDA

View Full Version : Php Help (+ Rep)



Assassinator
10-02-2008, 08:47 PM
Ok, so basicly on the users profile i have this;


<?php

$time_min=time() - (1 * 1);

$time_five=time() - (60 * 5);

$time_day=time() - (3600 * 24);

$time_week=time() - (3600 * 24 * 7);

if($fetch->ghostmode == "1"){
$state="<font color=RED>(Offline)</font>";

}elseif ($fetch->online > $time_min){

$state="<font color=00FF00>(Online)</font>";

}elseif ($fetch->online > $time_min){

$state="<font color=RED>(Offline)</font>";


}elseif ($fetch->online > $time_five){

$state="<font color=PURPLE>(Busy)</font>";

}elseif ($fetch->online > $time_five){

$state="<font color=RED>(Offline)</font>";


}elseif ($fetch->online > $time_day){

$state="<font color=RED>(Offline)</font>";

}elseif ($fetch->online > $time_day){

$state="<font color=RED>(Offline)</font>";


}elseif ($fetch->online > $time_week){

$state="<font color=RED>(Offline)</font>";

}elseif ($fetch->online > $time_week){

$state="<font color=RED>(Offline)</font>";

}


echo "<font color=white>$fetch->status</font> $state"; ?>
How would i make it so if a user's status has just been set to dead, there status is (Bleeding to Death) for exacly one minute, they it goes to (Dead).

+ Rep for all answeres.

Thread moved from website design by --ss-- (Forum Super Moderator): Please post in a more specific section ;).

QuickScriptz
11-02-2008, 12:31 AM
So, here's how I'd do it.... (in pseudo code)



<?php
// $whendead will be the time() for when they died
$lastaction = $whendead;
if($lastaction >= time()-60){ //If lastaction was less than 60 seconds ago
$status = 'Bleeding to death';
}elseif($lastaction < time()-60){ //If lastaction was more than 60 seconds ago
$status = 'Dead';
}?>
?>

Hypertext
11-02-2008, 05:09 AM
hehe edit


<?php
// $whendead will be the time() for when they died
$lastaction = $whendead;
if($lastaction >= time()-60){ //If lastaction was less than 60 seconds ago
$status = 'Bleeding to death';
}elseif($lastaction < time()-60){ //If lastaction was more than 60 seconds ago
$status = 'Dead';
}
?>

Assassinator
11-02-2008, 08:23 AM
Thanks, Rep+ to both but can anyone enter it in my code so it works?

Tomm
11-02-2008, 09:14 AM
No because your code does not include a time when they died.


Thanks, Rep+ to both but can anyone enter it in my code so it works?

Want to hide these adverts? Register an account for free!