1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Time Display

Discussion in 'BF2Statistics discussion' started by stevie, Oct 2, 2007.

  1. stevie

    stevie New Member

    Can anyone tell me how to make the times display in just hours, minutes and seconds. No weeks or days.

    Thank you
     
  2. Thinner

    Thinner New Member

    Hi,

    you have to edit bf2stats.php.

    replace function sec2log with this code:

    function sec2log($seconds) {
    $secPerHour = 3600;
    $secPerMinute = 60;

    $h = floor( $seconds / $secPerHour );
    $m = floor( ($seconds % $secPerHour) / $secPerMinute );
    $s = floor( ($seconds % $secPerHour) % $secPerMinute );

    $m=sprintf("%02d",$m);
    $s=sprintf("%02d",$s);

    return "{$h}h {$m}m {$s}s";
     
  3. stevie

    stevie New Member

    Thanks man
    I had played with that bit of code already, but I must have missed something. I'll give it another try later. Another thing I meant to ask before but forgot was if anyone could tell me how to make the kill/death ratios display as x:1 all the time instead of the crazy numbers it does.

    thanks again everyone
     
  4. Thinner

    Thinner New Member

    k/d-Ratio:

    assume 32 kills, 6 deaths
    this will be a ratio of 32:6 or shortened 16:3
    do you really want to display as 5.33:1 ?
    That's silly, isn't it? I would prefer 5.33 instead.

    I did it this way:
    added a function to ASP/getplayerinfo.aspx:

    function ratio($x, $y) {
    if ($y != 0) {
    return sprintf("%.2f", $x / $y);
    }
    else {
    return '0.00';
    }
    }

    If you prefer another output format, you can simply change return lines.

    for weapon ratio I replaced lines like this:

    if ($roww['deaths0'] != 0)
    {
    $den = denominator($roww['kills0'], $roww['deaths0']);
    $w0 = $roww['kills0']/$den . ':' . $roww['deaths0']/$den;
    }
    else {$w0 = $roww['kills0'] . ':0';}

    with this line:

    $w0 = ratio($roww['kills0'], $roww['deaths0']);

    same for vehicle and kit ratio.
    $v0 = ratio($rowv['kills0'], $rowv['deaths0']);
    ...
    $k0 = ratio($rowk['kills0'], $rowk['deaths0']);
    ...
     
  5. stevie

    stevie New Member

    Hey Thinner
    Thanks for taking the time to try to explain this to me. I haven't had much time to work on this project and an only just now trying to implement your ideas. I pasted the code

    function ratio($x, $y) {
    if ($y != 0) {
    return sprintf("%.2f", $x / $y);
    }
    else {
    return '0.00';
    }
    }

    into my getplayerinfo.aspx as you instructed, but got no different results. My kill/death ratios still display like:
    3465:231
    I should have mentioned that this is all greek to me and I'm probably going to need step by step instructions to get this done. If anyone has time to do that for me it would be appreciated.