You are not logged in.

#1 15 Jan 2008 4:52 am

azzlack
Senior Member
From: Bergen, Norway
Registered: Jan 2008
Posts: 26
Website

BF2Rank - Example scripts

I thought I should just post the scripts I use on my website bobforum.eyecatch.no for users who do not know PHP.

Credits go to MadHatter for creating the script. I did only minor modifications.

  • Online status (NOTE: NOT ACCURATE):

    $last_online_date = date('d. F Y H:i', $bf2_player->stats['lbtl']);

    $difference = ((time() - strtotime($last_online_date))/60);
    //15 is the amount of minutes since last_online that you want as a treshold for showing if the player is online or not.
    if ($difference < 15) {
        $online_status = "Online";
    }
    else {
        $online_status = "Offline";
    }

    $file_contents = str_replace('<online_status>', $online_status, $file_contents);

    Just place the <online_status> tag where you want it in the index.tpl

  • Calculating time played (don't remember if this part was in there from before ):

    $time_played = $bf2_player->stats['time'];   
       
    //Counting time_played
    $days    = floor($time_played/60/60/24);
    $hours   = floor(($time_played-($days*60*60*24))/60/60);
    $minutes = floor(($time_played-($days*60*60*24)-($hours*60*60))/60);
    $total_time_played = "$days days $hours hours $minutes minutes";

    $file_contents = str_replace('<time_played>', $total_time_played, $file_contents);

    Just place the <time_played> tag where you want it in the index.tpl
  • Last edited by azzlack (15 Jan 2008 4:57 am)


    Web Developer and Designer.
    Currently studying for Bachelor of Computer Science degree ...

    Offline

     



    © 2003 - 2018 NullFX
    Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License