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

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

Moderators: Jocy, Wabbitface, steeffeen, NADEO

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

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

Post by Nicklander »

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: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

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

Post by undef.de »

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 »

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 ++/-- ?
Attachments
KarmaPlugin.php.txt
(33.9 KiB) Downloaded 219 times
User avatar
undef.de
Posts: 2095
Joined: 06 Apr 2011, 21:57
Location: Germany, North Sea Coast
Contact:

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

Post by undef.de »

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.
ranig
Posts: 71
Joined: 27 May 2017, 01:07

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

Post by ranig »

Nicklander wrote: 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 just need to go in the settings of the KarmaPlugin and change the "Available Votes" setting to -3,3 and you will be able to vote +++ and --- (as well as any combination of + and - in between). You can do this in-game, no need to go in the code or the configuration files.
Your Trackmania resource for Nascar racing http://www.tm-nascar.com
Post Reply

Return to “ManiaControl”

Who is online

Users browsing this forum: No registered users and 1 guest