• NOW LIVE! Into the Woods--new character species, eerie monsters, and haunting villains to populate the woodlands of your D&D games.

[RPG] Jobs and collecting salary?

Actually, I think I'll make it easier for the guy to fix it instead of give a general description I think that the code is adding 1 day when it should be subtracting 1 day(ie the sign is reversed on that operation).
 

log in or register to remove this ad

Confirm.
$nowtime=time();
$checktime=$nowtime-$member['last_jpay'];
$rate=$job['jinterval'];
if($checktime > $rate){
// timer disable
$timer="Your salary is now able to be collected";
$time=$timer;
} else {

// [Calculate Time Untill Next Payment]
$diff = time()-$member['last_jpay'];
$diff = $diff+$job['jinterval'];
$daysDiff = floor($diff/60/60/24);
$diff -= $daysDiff*60*60*24;
$hrsDiff = floor($diff/60/60);
$diff -= $hrsDiff*60*60;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;

$tdays=$daysDiff-1;
$thrs=23-$hrsDiff;
$tmins=59-$minsDiff;
$tsecs=59-$secsDiff;
$timer ="{$tdays} days, ".$thrs." hours, ".$tmins." minutes and ".$tsecs." seconds until you are able to collect your salary";
$time=$timer;
The evidenced bit is wrong. It should be $tdays=1-$daysDiff;. On the plus side, it is only a display problem; the real data is fine and you should be able to collect at the right time.
 
Last edited:

That explains why accolytes picked up their pay today. I'd theorized their was a seperate actual timer or that reaching double the time delivered the salary, just didn't have time to check the code. Thanks Zappo.
 

Wait, so should I be checking if I can collect even if it says I can't? My time is going down (seemingly appropriately), but it's still a lot more than it should be (i.e., more than 2 days for a 48-hour job).

Edit: Nope, tried collected at 2 days, 9 hours, blah blah blah, and it wouldn't let me. I do still have a 48-hour job.
 
Last edited:


Most likely, even if the days timer displayed is wrong, you will be able to collect your salary at the actual right time. Ie, 48 real hours after the last time.
 





Into the Woods

Remove ads

Top