[Xaseco 1+2] ReplayCharge Plugin

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
User avatar
Leigham
happy cruiser
happy cruiser
Posts: 139
Joined: 26 Mar 2011 01:04
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): None

[Xaseco 1+2] ReplayCharge Plugin

Post by Leigham » 12 Jun 2011 15:15

Replay Charge.

This is a plugin I've thrown together because someone asked for it :)

It allows players to pay coppers in order to replay a track. Coppers go to the server account, so it must be TMUF.

Image

Image

As of version 1.20 there is an alternative look designed to fit with the popular records-eyepiece panels.
Image Image Image

Versions
v2.00 - Pay2Play
  • Plugin merged into pay2play plugin.
  • Skipping maps added.
  • Blinking functionality improved.
v1.22
  • Fixed a bug causing the TMU version to incorrectly read tracks (thanks Blackbird111).
  • Fixed a positioning error when displaying a blinking message.
  • Fixed a bug causing replays to always display as a maximum after the first (thanks TheBigG).
v1.21
  • Fixed a bug causing the wrong widget to be occasionally displayed when a player connects during a replay.
v1.20
  • Fixed a bug causing replays to be delayed if payment is recieved during scoreboard (thanks yamyam).
  • Added the option to limit the number of replays on a track.
  • Added the option for a blinking message informing players of a replay.
  • Added official(ish) support for the eyepiece-esque version of the plugin (designed by TheBigG).
v1.17
  • Fixed a bug causing players joining at score to be shown the widget (thanks TheBigG)
v1.16
  • Fixed a bug where new players may still be able to pay to replay a track even if a replay is scheduled (thanks TheBigG).
v1.15 v1.1
  • No changes to the plugin at all. Added an unnecessary xml config file.
Download the zip here:

Please see this topic for downloads:
viewtopic.php?f=127&t=30163


Setup:

- Unzip the file and move plugin.replaycharge.php into you xaseco /plugins directory.

- Edit the values in replaycharge.xml to your satisfaction.

- Add the following line to plugins.xml in your xaseco root directory: <plugin>plugin.replaycharge.php</plugin>

- Restart Xaseco

I've tested this plugin on my servers so it should work fine, theoretically.
Last edited by Leigham on 29 Nov 2012 18:06, edited 17 times in total.
"Never surrender, sometimes retreat"

Image

Scottish Flat Trax servers

User avatar
sterretje22
road tourist
road tourist
Posts: 87
Joined: 29 May 2010 23:47
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): fireteam
Location: Oudenburg(BE)
Contact:

Re: [Xaseco] ReplayCharge Plugin

Post by sterretje22 » 12 Jun 2011 16:42

Nice Work mate :)
`·.¸¸.->ѕтαя~ƒιяє<-.¸¸.·´
ImageImage
Image
`·.¸¸.->~ƒιяє~<-.¸¸.·´
Image

dukez30
sunday driver
sunday driver
Posts: 59
Joined: 23 Aug 2008 14:26
Owned TM-games: TMU

Re: [Xaseco] ReplayCharge Plugin

Post by dukez30 » 12 Jun 2011 18:18

Nice, whered you get that paypal button too ^^?

User avatar
Leigham
happy cruiser
happy cruiser
Posts: 139
Joined: 26 Mar 2011 01:04
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): None

Re: [Xaseco] ReplayCharge Plugin

Post by Leigham » 12 Jun 2011 19:21

That's just an ad widget on fufi's plugin. The image is a doctored one from google image search.
"Never surrender, sometimes retreat"

Image

Scottish Flat Trax servers

savage24x
cyclist
cyclist
Posts: 39
Joined: 10 Jul 2009 04:27
Owned TM-games: TMNF, TMN:ESWC, TMU
Contact:

Re: [Xaseco] ReplayCharge Plugin

Post by savage24x » 23 Jun 2011 16:19

how can i shift it down about 1.5X it's size so its right above the chat bar a little bit?
Join my FreeZone!

