donated Planets statistic
This commit is contained in:
parent
40219b7367
commit
4412ff73c1
@ -215,7 +215,6 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
|||||||
$testf->add($testq);
|
$testf->add($testq);
|
||||||
|
|
||||||
$script->addTooltip($itemQuad, $testf);
|
$script->addTooltip($itemQuad, $testf);
|
||||||
$script->addTooltip($testf, $testf);
|
|
||||||
/** TEST TOOLTIP */
|
/** TEST TOOLTIP */
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class Map {
|
|||||||
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
||||||
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
||||||
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
||||||
$this->mx = new \MXInfoFetcher($title, $this->uid, false);
|
// $this->mx = new \MXInfoFetcher($title, $this->uid, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
use ManiaControl\ManiaControl;
|
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
const ID = 3;
|
const ID = 3;
|
||||||
const VERSION = 0.1;
|
const VERSION = 0.1;
|
||||||
const SETTING_ANNOUNCE_SERVERDONATION = 'Enable Server-Donation Announcements';
|
const SETTING_ANNOUNCE_SERVERDONATION = 'Enable Server-Donation Announcements';
|
||||||
|
const STAT_PLAYER_DONATIONS = 'donatedPlanets';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -42,6 +43,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
||||||
|
|
||||||
|
// Define player stats
|
||||||
|
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYER_DONATIONS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,16 +121,13 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
$receiver = $params[2];
|
$receiver = $params[2];
|
||||||
$receiverPlayer = $this->maniaControl->playerManager->getPlayer($receiver);
|
$receiverPlayer = $this->maniaControl->playerManager->getPlayer($receiver);
|
||||||
$receiverName = ($receiverPlayer ? $receiverPlayer['NickName'] : $receiver);
|
$receiverName = ($receiverPlayer ? $receiverPlayer['NickName'] : $receiver);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$receiver = '';
|
$receiver = '';
|
||||||
$receiverName = $this->maniaControl->server->getName();
|
$receiverName = $this->maniaControl->server->getName();
|
||||||
}
|
}
|
||||||
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
|
$message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?';
|
||||||
if(!$this->maniaControl->client->query('SendBill', $player->login, $amount, $message, $receiver)) {
|
if(!$this->maniaControl->client->query('SendBill', $player->login, $amount, $message, $receiver)) {
|
||||||
trigger_error(
|
trigger_error("Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText());
|
||||||
"Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " .
|
|
||||||
$this->maniaControl->getClientErrorText());
|
|
||||||
$this->maniaControl->chat->sendError("Creating donation failed.", $player->login);
|
$this->maniaControl->chat->sendError("Creating donation failed.", $player->login);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -161,15 +161,12 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
}
|
}
|
||||||
if(count($params) >= 3) {
|
if(count($params) >= 3) {
|
||||||
$receiver = $params[2];
|
$receiver = $params[2];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$receiver = $player->login;
|
$receiver = $player->login;
|
||||||
}
|
}
|
||||||
$message = 'Payout from $<' . $this->maniaControl->server->getName() . '$>.';
|
$message = 'Payout from $<' . $this->maniaControl->server->getName() . '$>.';
|
||||||
if(!$this->maniaControl->client->query('Pay', $receiver, $amount, $message)) {
|
if(!$this->maniaControl->client->query('Pay', $receiver, $amount, $message)) {
|
||||||
trigger_error(
|
trigger_error("Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " . $this->maniaControl->getClientErrorText());
|
||||||
"Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " .
|
|
||||||
$this->maniaControl->getClientErrorText());
|
|
||||||
$this->maniaControl->chat->sendError("Creating payout failed.", $player->login);
|
$this->maniaControl->chat->sendError("Creating payout failed.", $player->login);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -225,20 +222,18 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
// To player
|
// To player
|
||||||
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
||||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// To server
|
// To server
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_ANNOUNCE_SERVERDONATION, true)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_ANNOUNCE_SERVERDONATION, true)) {
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
||||||
$message = '$<' . ($player ? $player->nickname : $login) . '$> donated ' . $amount . ' Planets! Thanks.';
|
$message = '$<' . ($player ? $player->nickname : $login) . '$> donated ' . $amount . ' Planets! Thanks.';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$message = 'Donation successful! Thanks.';
|
$message = 'Donation successful! Thanks.';
|
||||||
}
|
}
|
||||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->getLogin(), $amount);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// Payout
|
// Payout
|
||||||
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
||||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user