Battlefield: Bad Company 2 Statistics Grabber (v1.0)

By IllogicTC on May 29, 2011

This script grabs your statistics for the game Battlefield: Bad Company 2 from the website bfbcs.com. You can grab stats for any of the three platforms that BFBC2 is on. To open it after loading, use the command /bc2stats.

To use it, start by adding your tag to the friends list on the right, then select it, make sure you have the proper platform selected, and hit Get Stats. After the download and processing is complete, you may sift through advanced statistics and track your progress on the game. The first time you run a stat query, the info bar on the left may announce "outdated stats." If this is the case, just select Get Stats again to be sure they are the most recent stats available (it may say it a second time, this would be a false alarm).

The percentages next to kill tallies is the percentage of your total kills you have achieved via that particular weapon/gadget. The percentages next to scores reflects its contribution toward your overall score.

VERSION 1.1: Added some tangential statistics for those of you who like all sorts of detail. New additions:
Changed the stats freshness indicator. It now tells if you have fresh stats, relatively fresh stats, or need to refresh. If you need to refresh, it will tell you your position in the queue and the server-estimated time until an update occurs.
Added some spacing the General Tab. Makes everything easier to read.
Added Miscellaneous stats at the bottom of the General Tab. Shows total shots fired from WEAPONS, total shots hit from WEAPONS, total headshots (from ALL equipment), and total distance driven in vehicles.
Added a percentage to the weapons, gadgets, and vehicles Time Used to show distribution of use compared to the overall time played.
Added a percentage to the headshots stat, showing how what percentage of kills were headshots.
Added an average speed in the Vehicles tab, displayed in km/h.

NOTE: I have noticed when testing PS3 tags that it is grumpy about working. I am unsure if this is due to the PlayStation Network outage, and will continue to test it. Also, you may notice that people you have acquired Dogtags from in the past day or two may not show up in the list. That is an issue with the site.

;Battlefield: Bad Company 2 Statistics
;By IllogicTC
;Data Filter help by jaytea
;version 1.1

alias bf_sock {
  set %bffield all,dogtags
  set %bfplayer $replace($1-,$chr(32),$+($chr(37),20))
  set %bfplat $did(bfbcstats,23).seltext
  sockopen bfsock api.bfbcs.com 80
  write -c $scriptdirbfstat.txt
}

on *:sockopen:bfsock: {
  sockwrite -n bfsock GET $+(/api/,%bfplat,?players=,%bfplayer,&fields=,%bffield,&dev=2) HTTP/1.0
  sockwrite -n bfsock Host: api.bfbcs.com
  sockwrite -n bfsock Connection: close
  sockwrite -n bfsock
  .fopen stats_setup $scriptdirbfstat.txt
}

on *:sockread:bfsock: {
  if ($sockerr) {
    echo -s Socket Error. Halting...
    return
  }
  if (!$sock($sockname).mark) {
    var %data
    sockread %data
    if (!%data) sockmark $sockname 1
  }
  else {
    while ($sock(bfsock).rq) {
      sockread &bfsocktext
      .fwrite -b stats_setup &bfsocktext
    }
  }
}

on *:sockclose:bfsock:{
  .fclose stats_setup
  filter -ffc $qt($scriptdirbfstat.txt) $qt($scriptdirbfstat.txt)
  did -r bfbcstats 3,5,7,8,11,12,22
  did -ra bfbcstats 2 $gettok($read($scriptdirbfstat.txt,s,p.name),2,61)
  did -ra bfbcstats 15 Processing...
  bf_stat_fill
  did -ra bfbcstats 15 Complete.
  .timerbf10 1 5 did -r bfbcstats 15
  .timerbf11 1 5 did -e bfbcstats 15
}

