Allow Karma plugin to accept +++/--- votes

ManiaControl, the completely new designed and easy to use controller managing all your Maniaplanet server.

Moderators: kremsy, steeffeen, Jocy, Wabbitface, NADEO

Post Reply
Nicklander
Posts: 30
Joined: 20 May 2018, 01:41

Allow Karma plugin to accept +++/--- votes

Post by Nicklander » 10 Oct 2019, 18:40

Lots of people are used to the tripple votes +++ and ---.
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);
	}

User avatar
undef.de
Posts: 1987
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: Allow Karma plugin to accept +++/--- votes

Post by undef.de » 10 Oct 2019, 18:56

The +++ and --- (and ++, +, -- and -) votes come from the ManiaKarma plugin I made for XAseco(2) and UASECO, but for ManiaControl nobody did the plugin yet.
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.

Nicklander
Posts: 30
Joined: 20 May 2018, 01:41

Re: Allow Karma plugin to accept +++/--- votes

Post by Nicklander » 10 Oct 2019, 21:12

undef.de wrote:
10 Oct 2019, 18:56
The +++ and --- (and ++, +, -- and -) votes come from the ManiaKarma plugin I made for XAseco(2) and UASECO, but for ManiaControl nobody did the plugin yet.
Well there's a KarmaPlugin that even syncs with MX, it works perfectly.
Could you add +++ and --- as an alias, so that it does the same as ++/-- ?
You do not have the required permissions to view the files attached to this post.

User avatar
undef.de
Posts: 1987
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

Re: Allow Karma plugin to accept +++/--- votes

Post by undef.de » 11 Oct 2019, 11:07

Nicklander wrote:
10 Oct 2019, 21:12
Well there's a KarmaPlugin that even syncs with MX, it works perfectly.
ManiaKarma != MXKarma 8-)
Nicklander wrote:
10 Oct 2019, 21:12
Could you add +++ and --- as an alias, so that it does the same as ++/-- ?
No sorry, I'm not familiar with the code of ManiaControl at all.
Developer of UASECO, a controller with support of the Modescript Gamemodes for TM².
Visit the official website for more: UASECO.org


Developer of various plugins for XAseco/XAseco2 and MPAseco, visit my lab: www.undef.name

You like what I do? Then award a ManiaStar.

Post Reply

Return to “ManiaControl”

Who is online

Users browsing this forum: No registered users and 1 guest