Re: PocketMine Plugin - VoteKick
<?php
/*
__PocketMine Plugin__
name=VoteKick
description=Vote to kick a player
version=0.2
author=NAT
class=VoteKick
apiversion=9
*/
//NOTICE : This plugins is STILL IN DEBUG .
class VoteKick implements Plugin{
private $api,$server;
public function __construct(ServerAPI $api, $server = false){
$this->api = $api;
$this->server = ServerAPI::request();
}
public function init(){
$this->api->console->register("startvote", "<player>", array($this, "handleCommand"));
$this->api->console->register("vote","<player>", array($this, "handleCommand"));
$this->server->api->ban->cmdWhitelist("vote");
$this->server->api->ban->cmdWhitelist("startvote");
$this->api->addHandler("player.quit", array($this, "handler"), 5);
$this->voting=0;
}
public function __destruct(){
}
public function handler(&$data, $event){
switch($data){
case "player.quit":
for($k=1;$k=$this->volting;$k++){
if($this->canvote1[$data->iusername][$this->vote[$k][1]]=="false"){
$this->vote[$k][1]=$this->vote[$k][1]-1;
$this->canvote1[$data->iusername][1]=="";
}
}
}
}
public function handleCommand($cmd, $arg ,$issuer , $alias){
switch($cmd){
case "startvote":
break;
case "vote":
break;
}
return $this->output;
}
public function canvote($name,$tovote){
if(empty($this->canvote1[$name][$tovote])){
$this->canvote1[$name][$tovote]="false";
return true;
}else{
return false;
}
}
public function isonline($totest){
$player = $this->api->player->get($totest);
if(!$player){
return false;
}
return true;
}
public function invote($tovote)
{
$invote=false;
if($this->voting!=0){
for($i=1;$i=$this->voting;$i++){
if($this->vote[$i][1]=$tovote){
$this->tmp=$i;
$invote=true;
break;
}
}
}
return $invote;
}
public function newvote($tovote){
$this->output="Usage : /startvote <player> (start a vote to kick someone)";
return 0;
}
if($this->invote($tovote)||!$this->isonline($tovote))
{
$this->output="Error During Try to start vote,Player might not online or already in vote.";
}else{
$this->api->chat->broadcast("Voting to kick ".$tovote." Using /vote ".$tovote." to vote it.");
$this->voting=$this->voting+1;
$this->vote[$this->voting][1]=$tovote;
$this->vote[$this->voting][2]=1;
}
}
public function vote($tovote){
$this->output="Usage : /vote <player> (vote to kick someone)";
return 0;
}
if(!$this->invote($tovote)||!$this->isonline($tovote)||!$this->canvote($issuer,$tovote)){
$this->snd("Error During Try to vote,Player might not online, isn't in vote , you has voted or running command from console");
return 0;
}else{
$this->output="Vote to kick Player ".$tovote." Successful!";
$this->vote[$this->tmp][2]=$vote[$this->tmp][2]+1;
}
if($this->vote[$this->tmp][2]>count($this->clients)/2)
{
$player = $this->api->player->get($tovote);
$this->api->chat->broadcast($tovote." has been kicked by voting");
$player->close("You has been vote to kick");
}
}
}
?>
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}