[TWITCH] BF4 Stats

By Blood_Wolf89 on Apr 03, 2015

Do you want to have a command that people can type to display your stats (!bf4stats)? And in the same way, the command where they can share their stats (!bf4stats [username]).

Commands: !bf4stats & !bf4stats [username]

Changes to make for the script..
1.) Change "STREAMER_IGN" on line 4 to you in game name.
2.) Currently this is set up for PC but if you wish to change it to something else..

Edit line 6: " var %url = http://api.bf4stats.com/api/playerInfo?plat=pc&name= $+ %urlSafeuser"

Change pc to whatever you decide.

Platforms:
pc = PC platform
xbox = XBOX 360 console platform
ps3 = Playstation 3 console platform
xone = XBOX ONE console platform.
ps4 = Playstation 4 console platform.

on *:TEXT:*:#flakeofthenorth:{

  if ($strip($1) === !bf4stats) {
    var %user = $iif($2, $strip($2), STREAMER_IGN)
    var %urlSafeUser = $regsubex(%user, /[^a-z\d_-]/gi, % $+ $base($asc(\t), 10, 16, 2))
    var %url = http://api.bf4stats.com/api/playerInfo?plat=pc&name= $+ %urlSafeuser

    JSONOpen -ud bf4stat %url

    var %name = $JSON(bf4stat, player, name)
    var %rank = $JSON(bf4stat, player, rank, nr)
    var %score = $JSON(bf4stat, player, score)

    var %kills = $JSON(bf4stat, stats, kills)
    var %deaths = $JSON(bf4stat, stats, deaths)
    var %kdRatio = $round($calc(%kills / %deaths), 2)

    var %wins = $JSON(bf4stat, stats, numWins)
    var %losses = $JSON(bf4stat, stats, numLosses)
    var %wlRatio = $round($calc(%wins / %losses), 2)

    var %played = $duration($JSON(bf4stat, stats, timePlayed))

    var %hits = $JSON(bf4stat, stats, shotsHit)
    var %misses = $JSON(bf4stat, stats, shotsFired)
    var %accuracy = $round($calc(%hits / %misses * 100),2) $+ %

    if ((%user == %name) || (%urlSafeuser == %name)) { msg # [BF4Stats]:  %name $+ 's Battlefield 4(PC) Stats $(|,0) Rank: %rank $(|,0) Kills: %kills $(|,0) K/D: %kdRatio $(|,0) W/L: %wlRatio $(|,0) Score: %score $(|,0) Time Played: %played $(|,0) Accuracy: %accuracy } 
    if ((%urlSafeuser !== %name)) {  msg # [BF4Stats]: Invalid Battlefield 4 Name. }

  }
}   

In order for this script to work, you must also use this JSON Parse made by SReject. To use it just past it after the script above.

REQUIRED:
JSON Parse: http://hawkee.com/snippet/10194/#c127159

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.