dialog bfbcstats {
  title "Bad Company 2 Stats"
  size -1 -1 257 122
  option dbu
  tab "Overall", 1, 2 1 158 117
  edit "", 2, 6 20 150 10, tab 1 read
  list 3, 6 31 150 84, tab 1 size vsbar
  tab "Kits", 4
  list 5, 6 18 150 97, tab 4 size vsbar
  tab "Weapons/Gadgets", 6
  list 8, 6 18 150 97, tab 6 size vsbar
  tab "Vehicles", 9
  list 11, 6 18 150 97, tab 9 size vsbar
  tab "Insignias/Pins", 13
  list 12, 6 18 150 97, tab 13 size
  tab "Dogtags", 20
  list 22, 6 18 150 97, tab 20 size vsbar
  box "Friends List", 14, 164 1 90 118
  edit "Enter Name...", 15, 167 10 50 11, autohs
  button "Add", 16, 168 22 37 9
  button "Get Stats", 17, 213 22 37 9
  list 18, 167 35 84 72, size vsbar
  button "Remove", 19, 189 108 37 9
  combo 23, 220 10 30 36, size drop
  list 7, 180 110 1 1, hide sort size vsbar
}

alias bc2stats {
  dialog -m bfbcstats bfbcstats
}

alias bf_stat_fill {
  .fopen stats $scriptdirbfstat.txt
  var %t $statnext
  if (phperror isin %t) {
    did -ra bfbcstats 2 ERROR: Make sure you have the right name.
    .fclose stats
    return
  }
  elseif ($len(%t) > 0) did -ra bfbcstats 2 %t
  else {
    did -ra bfbcstats 2 ERROR: Possible Server Overload. Please Try Again Later.
    .fclose stats
    return
  }
  set %bf_hold_shotfire 0
  set %bf_hold_shothit 0
  set %bf_hold_headshot 0
  set %bf_hold_driven
  did -r bfbcstats 3
  .fseek -l stats 3
  did -ra bfbcstats 15 Updt. General
  did -a bfbcstats 3 Rank: $statnext $+($chr(91),$statnext,$chr(93))
  did -a bfbcstats 3 Veteran Status: $statnext
  var %bf_hold_totscore $statnext
  did -a bfbcstats 3 Total Score: %bf_hold_totscore
  did -a bfbcstats 3 $chr(32)
  did -a bfbcstats 3 Skill Level: $statnext
  var %x $statnext
  set %bf_hold_total_kills %x
  var %y $statnext
  did -a bfbcstats 3 Kills: %x
  did -a bfbcstats 3 Deaths: %y
  did -a bfbcstats 3 K/D Ratio: $round($calc(%x / %y),3)
  did -a bfbcstats 3 $chr(32)
  set %bf_hold_timeplayed $statnext
  did -a bfbcstats 3 Time Played: $duration($int(%bf_hold_timeplayed),3)
  did -a bfbcstats 3 Score Per Minute: $round($calc(%bf_hold_totscore / (%bf_hold_timeplayed / 60)),2)
  did -a bfbcstats 3 Kills Per Minute: $round($calc(%x / (%bf_hold_timeplayed / 60)),3)
  var %bf_dpm $round($calc(%y / (%bf_hold_timeplayed / 60)),3)
  var %bf_dpm_precision $calc(%y / (%bf_hold_timeplayed / 60))
  did -a bfbcstats 3 Deaths Per Minute: %bf_dpm
  var %bf_dpm_secs $calc((1 / %bf_dpm_precision) * 60)
  did -a bfbcstats 3 Life Expectancy: $duration($int(%bf_dpm_secs),3) $+ $chr(46) $+ $left($gettok(%bf_dpm_secs,2,46),3)
  did -a bfbcstats 3 $chr(32)
  .fseek -l stats 13
  var %x $statnext
  if ($gettok(%x,1,84) != $asctime($ctime,yyyy-mm-dd)) {
    .fseek -l stats $calc($lines($scriptdirbfstat.txt) - 1)
    var %a1 $statnext
    var %a2 $statnext
    if (within !isin %a2) did -a bfbcstats 2 -- Outdated. Queue: %a1 $chr(40) $+ %a2 wait $+ $chr(41)
    else did -a bfbcstats 2 -- Fairly Recent Stats. Can update in 12 hours.
  }
  else did -a bfbcstats 2 -- Recent Stats. Can update every 12 hours.
  .fseek -l stats 17
  did -a bfbcstats 3 General Accuracy: $+($calc($statnext * 100),$chr(37))
  .fseek -l stats 19
  did -a bfbcstats 3 Dogtags Taken: $statnext
  .fseek -l stats 22
  var %bf_hold_playedgames $statnext
  did -a bfbcstats 3 Gold Edition: $iif($statnext == 1,Yes,No)
  did -a bfbcstats 3 $chr(32)
  var %bf_hold_losses $statnext
  var %bf_hold_assault $statnext
  var %bf_hold_award $statnext
  var %bf_hold_bonus $statnext
  var %bf_hold_engineer $statnext
  did -a bfbcstats 3 General Score: $statnext
  var %bf_hold_objective $statnext
  var %bf_hold_recon $statnext
  var %bf_hold_squad $statnext
  var %bf_hold_medic $statnext
  did -a bfbcstats 3 Assault Score: %bf_hold_assault $+($chr(40),$round($calc((%bf_hold_assault / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 Engineer Score: %bf_hold_engineer $+($chr(40),$round($calc((%bf_hold_engineer / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 Medic Score: %bf_hold_medic $+($chr(40),$round($calc((%bf_hold_medic / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 Recon Score: %bf_hold_recon $+($chr(40),$round($calc((%bf_hold_recon / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 Award Score: %bf_hold_award $+($chr(40),$round($calc((%bf_hold_award / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 Bonus Score: %bf_hold_bonus
  did -a bfbcstats 3 Objective Score: %bf_hold_objective
  did -a bfbcstats 3 Squad Score: %bf_hold_squad
  did -a bfbcstats 3 Team Score: $statnext
  var %bf_hold_vehicle_score $statnext
  did -a bfbcstats 3 Vehicle Score: %bf_hold_vehicle_score $+($chr(40),$round($calc((%bf_hold_vehicle_score / %bf_hold_totscore) * 100),2),$chr(37),$chr(41))
  did -a bfbcstats 3 $chr(32)
  .fseek -l stats 42
  did -i bfbcstats 3 8 Teamkills: $statnext
  .fseek -l stats 44
  var %x $statnext
  var %y %bf_hold_losses
  did -a bfbcstats 3 Wins: %x
  did -a bfbcstats 3 Losses: %y
  did -a bfbcstats 3 Win/Loss Ratio: $round($calc(%x / %y),2)
  .fseek -l stats 46
  did -ra bfbcstats 15 Updt. Kits
  var %h 0
  var %i 4
  while (%h < %i) {
    inc %h
    did -a bfbcstats 5 $statnext
    did -a bfbcstats 5 Score: $statnext
    var %x $statnext
    var %y $statnext
    did -a bfbcstats 5 Kills: %x
    did -a bfbcstats 5 Deaths: %y
    did -a bfbcstats 5 K/D Ratio: $round($calc(%x / %y),3)
    did -a bfbcstats 5 $chr(32)
  }
  .fseek -l stats 63
  var %x $statnext
  var %y $statnext
  did -a bfbcstats 3 Games Played: %bf_hold_playedgames
  did -a bfbcstats 3 Attacking Losses: %x
  did -a bfbcstats 3 Attacking Wins: %y
  did -a bfbcstats 3 Attacking W/L Ratio: $round($calc(%y / %x),2)
  .fseek -l stats 66
  var %x $statnext
  var %y $statnext
  did -a bfbcstats 3 Defending Losses: %x
  did -a bfbcstats 3 Defending Wins: %y
  did -a bfbcstats 3 Defending W/L Ratio: $round($calc(%y / %x),2)
  did -ra bfbcstats 15 Updt. Equipment
  did -a bfbcstats 8 ---Assault Weapons---
  var %h 0
  var %i 7
  while (%h < %i) {
    inc %h
    bf_ws
  }
  .fseek -l stats 1018
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Assault Gadgets---
  bf_gs
  .fseek -l stats 1034
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  var %skip $statnext
  var %skip $statnext
  var %bf_kill $statnext
  did -a bfbcstats 8 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  var %y $statnext
  var %x $statnext
  did -a bfbcstats 8 Shots Fired: %y
  did -a bfbcstats 8 Shots Hit: %x
  did -a bfbcstats 8 Accuracy: $+($round($calc((%x / %y) * 100),2),$chr(37))
  did -a bfbcstats 8 Headshots: $statnext
  did -a bfbcstats 8 Time Used: $duration($int($statnext),3)
  bf_gs
  .fseek -l stats 1030
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1033
  did -a bfbcstats 8 Resupplies: $statnext
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Engineer Weapons---
  .fseek -l stats 138
  var %h 0
  var %i 7
  while (%h < %i) {
    inc %h
    bf_ws
  }
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Engineer Gadgets---
  .fseek -l stats 1054
  bf_gs
  .fseek -l stats 1087
  bf_gs
  bf_gs
  .fseek -l stats 1075
  bf_gs
  .fseek -l stats 1066
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1069
  did -a bfbcstats 8 Repairs: $statnext
  var %bf_kill $statnext
  did -a bfbcstats 8 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  .fseek -l stats 1073
  did -a bfbcstats 8 Headshots: $statnext
  did -a bfbcstats 8 Time Used: $duration($int($statnext),3)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Medic Weapons---
  .fseek -l stats 208
  var %h 0
  var %i 7
  while (%h < %i) {
    inc %h
    bf_ws
  }
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Medic Gadgets---
  .fseek -l stats 1111
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1114
  did -a bfbcstats 8 Heals: $statnext
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1118
  did -a bfbcstats 8 Revives: $statnext
  var %bf_kill $statnext
  did -a bfbcstats 8 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  .fseek -l stats 1122
  did -a bfbcstats 8 Headshots: $statnext
  did -a bfbcstats 8 Time Used: $duration($int($statnext),3)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Recon Weapons---
  .fseek -l stats 278
  bf_ws
  .fseek -l stats 478
  bf_ws
  .fseek -l stats 288
  var %h 0
  var %i 5
  while (%h < %i) {
    inc %h
    bf_ws
  }
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Recon Gadgets---
  .fseek -l stats 1124
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1128
  did -a bfbcstats 8 Sensors Thrown: $statnext
  did -a bfbcstats 8 Spots: $statnext
  .fseek -l stats 1131
  did -a bfbcstats 8 Time Used: $duration($int($statnext),3)
  bf_gs
  bf_gs
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---All Kits Weapons---
  .fseek -l stats 338
  bf_ws
  .fseek -l stats 368
  bf_ws
  bf_ws
  .fseek -l stats 398
  bf_ws
  bf_ws
  .fseek -l stats 348
  bf_ws
  bf_ws
  .fseek -l stats 418
  bf_ws
  .fseek -l stats 448
  bf_ws
  .fseek -l stats 388
  bf_ws
  .fseek -l stats 428
  bf_ws
  bf_ws
  .fseek -l stats 458
  bf_ws
  .fseek -l stats 488
  var %h 0
  var %i 4
  while (%h < %i) {
    inc %h
    bf_ws
  }
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---All Kits Gadgets---
  .fseek -l stats 1156
  bf_gs
  bf_gs
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  .fseek -l stats 1184
  did -a bfbcstats 8 Shots Fired: $statnext
  .fseek -l stats 1187
  did -a bfbcstats 8 Time Used: $duration($int($statnext),3)
  .fseek -l stats 529
  var %bf_kill $statnext
  did -i bfbcstats 3 8 Demolition Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  .fseek -l stats 534
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 ---Vietnam Weapons---
  var %h 0
  var %i 14
  while (%h < %i) {
    inc %h
    bf_ws
  }
  did -ra bfbcstats 15 Updt. Vehicles
  did -a bfbcstats 11 ---Light Vehicles---
  var %h 0
  var %i 9
  while (%h < %i) {
    inc %h
    bf_ps
  }
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 ---Heavy Vehicles---
  var %h 0
  var %i 8
  while (%h < %i) {
    inc %h
    bf_ps
  }
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 ---Water Vehicles---
  var %h 0
  var %i 3
  while (%h < %i) {
    inc %h
    bf_ps
  }
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 ---Air Vehicles---
  var %h 0
  var %i 6
  while (%h < %i) {
    inc %h
    bf_ps
  }
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 ---Stationary Weapons---
  var %h 0
  var %i 8
  while (%h < %i) {
    inc %h
    bf_ss
  }
  did -i bfbcstats 11 1 ---Vehicle Stars---
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -i bfbcstats 11 2 Light Vehicle: Platinum Star
  elseif (%c > 0) did -i bfbcstats 11 2 Light Vehicle: Gold Star %c
  elseif (%b > 0) did -i bfbcstats 11 2 Light Vehicle: Silver Star
  elseif (%a > 0) did -i bfbcstats 11 2 Light Vehicle: Bronze Star
  else did -i bfbcstats 11 2 Light Vehicle: No Stars
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -i bfbcstats 11 3 Heavy Vehicle: Platinum Star
  elseif (%c > 0) did -i bfbcstats 11 3 Heavy Vehicle: Gold Star %c
  elseif (%b > 0) did -i bfbcstats 11 3 Heavy Vehicle: Silver Star
  elseif (%a > 0) did -i bfbcstats 11 3 Heavy Vehicle: Bronze Star
  else did -i bfbcstats 11 3 Heavy Vehicle: No Stars
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -i bfbcstats 11 4 Water Vehicle: Platinum Star
  elseif (%c > 0) did -i bfbcstats 11 4 Water Vehicle: Gold Star %c
  elseif (%b > 0) did -i bfbcstats 11 4 Water Vehicle: Silver Star
  elseif (%a > 0) did -i bfbcstats 11 4 Water Vehicle: Bronze Star
  else did -i bfbcstats 11 4 Water Vehicle: No Stars
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -i bfbcstats 11 5 Air Vehicle: Platinum Star
  elseif (%c > 0) did -i bfbcstats 11 5 Air Vehicle: Gold Star %c
  elseif (%b > 0) did -i bfbcstats 11 5 Air Vehicle: Silver Star
  elseif (%a > 0) did -i bfbcstats 11 5 Air Vehicle: Bronze Star
  else did -i bfbcstats 11 5 Air Vehicle: No Stars
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -i bfbcstats 11 6 Stationary Weapons: Platinum Star
  elseif (%c > 0) did -i bfbcstats 11 6 Stationary Weapons: Gold Star %c
  elseif (%b > 0) did -i bfbcstats 11 6 Stationary Weapons: Silver Star
  elseif (%a > 0) did -i bfbcstats 11 6 Stationary Weapons: Bronze Star
  else did -i bfbcstats 11 6 Stationary Weapons: No Stars
  did -i bfbcstats 11 7 $chr(32)
  did -i bfbcstats 11 8 $chr(32)
  .fseek -l stats 1620
  var %h 0
  var %i 48
  var %tot
  did -ra bfbcstats 15 Updt. Awards
  did -a bfbcstats 12 ---Pins---
  while (%h < %i) {
    inc %h
    did -a bfbcstats 12 $chr(32)
    did -a bfbcstats 12 Pin Name: $statnext
    var %x $statnext
    inc %tot %x
    did -a bfbcstats 12 Pin Count: %x
  }
  did -a bfbcstats 12 $chr(32)
  did -a bfbcstats 12 Total Pins: %tot
  did -a bfbcstats 12 $chr(32)
  did -a bfbcstats 12 $chr(32)
  did -a bfbcstats 12 ---Insignias---
  .fseek -l stats 1374
  var %x 0
  var %y 245
  while (%x < %y) {
    inc %x
    var %r $signext
    if ($gettok($gettok(%r,1,61),4,46) != name) && ($gettok($gettok(%r,1,61),4,46) != count) continue
    else {
      if ($gettok($gettok(%r,1,61),4,46) = name) {
        did -a bfbcstats 12 $chr(32)
        did -a bfbcstats 12 $gettok(%r,2,61)
      }
      elseif ($gettok($gettok(%r,1,61),4,46) = count) {
        if ($gettok(%r,2,61) = 1) did -a bfbcstats 12 ACQUIRED
        else did -a bfbcstats 12 $+($chr(62),MISSING,$chr(60))
      }
    }
  }
  did -ra bfbcstats 15 Updt. Dogtags
  .fseek -l stats 1949
  did -a bfbcstats 22 Total Dogtags: $statnext
  var %y $statnext
  did -a bfbcstats 22 Unique Dogtats: %y
  did -a bfbcstats 22 Bronze Tags: $statnext
  did -a bfbcstats 22 Silver Tags: $statnext
  did -a bfbcstats 22 Gold Tags: $statnext
  did -a bfbcstats 22 $chr(32)
  .fseek -l stats 1957
  var %x 0
  while (%x < %y) {
    inc %x
    var %a $statnext
    var %b $statnext
    var %c $statnext
    var %d $statnext
    did -a bfbcstats 7 %a - $+(%b,$chr(47),%c,$chr(47),%d)
  }
  did -a bfbcstats 3 $chr(32)
  did -a bfbcstats 3 --Miscellaneous--
  did -a bfbcstats 3 Shots Fired: %bf_hold_shotfire
  did -a bfbcstats 3 Shots Hit: %bf_hold_shothit
  did -a bfbcstats 3 Overall Gun Accuracy: $round($calc((%bf_hold_shothit / %bf_hold_shotfire) * 100),3) $+ $chr(37)
  did -a bfbcstats 3 Total Headshots: %bf_hold_headshot
  did -a bfbcstats 3 Total Distance Driven: $round($calc(%bf_hold_driven / 1000),1) km
  filter -if bfbcstats 7 $scriptdirbftags.txt
  filter -fo $scriptdirbftags.txt bfbcstats 22
  .remove $scriptdirbftags.txt
  .close -@ @BFFilter
  .fclose stats
  unset %bf_hold_*
}

alias -l statnext { return $gettok($fread(stats),2,61) }
alias -l signext { return $fread(stats) }

alias -l bf_ws {
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  var %bf_kill $statnext
  did -a bfbcstats 8 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  var %y $statnext
  var %x $statnext
  inc %bf_hold_shotfire %y
  inc %bf_hold_shothit %x
  did -a bfbcstats 8 Shots Fired: %y
  did -a bfbcstats 8 Shots Hit: %x
  did -a bfbcstats 8 Accuracy: $+($round($calc((%x / %y) * 100),2),$chr(37))
  var %bf_time $statnext
  did -a bfbcstats 8 Time Used: $duration($int(%bf_time),3) $chr(40) $+ $round($calc((%bf_time / %bf_hold_timeplayed) * 100),3) $+ $chr(37) $+ $chr(41)
  var %ws_hs $statnext
  inc %bf_hold_headshot %ws_hs
  did -a bfbcstats 8 Headshots: %ws_hs $chr(40) $+ $round($calc((%ws_hs / %bf_kill) * 100),2) $+ $chr(37) $+ $chr(41)
  did -a bfbcstats 8 Kills Per Hour: $round($calc(%bf_kill / (%bf_time / 3600)),2)
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -a bfbcstats 8 Current Rank: Platinum Star
  elseif (%c > 0) did -a bfbcstats 8 Current Rank: Gold Star %c
  elseif (%b > 0) did -a bfbcstats 8 Current Rank: Silver Star
  elseif (%a > 0) did -a bfbcstats 8 Current Rank: Bronze Star
  else did -a bfbcstats 8 Current Rank: No Stars
}

alias -l bf_ps {
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $statnext
  var %skip $statnext
  var %bf_kill $statnext
  did -a bfbcstats 11 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  did -a bfbcstats 11 Road Kills: $statnext
  var %bf_time $statnext
  did -a bfbcstats 11 Time Used: $duration($int(%bf_time),3) $chr(40) $+ $round($calc((%bf_time / %bf_hold_timeplayed) * 100),3) $+ $chr(37) $+ $chr(41)
  did -a bfbcstats 11 Kills Per Hour: $round($calc(%bf_kill / (%bf_time / 3600)),2)
  var %bf_driven $statnext
  did -a bfbcstats 11 Distance Driven: %bf_driven
  did -a bfbcstats 11 Average Speed: $round($calc((%bf_driven / 1000) / ($int(%bf_time) / 3600)),2) km/h
  inc %bf_hold_driven %bf_driven
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -a bfbcstats 11 Current Rank: Platinum Star
  elseif (%c > 0) did -a bfbcstats 11 Current Rank: Gold Star %c
  elseif (%b > 0) did -a bfbcstats 11 Current Rank: Silver Star
  elseif (%a > 0) did -a bfbcstats 11 Current Rank: Bronze Star
  else did -a bfbcstats 11 Current Rank: No Stars
}

alias -l bf_ss {
  did -a bfbcstats 11 $chr(32)
  did -a bfbcstats 11 $statnext
  var %skip $statnext
  var %bf_kill $statnext
  did -a bfbcstats 11 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  var %bf_time $statnext
  did -a bfbcstats 11 Time Used: $duration($int(%bf_time),3) $chr(40) $+ $round($calc((%bf_time / %bf_hold_timeplayed) * 100),3) $+ $chr(37) $+ $chr(41)
  did -a bfbcstats 11 Kills Per Hour: $round($calc(%bf_kill / (%bf_time / 3600)),2)
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -a bfbcstats 11 Current Rank: Platinum Star
  elseif (%c > 0) did -a bfbcstats 11 Current Rank: Gold Star %c
  elseif (%b > 0) did -a bfbcstats 11 Current Rank: Silver Star
  elseif (%a > 0) did -a bfbcstats 11 Current Rank: Bronze Star
  else did -a bfbcstats 11 Current Rank: No Stars
}

alias -l bf_gs {
  did -a bfbcstats 8 $chr(32)
  did -a bfbcstats 8 $statnext
  var %skip $statnext
  var %skip $statnext
  var %bf_kill $statnext
  did -a bfbcstats 8 Kills: %bf_kill $+($chr(40),$round($calc((%bf_kill / %bf_hold_total_kills) * 100),3),$chr(37),$chr(41))
  var %y $statnext
  var %x $statnext
  did -a bfbcstats 8 Shots Fired: %y
  did -a bfbcstats 8 Shots Hit: %x
  did -a bfbcstats 8 Accuracy: $+($round($calc((%x / %y) * 100),2),$chr(37))
  var %gs_hs $statnext
  inc %bf_hold_headshot %gs_hs
  did -a bfbcstats 8 Headshots: %ws_hs $chr(40) $+ $round($calc((%gs_hs / %bf_kill) * 100),2) $+ $chr(37) $+ $chr(41)
  var %a3 $statnext
  did -a bfbcstats 8 Time Used: $duration($int(%a3),3) $chr(40) $+ $round($calc((%a3 / %bf_hold_timeplayed) * 100),3) $+ $chr(37) $+ $chr(41)
  var %a $statnext
  var %b $statnext
  var %c $statnext
  var %d $statnext
  if (%d > 0) did -a bfbcstats 8 Current Rank: Platinum Star
  elseif (%c > 0) did -a bfbcstats 8 Current Rank: Gold Star %c
  elseif (%b > 0) did -a bfbcstats 8 Current Rank: Silver Star
  elseif (%a > 0) did -a bfbcstats 8 Current Rank: Bronze Star
  else did -a bfbcstats 8 Current Rank: No Stars
}

on *:dialog:bfbcstats:*:*: {
  if ($devent == init) {
    didtok $dname 18 44 %bfbc.friends
    did -a $dname 23 360
    did -a $dname 23 PC
    did -a $dname 23 PS3
    if (%bfbc.platform > 0) {
      if (%bfbc.platform == 1) did -c $dname 23 1
      elseif (%bfbc.platform == 2) did -c $dname 23 2
      else did -c $dname 23 3
    }
  }
  if ($devent == sclick) {
    if ($did == 15) did -r $did
    if ($did == 16) && ($len($did($dname,15)) > 0) && ($findtok(%bfbc.friends,$did($dname,15),1,44) == $null) {
      did -a $dname 18 $did($dname,15)
      set %bfbc.friends $addtok(%bfbc.friends,$did($dname,15),44)
    }
    if ($did == 17) && ($did($dname,18).sel > 0) {
      bf_sock $did($dname,18).seltext
      did -b $dname 15
      did -ra $dname 15 Downloading...
    }
    if ($did == 19) && ($did($dname,18).sel > 0) {
      set %bfbc.friends $remtok(%bfbc.friends,$did($dname,18).seltext,44)
      did -d $dname 18 $did($dname,18).sel
    }
    if ($did == 23) set %bfbc.platform $did($dname,23).sel 
  }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.