[server=gravedig24x]FreeZone LOL Fun 2[/server]

User avatar
Leigham
happy cruiser
happy cruiser
Posts: 139
Joined: 26 Mar 2011 01:04
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): None

Re: [Xaseco] ReplayCharge Plugin

Post by Leigham » 23 Jun 2011 20:18

You can change the position using the $position variable on line 23. To change the actual size you'll have to edit the sizen value on lines 34 and 46. You'll probably also have to alter the text size on the following line and realign it all.
"Never surrender, sometimes retreat"

Image

Scottish Flat Trax servers

savage24x
cyclist
cyclist
Posts: 39
Joined: 10 Jul 2009 04:27
Owned TM-games: TMNF, TMN:ESWC, TMU
Contact:

Re: [Xaseco] ReplayCharge Plugin

Post by savage24x » 24 Jun 2011 21:35

i dont knwo what I would change it to... the position variable i mean...
Join my FreeZone!

[server=gravedig24x]FreeZone LOL Fun 2[/server]

User avatar
Leigham
happy cruiser
happy cruiser
Posts: 139
Joined: 26 Mar 2011 01:04
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): None

Re: [Xaseco] ReplayCharge Plugin

Post by Leigham » 24 Jun 2011 23:49

If you're just moving it down you'll want to change the Y to a lower number. Just keep lowering it until it's where you want it :)
Last edited by Leigham on 25 Jun 2011 09:07, edited 1 time in total.
"Never surrender, sometimes retreat"

Image

Scottish Flat Trax servers

djarrett
smooth traffic navigator
smooth traffic navigator
Posts: 235
Joined: 04 Jul 2006 15:01
Owned TM-games: TMO,TMS,TMN,TMU,TMUF
Location: Fayetteville,GA
Contact:

Re: [Xaseco] ReplayCharge Plugin

Post by djarrett » 25 Jun 2011 01:37

Heres code to move this plugin to the bottom right,
not over lapping anything, when using... Xaseco ,
and also plugin.records_eyepiece.php and plugin.alternate_scoretable.php

Code: Select all

<?php
/* ReplayCharge v1.0
 *
 * Plugin by Leigham. With thanks to Xymph, from whom I stole some code :)
 *
 * Important: This plugin will only work on a TMUF server. 
 * The server must have at least a small amount of coppers for
 * the plugin to work.
 *
 * Scroll down to configure plugin settings.
 */

Aseco::registerEvent('onPlayerConnect', 'replaychargeOn');
Aseco::registerEvent('onNewChallenge', 'replaychargeOn');
Aseco::registerEvent('onEndRace', 'replaychargeOff');
Aseco::registerEvent('onPlayerManialinkPageAnswer', 'replaychargeClick');
Aseco::registerEvent('onBillUpdated', 'replaychargeBill');

global $position, $coppers, $replaybills;

// Configuration settings below

$position = '49.5 -28.0 1';    // Position of the manialink. 'X Y Z'
$coppers = 10;   // Copper cost to replay the track
// End of config

$replaybills = array();

