The code is down below but it does not save player kills .... PHP: /**API PART*/ /** * @param Player $player * @return null|int */ public function getKills(Player $player){ $name = trim(strtolower($player->getName())); $result = $this->db->query("SELECT * FROM player_stats WHERE name = '".$this->db->escape_string($name)."'"); if($result instanceof \mysqli_result){ $data = $result->fetch_assoc(); $result->free(); if(isset($data["name"]) and strtolower($data["name"]) === $name){ unset($data["name"]); return $data["kills"]; } } return null; }/**NON API*/ /** * @param PlayerDeathEvent $event */ public function DeathEvent(PlayerDeathEvent $event){ $victim = $event->getEntity(); if($victim instanceof Player){ $this->db->query("UPDATE player_stats SET deaths = deaths +1 WHERE name = '".strtolower($this->db->escape_string($event->getEntity()->getPlayer()->getDisplayName()))."'"); $cause = $event->getEntity()->getLastDamageCause()->getCause(); if($cause == 1){ $killer = $event->getEntity()->getLastDamageCause()->getEntity(); if($killer instanceof EntityDamageByEntityEvent){ $this->db->query("UPDATE player_stats SET kills = kills +1 WHERE name = '".strtolower($this->db->escape_string($killer))."'"); } } } } Website: http://stats.dr-pvp.net/stats/purple/stats.php?
@Radix, the fix is so easy. Just add a var before instanceof called '$cause'. And it is: PHP: $cause = $event->getEntity()->getLastDamageCause(); And change the PHP: if($killer instanceof … to PHP: if($cause instanceof …
https://github.com/SurvivalHive/Minecraft-Pocket-Edition/tree/master/SurvivalHiveStats i upload my rewrited stats plugin for Joins/Kills & Death. iam sry but i dont know right how to create database/tables/colums automaticly if there are not existent... so u have to create your own database table and the 4 colums... u can change the settings from the values in config... here a phar -> http://survivalhive.de/files/StatswithCfg.phar
I just want to track kills and death thats all , Kill rate has a really nasty structure! How am I suppose to freaking show this in a webpage ? Its so easy with PlayerStats structure!
With some query like: SELECT * FROM Scores WHERE player = "0speed0" And then you would get each type as count o.o?
$link = mysqli_connect("$this->serverip", "$this->user", "$this->password"); if (!mysqli_select_db('mydb', "$link")) { mysqli_query('CREATE DATABASE mydb'); mysqli_select_db('mydb'); } if (!mysqli_select_db('mydb', "$link")) { //<--- "mysqli_select_db() expects parameter 1 to be mysqli, string given" if (!mysqli_select_db('mydb', `$link`)) { //<--- "Object of class mysqli could not be converted to string" if (!mysqli_select_db('mydb', $link)) { //<--- "Object of class mysqli could not be converted to string" this line makes me trouble! can anyone help???