Code (javascript): ({ serverStartUp : function() { scriptChecks = 0; this.init() ; this.loadStatsFromFile() ; } , init : function() { if (typeof(stats) == "undefined" ) stats = []; if (typeof(totalUsage) == "undefined" ) totalUsage = []; if (typeof(scriptChecks) == "undefined" ) scriptChecks += 1; PokeStat = function (poke) { this.poke = poke; this.totalUsage = 0; this.moves = []; this.addMoveSet = function(move1,move2,move3,move4) { this.totalUsage += 1; var parmoves = new Array(move1,move2,move3,move4) ; for (var i = 0; i < 4; i += 1) { if (parmoves[i] == 0) continue; if (typeof(this.moves[parmoves[i]]) == "undefined" ) this.moves[parmoves[i]] = 0; this.moves[parmoves[i]] += 1; } } } saveStatsPeriodically = function(version) { if (version != scriptChecks) return; this.saveStatsToFile() ; //save every two hours sys.callLater("saveStatsPeriodically("+version+" )", 7200) ; } } , afterNewMessage : function (message) { if (message == "Script Check: OK" ) { sys.sendAll("ScriptBot: Scripts were updated!" ) ; this.init() ; } } , beforeBattleStarted : function(src, dest,clauses) { [I]/* Check if this is a regular battle */[/I] if (sys.tier(src) == sys.tier(dest) && clauses[7] == 0) { [I]/* save stats.. */[/I] var tier = sys.tier(src) ; if (typeof(stats[tier]) == "undefined" ) { stats[tier] = []; } if (typeof(totalUsage[tier]) == "undefined" ) { totalUsage[tier] = 0; } this.saveStats(src,tier) ; this.saveStats(dest,tier) ; } } , saveStats : function (id, tier) { totalUsage[tier] += 1; for (var i = 0; i < 6; i+=1) { var poke = sys.teamPoke(id, i) ; if (poke == 0) continue; if (typeof(stats[tier][poke]) == "undefined" ) stats[tier][poke] = new PokeStat(poke) ; stats[tier][poke].addMoveSet(sys.teamPokeMove(id,i,0), sys.teamPokeMove(id,i,1), sys.teamPokeMove(id,i,2), sys.teamPokeMove(id,i,3)) ; } } , saveStatsToFile : function () { sys.writeToFile("stats.txt", "" ) ; var write = function(string) { sys.appendToFile("stats.txt", string+"\n" ) ; }; write ("/!\\ Tier Usage Stats! /!\\" ) ; for (tier in stats) { write("\n\n=== Tier: " + tier + " ===" ) ; write("--Total Usage: " + totalUsage[tier] + "--" ) ; for (pokemon in stats[tier]) { var poke = stats[tier][pokemon] write("*Pokemon " + sys.pokemon(pokemon) + ": " + poke.totalUsage + "*" ) ; for (move in poke.moves) { write(sys.move(move) + ": " + poke.moves[move]) ; } write("" ) ; } } } , loadStatsFromFile : function () { var loadedStats = sys.getFileContent("stats.txt" ).split("\n" ) ; print("Size: "+loadedStats.length) ; totalUsage = []; stats = []; var tier = ""; var poke = 0; for (x in loadedStats) { line = loadedStats[x]; if (line.length == 0) continue; if (line.substr(0,3) == "===" ) { //Tier line tier = line.substr(10, line.length-14) ; totalUsage[tier] = 0; stats[tier] = []; continue; } if (line.substr(0,2) == "--" ) { //Total usage line totalUsage[tier] = line.substr(15, line.length-17) * 1; continue; } if (line.charAt(0) == "*" ) { //New pokémon! var i = line.indexOf(':') ; if (i ==-1) continue; poke = sys.pokeNum(line.substring(9, i)) ; stats[tier][poke] = new PokeStat(poke) ; stats[tier][poke].totalUsage = line.substring(i+2, line.length - 1) * 1 ; continue; } //Move! var i = line.indexOf(':') ; if (i ==-1) continue; var move = sys.moveNum(line.substring(0, i)) ; if (move != 0) { stats[tier][poke].moves[move] = line.substr(i+2) * 1; } } } , beforeChatMessage: function(src, message) { if ((message[0] == '/' || message[0] == '!') && message.length > 1) { print("Command -- " + sys.name(src) + ": " + message) ; sys.stopEvent() ; var command; var commandData; var pos = message.indexOf(' ') ; if (pos != -1) { command = message.substring(1, pos).toLowerCase() ; commandData = message.substr(pos+1) ; } else { command = message.substr(1).toLowerCase() ; } var tar = sys.id(commandData) ; if (command == "commands" || command == "command" ) { sys.sendMessage(src, "" ) ; sys.sendMessage(src, "*** Commands ***" ) ; sys.sendMessage(src, "/pokeStats [poke] [tier]: to see stats of the pokemon in the tier" ) ; sys.sendMessage(src, "/tierStats [poke] [tier]: to see stats of tier" ) ; sys.sendMessage(src, "/savestats: Save all tier usage stats to file. Very expensive!" ) ; sys.sendMessage(src, "/loadstats: Load all tier usage stats from file. Very expensive!" ) ; return; } if (command == "pokestats" ) { var pos = commandData.indexOf(' ') ; if (pos == -1) { return; } var poke = sys.pokeNum(commandData.substring(0, pos)) ; var tier = commandData.substr(pos+1) ; if (typeof(stats[tier]) == "undefined" ) { sys.sendMessage(src, "StatBot: The tier you entered ("+ tier+" ) doesn't exist in the db." ) ; return; } if (typeof(stats[tier][poke]) == "undefined" ) { sys.sendMessage(src, "StatBot: There's no records of pokemon " + poke + " for the tier "+ tier+ "." ) ; return; } sys.sendMessage(src, "" ) ; sys.sendMessage(src, "*** Pokemon " + sys.pokemon(poke) + " in tier " + tier + " ***" ) ; poke = stats[tier][poke]; sys.sendMessage(src, "StatBot: Usage percentage: " + Math.round(parseFloat(poke.totalUsage) * 10000 / totalUsage[tier])/100 + "%." ) ; sys.sendMessage(src, "StatBot: Moves: " ) ; for (move in poke.moves) { sys.sendMessage(src, sys.move(move) + ": " + Math.round(parseFloat(poke.moves[move]) * 10000 / poke.totalUsage)/100 + "%." ) ; } return; } if (command == "tierstats" ) { var tier = commandData; if (typeof(stats[tier]) == "undefined" ) { sys.sendMessage(src, "StatBot: The tier " + tier + " doesn't exist in the db." ) ; return; } sys.sendMessage(src, "" ) ; sys.sendMessage(src, "*** Tier " + tier + " ***" ) ; for (poke in stats[tier]) { sys.sendMessage(src, sys.pokemon(poke) + ": " + Math.round(stats[tier][poke].totalUsage * 10000 / parseFloat(totalUsage[tier]))/100 + "%." ) ; } return; } if (command == "savestats" ) { this.saveStatsToFile() ; sys.sendMessage(src, "StatBot: All stats were saved!" ) ; return; } if (command == "loadstats" ) { this.loadStatsFromFile() ; sys.sendMessage(src, "StatBot: Stats were loaded" ) ; return; } } } }) Results so far: [Secret]*** Tier OverUsed (5610 battles) *** Bulbasaur: 0.02%. Venusaur: 2.67%. Charizard: 3.76%. Blastoise: 0.82%. Pidgeot: 0.29%. Raticate: 0.05%. Arbok: 0.02%. Pikachu: 0.7%. Raichu: 0.75%. Sandslash: 0.23%. Nidoqueen: 0.12%. Nidoking: 0.37%. Clefairy: 0.62%. Clefable: 2.19%. Ninetales: 0.36%. Vileplume: 0.05%. Parasect: 0.14%. Venomoth: 0.14%. Dugtrio: 1.35%. Persian: 0.02%. Golduck: 0.21%. Primeape: 0.87%. Arcanine: 4.21%. Poliwrath: 0.34%. Alakazam: 4.53%. Machamp: 7.04%. Victreebel: 0.29%. Tentacruel: 3.46%. Golem: 0.12%. Rapidash: 0.46%. Slowbro: 1.37%. Magneton: 0.29%. Dodrio: 0.12%. Dewgong: 0.21%. Muk: 0.23%. Cloyster: 1.19%. Gengar: 19.79%. Onix: 0.14%. Hypno: 0.16%. Kingler: 0.34%. Electrode: 0.68%. Exeggutor: 0.32%. Marowak: 2.51%. Hitmonlee: 0.68%. Hitmonchan: 0.55%. Weezing: 0.34%. Chansey: 0.11%. Kangaskhan: 0.39%. Starmie: 11.76%. Mr. Mime: 0.07%. Scyther: 0.36%. Jynx: 0.04%. Magmar: 0.05%. Pinsir: 0.25%. Tauros: 0.11%. Magikarp: 0.34%. Gyarados: 17.49%. Lapras: 1.59%. Ditto: 0.09%. Eevee: 0.11%. Vaporeon: 7.45%. Jolteon: 6.38%. Flareon: 0.37%. Omastar: 0.39%. Kabutops: 1.23%. Aerodactyl: 5.35%. Snorlax: 9.63%. Articuno: 0.7%. Zapdos: 7.09%. Moltres: 0.11%. Dragonair: 0.52%. Dragonite: 8.88%. Meganium: 0.32%. Typhlosion: 2.83%. Croconaw: 0.11%. Feraligatr: 2.83%. Noctowl: 0.12%. Ariados: 0.04%. Crobat: 3.58%. Lanturn: 1.87%. Pichu: 0.02%. Cleffa: 0.34%. Xatu: 0.12%. Ampharos: 0.34%. Azumarill: 0.32%. Politoed: 0.39%. Jumpluff: 0.27%. Quagsire: 0.04%. Espeon: 1.48%. Umbreon: 3.08%. Murkrow: 0.11%. Slowking: 0.52%. Forretress: 4.51%. Dunsparce: 0.12%. Steelix: 1.34%. Snubbull: 0.11%. Qwilfish: 0.46%. Scizor: 28.7%. Shuckle: 0.7%. Heracross: 3.98%. Sneasel: 0.04%. Ursaring: 0.32%. Piloswine: 0.12%. Octillery: 0.68%. Delibird: 0.14%. Mantine: 0.48%. Skarmory: 10.7%. Houndoom: 1.82%. Kingdra: 6.63%. Donphan: 0.94%. Porygon2: 1.55%. Stantler: 0.02%. Smeargle: 5.12%. Hitmontop: 1.03%. Miltank: 1.03%. Blissey: 11.32%. Raikou: 1.03%. Entei: 0.02%. Suicune: 7.5%. Pupitar: 0.11%. Tyranitar: 22.51%. Celebi: 3.76%. Treecko: 0.04%. Sceptile: 2.44%. Blaziken: 2.07%. Swampert: 19.82%. Mightyena: 0.09%. Linoone: 0.02%. Ludicolo: 2.64%. Shiftry: 0.07%. Swellow: 0.45%. Pelipper: 0.02%. Gardevoir: 1.71%. Breloom: 8.16%. Slaking: 0.64%. Ninjask: 3.23%. Shedinja: 1.12%. Exploud: 0.45%. Hariyama: 0.61%. Mawile: 0.04%. Aggron: 0.3%. Meditite: 0.04%. Medicham: 0.89%. Plusle: 0.07%. Sharpedo: 0.23%. Wailord: 0.18%. Camerupt: 0.11%. Torkoal: 0.34%. Grumpig: 0.04%. Flygon: 7.34%. Cacturne: 0.93%. Altaria: 0.21%. Zangoose: 0.37%. Whiscash: 0.82%. Claydol: 0.64%. Cradily: 0.29%. Milotic: 3.55%. Kecleon: 0.05%. Banette: 0.05%. Duskull: 0.07%. Dusclops: 0.14%. Tropius: 0.02%. Absol: 1.98%. Wynaut: 0.09%. Glalie: 0.14%. Walrein: 2.16%. Huntail: 0.12%. Gorebyss: 0.18%. Relicanth: 0.18%. Salamence: 22.03%. Metagross: 19.09%. Regirock: 0.05%. Regice: 0.41%. Registeel: 0.78%. Latias: 10.91%. Groudon: 0.07%. Jirachi: 13.58%. Grotle: 0.02%. Torterra: 1.62%. Chimchar: 0.02%. Infernape: 16.02%. Empoleon: 5.29%. Staraptor: 2.12%. Luxray: 0.12%. Roserade: 3.76%. Rampardos: 0.91%. Bastiodon: 0.34%. Buizel: 0.02%. Floatzel: 0.5%. Cherrim: 0.02%. Gastrodon: 0.02%. Ambipom: 1.28%. Drifblim: 0.52%. Lopunny: 0.05%. Mismagius: 2.98%. Honchkrow: 1.19%. Purugly: 0.04%. Skuntank: 0.04%. Bronzong: 4.24%. Chatot: 0.02%. Spiritomb: 1.94%. Munchlax: 0.04%. Lucario: 13.1%. Hippowdon: 6.36%. Drapion: 0.55%. Toxicroak: 0.84%. Carnivine: 0.04%. Abomasnow: 4.71%. Weavile: 9.25%. Magnezone: 7.36%. Lickilicky: 0.27%. Rhyperior: 1.59%. Tangrowth: 0.21%. Electivire: 9.88%. Magmortar: 0.94%. Togekiss: 4.56%. Yanmega: 2.12%. Leafeon: 0.45%. Glaceon: 1.62%. Gliscor: 9.36%. Mamoswine: 3.07%. Porygon-Z: 8.29%. Gallade: 4.14%. Probopass: 0.25%. Dusknoir: 5.76%. Froslass: 2.75%. Rotom: 0.46%. Uxie: 1.52%. Mesprit: 0.12%. Azelf: 8.22%. Heatran: 17.24%. Regigigas: 0.36%. Cresselia: 3.71%. Phione: 0.37%. Shaymin: 0.78%. Rotom-C: 1.41%. Rotom-H: 8.45%. Rotom-F: 0.73%. Rotom-W: 0.5%. Rotom-S: 0.09%. Missingno: 0.18%.[/Secret] [Secret]*** Pokemon Gengar in tier OverUsed *** StatBot: Usage percentage: 19.76%. (1110 battles) StatBot: Moves: Brick Break: 0.09%. Confuse Ray: 2.43%. Counter: 0.9%. Curse: 0.81%. Dark Pulse: 3.42%. Destiny Bond: 21.26%. Disable: 0.18%. Double Team: 0.36%. Dream Eater: 10.18%. Embargo: 0.09%. Energy Ball: 12.07%. Explosion: 9.64%. Fire Punch: 0.81%. Focus Blast: 49.19%. Focus Punch: 1.26%. Giga Drain: 2.16%. Hidden Power: 32.61%. Hypnosis: 24.05%. Ice Punch: 3.15%. Icy Wind: 3.51%. Mean Look: 2.07%. Night Shade: 0.63%. Nightmare: 0.99%. Ominous Wind: 0.45%. Pain Split: 6.76%. Perish Song: 0.63%. Protect: 4.68%. Psychic: 11.98%. Seismic Toss: 0.36%. Shadow Ball: 86.4%. Shadow Punch: 0.18%. Sludge Bomb: 11.62%. Substitute: 13.33%. Sucker Punch: 0.09%. Taunt: 2.7%. Thunder: 3.15%. Thunderbolt: 55.14%. Torment: 0.18%. Toxic: 0.36%. Trick: 15.05%. Will-O-Wisp: 5.05%.[/Secret] There is a little bug: Mr. Mime appears as Missingno because of the space in its name.
Stats in a more useful order (usage): [Secret] Scizor 28.42% Tyranitar 22.29% Salamence 21.81% Swampert 19.62% Gengar 19.59% Metagross 18.90% Gyarados 17.32% Heatran 17.07% Infernape 15.86% Jirachi 13.45% Lucario 12.97% Starmie 11.64% Blissey 11.21% Latias 10.80% Skarmory 10.59% Electivire 9.78% Snorlax 9.53% Gliscor 9.27% Weavile 9.16% Dragonite 8.79% Rotom-H 8.37% Porygon-Z 8.21% Azelf 8.14% Breloom 8.08% Suicune 7.43% Vaporeon 7.38% Magnezone 7.29% Flygon 7.27% Zapdos 7.02% Machamp 6.97% Kingdra 6.56% Jolteon 6.32% Hippowdon 6.30% Dusknoir 5.70% Aerodactyl 5.30% Empoleon 5.24% Smeargle 5.07% Abomasnow 4.66% Togekiss 4.51% Alakazam 4.49% Forretress 4.47% Bronzong 4.20% Arcanine 4.17% Gallade 4.10% Heracross 3.94% Charizard 3.72% Celebi 3.72% Roserade 3.72% Cresselia 3.67% Crobat 3.54% Milotic 3.51% Tentacruel 3.43% Ninjask 3.20% Umbreon 3.05% Mamoswine 3.04% Mismagius 2.95% Typhlosion 2.80% Feraligatr 2.80% Froslass 2.72% Venusaur 2.64% Ludicolo 2.61% Marowak 2.49% Sceptile 2.42% Clefable 2.17% Walrein 2.14% Staraptor 2.10% Yanmega 2.10% Blaziken 2.05% Absol 1.96% Spiritomb 1.92% Lanturn 1.85% Houndoom 1.80% Gardevoir 1.69% Torterra 1.60% Glaceon 1.60% Lapras 1.57% Rhyperior 1.57% Porygon2 1.53% Uxie 1.50% Espeon 1.47% Rotom-C 1.40% Slowbro 1.36% Dugtrio 1.34% Steelix 1.33% Ambipom 1.27% Kabutops 1.22% Cloyster 1.18% Honchkrow 1.18% Shedinja 1.11% Hitmontop 1.02% Miltank 1.02% Raikou 1.02% Donphan 0.93% Magmortar 0.93% Cacturne 0.92% Rampardos 0.90% Medicham 0.88% Primeape 0.86% Toxicroak 0.83% Blastoise 0.81% Whiscash 0.81% Registeel 0.77% Shaymin 0.77% Raichu 0.74% Rotom-F 0.72% Pikachu 0.69% Articuno 0.69% Shuckle 0.69% Electrode 0.67% Hitmonlee 0.67% Octillery 0.67% Slaking 0.63% Claydol 0.63% Clefairy 0.61% Hariyama 0.60% Hitmonchan 0.54% Drapion 0.54% Dragonair 0.51% Slowking 0.51% Drifblim 0.51% Floatzel 0.50% Rotom-W 0.50% Mantine 0.48% Rapidash 0.46% Qwilfish 0.46% Rotom 0.46% Swellow 0.45% Exploud 0.45% Leafeon 0.45% Regice 0.41% Kangaskhan 0.39% Omastar 0.39% Politoed 0.39% Nidoking 0.37% Flareon 0.37% Zangoose 0.37% Phione 0.37% Ninetales 0.36% Scyther 0.36% Regigigas 0.36% Poliwrath 0.34% Kingler 0.34% Weezing 0.34% Magikarp 0.34% Cleffa 0.34% Ampharos 0.34% Torkoal 0.34% Bastiodon 0.34% Exeggutor 0.32% Meganium 0.32% Azumarill 0.32% Ursaring 0.32% Aggron 0.30% Pidgeot 0.29% Victreebel 0.29% Magneton 0.29% Cradily 0.29% Jumpluff 0.27% Lickilicky 0.27% Pinsir 0.25% Probopass 0.25% Sandslash 0.23% Muk 0.23% Sharpedo 0.23% Golduck 0.21% Dewgong 0.21% Altaria 0.21% Tangrowth 0.21% Wailord 0.18% Gorebyss 0.18% Relicanth 0.18% Missingno 0.18% Hypno 0.16% Parasect 0.14% Venomoth 0.14% Onix 0.14% Delibird 0.14% Dusclops 0.14% Glalie 0.14% Nidoqueen 0.12% Golem 0.12% Dodrio 0.12% Noctowl 0.12% Xatu 0.12% Dunsparce 0.12% Piloswine 0.12% Huntail 0.12% Luxray 0.12% Mesprit 0.12% Chansey 0.11% Tauros 0.11% Eevee 0.11% Moltres 0.11% Croconaw 0.11% Murkrow 0.11% Snubbull 0.11% Pupitar 0.11% Camerupt 0.11% Ditto 0.09% Mightyena 0.09% Wynaut 0.09% Rotom-S 0.09% Mr. Mime 0.07% Shiftry 0.07% Plusle 0.07% Duskull 0.07% Groudon 0.07% Raticate 0.05% Vileplume 0.05% Magmar 0.05% Kecleon 0.05% Banette 0.05% Regirock 0.05% Lopunny 0.05% Jynx 0.04% Ariados 0.04% Quagsire 0.04% Sneasel 0.04% Treecko 0.04% Mawile 0.04% Meditite 0.04% Grumpig 0.04% Purugly 0.04% Skuntank 0.04% Munchlax 0.04% Carnivine 0.04% Bulbasaur 0.02% Arbok 0.02% Persian 0.02% Pichu 0.02% Stantler 0.02% Entei 0.02% Linoone 0.02% Pelipper 0.02% Tropius 0.02% Grotle 0.02% Chimchar 0.02% Buizel 0.02% Cherrim 0.02% Gastrodon 0.02% Chatot 0.02% [/Secret]
So I tried using this, and got the following error: "Script Error line 1: SyntaxError: Parse error". What am I doing wrong?
Well, in the script window you need to have ({ at the beginning and }) at the end. I fixed the script to add that. Can you try again?
Sorry for the double post, and I feel stupid for asking so many questions. -.- I go /savestats, but then check the stats file and there's nothing there. Am I doing it wrong?