function replaychargeOn($aseco) {
	global $position, $coppers;
	
	$xml = '<manialink id="1234512301">
    <frame posn="'.$position.'">
        <quad posn="0 0 0" sizen="15 5" style="BgsPlayerCard" substyle="BgCardSystem" action="234561"></quad>
        <label posn="7.5 -2.4 1" sizen="11 5" halign="center" valign="center" textsize="2.0" textcolor="FFFF" text="Replay track for '.$coppers.' coppers!"></label>
    </frame>
	</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeSuccess($aseco) {
	global $position;
	
	$xml = '<manialink id="1234512301">
    <frame posn="'.$position.'">
        <quad posn="0 0 0" sizen="15 5" style="BgsPlayerCard" substyle="BgCardSystem"></quad>
        <label posn="7.5 -2.4 1" sizen="11 5" halign="center" valign="center" textsize="2.0" textcolor="FFFF" text="Track is being replayed!"></label>
    </frame>
	</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeOff($aseco) {
	
	$xml = '<manialink id="1234512301">
		<frame posn="0 0 0">
			<quad posn="0 0 0" sizen="0 0" halign="center" valign="center" action="234561"></quad>
		</frame>
	</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeClick($aseco, $command) {
	global $coppers, $replaybills;
	
	$playerid = $command[0];
	$login = $command[1];
	$answer = $command[2].'';
	$aseco->client->query('GetDetailedPlayerInfo', $login);
	$player = $aseco->client->getResponse();
	$nickname = $player['NickName'];
		if ($answer == '234561') {
		$aseco->client->query('GetCurrentChallengeInfo');
		$thistrack = $aseco->client->getResponse();
		$aseco->client->query('GetNextChallengeInfo');
		$nexttrack = $aseco->client->getResponse();
		// Check if already being replayed
		if ($thistrack['FileName'] != $nexttrack['FileName']) {	
			//	Check for TMF server
			if ($aseco->server->getGame() == 'TMF') {
				// check for TMUF server
				if ($aseco->server->rights) {
					// check for TMUF player
					if ($player['OnlineRights'] == 3) {
						// start the transaction
						$message = 'You need to pay '.$coppers.' coppers to replay the track';
						$aseco->client->query('SendBill', $login, $coppers, $message, '');
						$replaybillid = $aseco->client->getResponse();
						$replaybills[$replaybillid] = array($login, $nickname, $coppers, $thistrack);
					} else {
					$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'account');
					$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
					}
				} else {
				$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'server');
				$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
				}
			} else {
			$message = $aseco->getChatMessage('FOREVER_ONLY');
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			}
		} else {
		$message = '>$f00 This track is already being replayed';
		$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);
		}
	}
}
		// [0]=BillId, [1]=State, [2]=StateName, [3]=TransactionId
function replaychargeBill($aseco, $replaybill) {
	global $replaybills;
	$replaybillid = $replaybill[0];
	// check for known bill ID
	if (array_key_exists($replaybillid, $replaybills)) {
		// get bill info
		$login = $replaybills[$replaybillid][0];
		$nickname = $replaybills[$replaybillid][1];
		$coppers = $replaybills[$replaybillid][2];
		$thistrack = $replaybills[$replaybillid][3];
				// check bill state
		switch($replaybill[1]) {
		case 4:  // Payed (Paid)
				$track = $thistrack['FileName'];
				$message = '$f90Player $z'.$nickname.'$z$f90  pays '.$coppers.' coppers and queues challenge for replay!';
				$aseco->client->query('ChooseNextChallenge', $track);
				$aseco->client->query('ChatSendServerMessage', $message);
				$aseco->console('Player {1} paid {2} coppers to replay the current track', $login, $coppers);
			unset($replaybills[$replaybillid]);
			replaychargeSuccess($aseco);
			break;
		case 5:  // Refused
			$message = '{#server}> {#error}Transaction refused!';
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			unset($replaybills[$replaybillid]);
			break;
		case 6:  // Error
			$message = '{#server}> {#error}Transaction failed: {#highlite}$i ' . $replaybill[2];
			if ($login != '')
				$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			else
				$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
			unset($replaybills[$replaybillid]);
			break;
		default:  // CreatingTransaction/Issued/ValidatingPay(e)ment
			break;
		}
	}
}
?>


perycjusz
road tourist
road tourist
Posts: 85
Joined: 06 Feb 2009 03:00
Owned TM-games: TMU

Re: [Xaseco] ReplayCharge Plugin

Post by perycjusz » 06 Sep 2011 00:46

can someone please rewrite this script for Xaseco2 ?
Image

TheBigG
smooth traffic navigator
smooth traffic navigator
Posts: 226
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: [Xaseco] ReplayCharge Plugin

Post by TheBigG » 09 Sep 2011 18:06

hello i want to show it a minute before end and not the complete race can somebody add that?

