Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Dec 5, 2016
1 parent 0184115 commit c33d2a7
Show file tree
Hide file tree
Showing 5 changed files with 555 additions and 2 deletions.
109 changes: 107 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,107 @@
# KillRate
Keep track of the number of kills
KillRate
=======

* Summary: Keep track of how much killing is going-on
* Dependency Plugins: N/A
* PocketMine-MP version: 1.4 - API 1.10.0
* DependencyPlugins: -
* OptionalPlugins: PocketMoney,MassiveEconomy,EconomyAPI,GoldStd
* Categories: Informational
* Plugin Access: Commands, Entity
* WebSite: [github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/KillRate)

Overview
--------

Keep track on how much killing is going-on on a server.

It may optionally use an economy plugin like for example, PocketMoney,
to reward killing.

Basic Usage:

* killrate - Will show your KillRate stats.
* killrate stats [player] - Show the KillRate stats for [player]
* killrate top [online] - Show top players.

Documentation
-------------

This plugin supports PocketMoney and GoldStd and has experimental
support for MassiveEconomy and EconomyAPI.

### Configuration

These can be configured from `config.yml`:

settings:
points: true
rewards: true
creative: false
values:
zombie: [10,100]
Player: [100, 100]
'*': [0, -10]

If `creative` is set to true, kills done when the player is in
`creative` will be counted. The default is false, *NOT* to count
them.

If `points` is true, points are awarded and tracked. You need to
enable `points` for the rankings to work.

If `rewards` is true, money is awarded. You need an economy plugin
for this to work.

`values` are used to configure how many points or how much money is
awarded per kill type. The first number is points, the second is
money. You can use negative values.

### Permission Nodes:

* killrate.cmd:
* default: true
* description: "Give players access to KillRate command"
* killrate.cmd.stats:
* default: true
* description: "Access to stats command"
* killrate.cmd.stats.other:
* default: op
* description: "View other's stats"
* killrate.cmd.rank:
* default: true
* description: "View top players"

Changes
-------

* 1.0.2 : Arrow
* Improved scoring of Exploding arrows
* Fixed a bug in the way we call the EconomyAPI
*
* 1.0.1 : Bugfixes
* Removed warnings
* Improve the scoring detection
* Scores deaths
* Added support for GoldStd
* 1.0.0 : First submission

Copyright
---------

KillRate
Copyright (C) 2015 Alejandro Liu
All Rights Reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Binary file added media/killrate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: KillRate
version: 1.0.2
main: aliuly\killrate\Main
api: 1.10.0
load: POSTWORLD
# You have to have at least one of these...
softdepend: [PocketMoney,MassiveEconomy,EconomyAPI,GoldStd]

description: Keep track of the number of kills
author: aliuly

commands:
killrate:
description: Show kill rate stats
usage: "/killrate [stats|top]"
aliases: [kr]
permission: killrate.cmd

permissions:
killrate.cmd:
default: true
description: "Give players access to KillRate command"
killrate.cmd.stats:
default: true
description: "Access to stats command"
killrate.cmd.stats.other:
default: op
description: "View other's stats"
killrate.cmd.rank:
default: true
description: "View top players"
80 changes: 80 additions & 0 deletions src/aliuly/killrate/DatabaseManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace aliuly\killrate;

class DatabaseManager {
private $database;

static function prepare($player) {
return "'".\SQLite3::escapeString(strtolower($player))."'";
}

public function __construct($path){
$this->database = new \SQLite3($path);
$sql = "CREATE TABLE IF NOT EXISTS Scores (
player TEXT NOT NULL,
type TEXT NOT NULL,
count INTEGER NOT NULL,
PRIMARY KEY (player,type)
)";
$this->database->exec($sql);
}
public function getTops($limit,$players,$scores) {
$sql = "SELECT * FROM Scores";
$sql .= " WHERE type = ".self::prepare($scores);
if ($players != null) {
$sql .= " AND player IN (";
$q = "";
foreach ($players as $p) {
$sql .= $q.self::prepare($p);
$q = ",";
}
$sql .=")";
}
$sql .= " ORDER BY count DESC";
if ($limit) $sql .= " LIMIT ".intval($limit);
//echo $sql."\n";
$res = $this->database->query($sql);
if ($res === false) return null;
$tab = [];
while (($row = $res->fetchArray(SQLITE3_ASSOC)) != false) {
$tab[] = $row;
}
return $tab;
}

public function getScores($player) {
$sql = "SELECT * FROM Scores WHERE player = ".self::prepare($player);
$res = $this->database->query($sql);
if ($res === false) return null;
$tab = [];
while (($row = $res->fetchArray(SQLITE3_ASSOC)) != false) {
$tab[] = $row;
}
return $tab;
}
public function getScore($player,$type) {
$sql = "SELECT * FROM Scores WHERE player = ".self::prepare($player).
" AND type = ".self::prepare($type);
$res = $this->database->query($sql);
return $res->fetchArray(SQLITE3_ASSOC);
}
public function insertScore($player,$type,$cnt) {
$sql = "INSERT INTO Scores (player,type,count) VALUES (".
self::prepare($player).", ".self::prepare($type).", ".intval($cnt).
")";
return $this->database->exec($sql);
}

public function updateScore($player,$type,$cnt) {
$sql ="UPDATE Scores SET count=".intval($cnt).
" WHERE (player = ".self::prepare($player)." AND type = ".
self::prepare($type).")";
return $this->database->exec($sql);
}

public function delScore($player) {
$sql ="DELETE FROM Scores WHERE player=".self::prepare($player);
return $this->database->exec($sql);
}
}
Loading

0 comments on commit c33d2a7

Please sign in to comment.