ManiaControl's MX Karma plugin only supports ++ and -- tho.
Is it possible to allow +++/--- like in TMNF ?
If yes, how ?
If not, then can I at least create +++/--- as an alias for ++/-- as a workaround ? So that voting +++ does the same as ++ ?
I'm not very familiar with how exactly this plugin works, maybe someone can help me to allow +++/--- votes.
Code: Select all
/**
* Handle PlayerChat callback
*
* @param array $chatCallback
*/
public function handlePlayerChat(array $chatCallback) {
$login = $chatCallback[1][1];
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if (!$player) {
return;
}
$message = $chatCallback[1][2];
if ($chatCallback[1][3]) {
$message = substr($message, 1);
}
if (preg_match('/[^+-]/', $message)) {
return;
}
$countPositive = substr_count($message, '+');
$countNegative = substr_count($message, '-');
if ($countPositive <= 0 && $countNegative <= 0) {
return;
}
$vote = $countPositive - $countNegative;
$success = $this->handleVote($player, $vote);
if (!$success) {
$this->maniaControl->getChat()->sendError('Error occurred.', $player->login);
return;
}
$this->maniaControl->getChat()->sendSuccess('Vote updated!', $player->login);
}