User avatar
L3cKy
happy cruiser
happy cruiser
Posts: 138
Joined: 05 Sep 2007 13:55
Owned TM-games: TMUF
Manialink(s): woa
Location: Sweden
Contact:

Re: [Xaseco] ReplayCharge Plugin

Post by L3cKy » 21 Sep 2011 23:24

Really nice plugin :)

But i found something out ... if you have normal or chat-based voting on you can anyway vote without paying ;)

To prevent this go first into /includes/rasp.settings.php enable chat-based voting and disable normal voting with:

Code: Select all

$feature_votes = true;
Than go to /plugins/plugin.rasp_votes.php and change:
(this disable the chat-command /replay)

Code: Select all

Aseco::addChatCommand('replay', 'Starts a vote to replay this track');
to
//Aseco::addChatCommand('replay', 'Starts a vote to replay this track');
Important: Non TMUF players cant vote for replay anymore.

--------

An solution can be that TMUF players must pay and non TMUF players dont.
If you want to do so you can use my fix. (could not tested because i have no TMNF account ... but should work)
BUT be warned ... non TMUF player can now replay the track how often they want because this script have not the replay_limit from rasp included. :(

Code: Select all

<?php
/* ReplayCharge v1.0
 *
 * Plugin by Leigham. With thanks to Xymph, from whom I stole some code :)
 *
 * Important: This plugin will only work on a TMUF server.
 * The server must have at least a small amount of coppers for
 * the plugin to work.
 *
 * Scroll down to configure plugin settings.
 */

Aseco::registerEvent('onPlayerConnect', 'replaychargeOn');
Aseco::registerEvent('onNewChallenge', 'replaychargeOn');
Aseco::registerEvent('onEndRace', 'replaychargeOff');
Aseco::registerEvent('onPlayerManialinkPageAnswer', 'replaychargeClick');
Aseco::registerEvent('onBillUpdated', 'replaychargeBill');

global $position, $coppers, $replaybills;

// Configuration settings below

$position = '-63.8 -17.5 1';    // Position of the manialink. 'X Y Z'
$coppers = 85;   // Copper cost to replay the track
// End of config

$replaybills = array();


function replaychargeOn($aseco) {
	global $position, $coppers;

	$xml = '<manialink id="1234512301">
				<frame posn="'.$position.'">
					<quad posn="0 0 0" sizen="23 5" style="BgsPlayerCard" substyle="BgCardSystem" action="234561"></quad>
					<label posn="11.3 -2.4 1" sizen="23 5" halign="center" valign="center" textsize="2.5" textcolor="FFFF" text="Replay track!"></label>
				</frame>
			</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeSuccess($aseco) {
	global $position;

	$xml = '<manialink id="1234512301">
    <frame posn="'.$position.'">
        <quad posn="0 0 0" sizen="23 5" style="BgsPlayerCard" substyle="BgCardSystem"></quad>
        <label posn="11.3 -2.4 1" sizen="23 5" halign="center" valign="center" textsize="2.5" textcolor="FFFF" text="Track is being replayed!"></label>
    </frame>
	</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeOff($aseco) {

	$xml = '<manialink id="1234512301">
		<frame posn="0 0 0">
			<quad posn="0 0 0" sizen="0 0" halign="center" valign="center" action="234561"></quad>
		</frame>
	</manialink>';
	$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
}

function replaychargeClick($aseco, $command) {
	global $coppers, $replaybills;

	$playerid = $command[0];
	$login = $command[1];
	$answer = $command[2].'';
	$aseco->client->query('GetDetailedPlayerInfo', $login);
	$player = $aseco->client->getResponse();
	$nickname = $player['NickName'];
		if ($answer == '234561') {
		$aseco->client->query('GetCurrentChallengeInfo');
		$thistrack = $aseco->client->getResponse();
		$aseco->client->query('GetNextChallengeInfo');
		$nexttrack = $aseco->client->getResponse();
		// Check if already being replayed
		if ($thistrack['FileName'] != $nexttrack['FileName']) {
			//	Check for TMF server
			if ($aseco->server->getGame() == 'TMF') {
				// check for TMUF server
				if ($aseco->server->rights) {
					// check for TMUF player
					if ($player['OnlineRights'] == 3) {
						// start the transaction
						$message = 'You need to pay '.$coppers.' coppers to replay the track';
						$aseco->client->query('SendBill', $login, $coppers, $message, '');
						$replaybillid = $aseco->client->getResponse();
						$replaybills[$replaybillid] = array($login, $nickname, $coppers, $thistrack);
					} else {
						//$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'account');
						//$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
						$aseco->client->query('ChooseNextChallenge', $thistrack);
						$message = '$f90Player $z'.$nickname.'$z$f90 queues challenge for replay!';
						$aseco->client->query('ChatSendServerMessage', $message);
					}
				} else {
				$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'server');
				$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
				}
			} else {
			$message = $aseco->getChatMessage('FOREVER_ONLY');
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			}
		} else {
		$message = '>$f00 This track is already being replayed';
		$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);
		}
	}
}
		// [0]=BillId, [1]=State, [2]=StateName, [3]=TransactionId
function replaychargeBill($aseco, $replaybill) {
	global $replaybills;
	$replaybillid = $replaybill[0];
	// check for known bill ID
	if (array_key_exists($replaybillid, $replaybills)) {
		// get bill info
		$login = $replaybills[$replaybillid][0];
		$nickname = $replaybills[$replaybillid][1];
		$coppers = $replaybills[$replaybillid][2];
		$thistrack = $replaybills[$replaybillid][3];
				// check bill state
		switch($replaybill[1]) {
		case 4:  // Payed (Paid)
				$track = $thistrack['FileName'];
				$message = '$f90Player $z'.$nickname.'$z$f90  pays '.$coppers.' coppers and queues challenge for replay!';
				$aseco->client->query('ChooseNextChallenge', $track);
				$aseco->client->query('ChatSendServerMessage', $message);
				$aseco->console('Player {1} paid {2} coppers to replay the current track', $login, $coppers);
			unset($replaybills[$replaybillid]);
			replaychargeSuccess($aseco);
			break;
		case 5:  // Refused
			$message = '{#server}> {#error}Transaction refused!';
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			unset($replaybills[$replaybillid]);
			break;
		case 6:  // Error
			$message = '{#server}> {#error}Transaction failed: {#highlite}$i ' . $replaybill[2];
			if ($login != '')
				$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
			else
				$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
			unset($replaybills[$replaybillid]);
			break;
		default:  // CreatingTransaction/Issued/ValidatingPay(e)ment
			break;
		}
	}
}
?>

perycjusz
road tourist
road tourist
Posts: 85
Joined: 06 Feb 2009 03:00
Owned TM-games: TMU

Re: [Xaseco] ReplayCharge Plugin

Post by perycjusz » 22 Sep 2011 18:08

can someone fix this plugin for xaseco2 ?
Image

User avatar
Leigham
happy cruiser
happy cruiser
Posts: 139
Joined: 26 Mar 2011 01:04
Owned TM-games: TMUF, TMNF, TM²
Manialink(s): None

Re: [Xaseco 1+2] ReplayCharge Plugin

Post by Leigham » 01 Oct 2011 13:17

The plugin is now compatible with Xaseco2. I've tested it on v0.95 and it works fine. (Download in the first post)
"Never surrender, sometimes retreat"

Image

Scottish Flat Trax servers

TheBigG
smooth traffic navigator
smooth traffic navigator
Posts: 226
Joined: 16 Oct 2010 19:45
Owned TM-games: TMN! TMF
Location: Germany

Re: [Xaseco 1+2] ReplayCharge Plugin

Post by TheBigG » 03 Oct 2011 17:02

hello there is a bug if a player connects @ scoretable the plugin is shown again.
can somebody fix that?
thx in advance

Post Reply