Plugin autoendround

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

Moderators: Xymph, TM-Patrol

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: Plugin autoendround

Post by nocturne » 14 Jul 2009 18:37

Alright, this should finally do it... :lol:

Full plugin is in the first post.

Problem was the check_rounds function... again :grmblz:

Code: Select all

function checkRounds($aseco){
   global $rt_debug, $round_timer;
   if ( $aseco->server->gameinfo->mode == 0 ) {
     if ($rt_debug) {
		$aseco->console_text('[RoundTimer] In Rounds...');
     }
     return true;
   } else {
     if ($round_timer) {
		unset($round_timer);
     }
     if ($rt_debug) {
		$aseco->console_text('[RoundTimer] Not in rounds... Should not do anything.');
     }
     return false;
   }
}

dago
sunday driver
sunday driver
Posts: 61
Joined: 20 Feb 2009 18:43
Owned TM-games: tmuf

Re: Plugin autoendround

Post by dago » 14 Jul 2009 18:58

nocturne wrote:Alright, this should finally do it... :lol:

Full plugin is in the first post.

Problem was the check_rounds function... again :grmblz:

Code: Select all

function checkRounds($aseco){
   global $rt_debug, $round_timer;
   if ( $aseco->server->gameinfo->mode == 0 ) {
     if ($rt_debug) {
		$aseco->console_text('[RoundTimer] In Rounds...');
     }
     return true;
   } else {
     if ($round_timer) {
		unset($round_timer);
     }
     if ($rt_debug) {
		$aseco->console_text('[RoundTimer] Not in rounds... Should not do anything.');
     }
     return false;
   }
}
Took the full version in your previous post and i got this:

Begin Challenge
[PHP Warning] Missing argument 1 for checkRounds(), called in C:\xaseco\plugins\
plugin.autoendround.php on line 29 and defined on line 74 in file C:\xaseco\plug
ins\plugin.autoendround.php

Fatal error: Call to a member function query() on a non-object in C:\xaseco\plug
ins\plugin.autoendround.php on line 32

Thanks

Dan
join VITAMINEC
Servermania V 0.98
xaseco 1.10

Assembler Maniac
Pit Crew
Pit Crew
Posts: 1493
Joined: 03 Jun 2006 13:24
Owned TM-games: TMU
Contact:

Re: Plugin autoendround

Post by Assembler Maniac » 14 Jul 2009 19:16

Try this out. Event functions need $aseco as first parameter (added). I also ran it through a code formatter, so it should be nice and cleanly formatted again.

WARNING: I don't have an XAseco to test this with, but I've fixed the obvious problems, so it *should* work (hopefully).

Code: Select all

<?php

/**
* Round Auto-End plugin.
* Ends the current round after a magically computed amount of time.
* Created by -nocturne=-
*
* Dependencies: none
*/

Aseco::registerEvent('onNewChallenge', 'set_timer');
Aseco::registerEvent('onBeginRound', 'start_timer');
Aseco::registerEvent('onMainLoop', 'check_timer');
Aseco::registerEvent('onEndRound', 'disable_timer');

global $IsInRounds, $round_timer, $round_time, $round_active, $rt_debug;

$rt_debug = false;

//Redundancy - Don't Touch
$IsInRounds = false;
$round_timer = 0;
$round_time = 0;
$round_active = false;

function set_timer($aseco) {
	global $IsInRounds, $round_timer, $round_active, $rt_debug;
	$round_active = false; //probably redundant, but oh well
	$IsInRounds = checkRounds($aseco);

	if (!$IsInRounds) {
		return;
	}

	$aseco->client->query('GetCurrentChallengeInfo');
	$result = $aseco->client->getResponse();
	$authortime = $result['AuthorTime'] / 1000;
	$round_timer = ($authortime * 1.10) + 5;
	$round_timer = round($round_timer);

	if ($rt_debug) {
		$aseco->console_text('[RoundTimer] Author Time: ' . $authortime . '  Round Time:' . $round_timer);
	}
}

function start_timer($aseco) {
	global $IsInRounds, $round_time, $round_timer, $round_active;

	if ($IsInRounds) {
		$round_time = $round_timer + time();
		$round_active = true;

		if ($rt_debug) {
			$aseco->console_text('[RoundTimer] Round Started!');
		}
	}
}

function check_timer($aseco) {
	global $IsInRounds, $round_active, $round_time, $round_timer;

	if ($IsInRounds && $round_active && time() > $round_time) {
		$aseco->client->query('ForceEndRound');
		$round_active = false;
		$aseco->client->query('ChatSendServerMessage', '$fff$iRound automatically ended!');
		$aseco->console_text('[RoundTimer] Round automatically ended after ' . $round_timer . 'secs...');
	}
}

function disable_timer($aseco) {
	global $IsInRounds, $round_active, $rt_debug;

	if ($IsInRounds && $round_active) {
		$round_active = false;

		if ($debug) {
			$aseco->console_text('[RoundTimer] End of round...');
		}
	}
}

function checkRounds($aseco) {
	global $rt_debug, $round_timer;

	if ($aseco->server->gameinfo->mode == 0) {
		if ($rt_debug) {
			$aseco->console_text('[RoundTimer] In Rounds...');
		}
		return true;
	} else {
		if ($round_timer) {
			unset($round_timer);
		}

		if ($rt_debug) {
			$aseco->console_text('[RoundTimer] Not in rounds... Should not do anything.');
		}
		return false;
	}
}
?>

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: Plugin autoendround

Post by nocturne » 15 Jul 2009 06:45

lmao... it really has been awhile since Aseco .61b, hehe...

Thanks to AM for straightening it out... and again thanks for cleaning up the plugin format for Aseco v2. Soooo much easier... :gobananas:

dago
sunday driver
sunday driver
Posts: 61
Joined: 20 Feb 2009 18:43
Owned TM-games: tmuf

Re: Plugin autoendround

Post by dago » 15 Jul 2009 10:45

You got it.

It is working now and i did not see any error :gobananas:

Thanks to all of you for your time

:1

Dan
join VITAMINEC
Servermania V 0.98
xaseco 1.10

Assembler Maniac
Pit Crew
Pit Crew
Posts: 1493
Joined: 03 Jun 2006 13:24
Owned TM-games: TMU
Contact:

Re: Plugin autoendround

Post by Assembler Maniac » 15 Jul 2009 12:20

nocturne wrote:lmao... it really has been awhile since Aseco .61b, hehe...

Thanks to AM for straightening it out... and again thanks for cleaning up the plugin format for Aseco v2. Soooo much easier... :gobananas:
Glad I could help.

Don't thank me, thank Flo. He's the one that did all the great thinking on the plugin framework.

dago
sunday driver
sunday driver
Posts: 61
Joined: 20 Feb 2009 18:43
Owned TM-games: tmuf

Re: Plugin autoendround

Post by dago » 15 Jul 2009 18:19

Just a note to say it also work in team mode.

And not a big problem but the message:
round automatically ended!
appears even in time attack mode without causing any problem.

Would it be easy to remove this message in time attack mode ?

Thanks

Dan
join VITAMINEC
Servermania V 0.98
xaseco 1.10

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: Plugin autoendround

Post by nocturne » 15 Jul 2009 19:11

It should only be working in Rounds mode (didn't think about Team mode)...

Try setting '$rt_debug' at the top to true and check what pops up in the log at the beginning of the round.

Assembler Maniac
Pit Crew
Pit Crew
Posts: 1493
Joined: 03 Jun 2006 13:24
Owned TM-games: TMU
Contact:

Re: Plugin autoendround

Post by Assembler Maniac » 15 Jul 2009 21:15

Looks like I missed a $aseco assign.

in the checkRounds function, add $aseco to the definition.

Should look like this

function checkRounds($aseco) {

I'd be willing to bet it's failing on getting the right value back and thinks it's in rounds all the time.

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: Plugin autoendround

Post by nocturne » 15 Jul 2009 21:22

Might as well add Team mode too, I guess...

Code: Select all

function checkRounds($aseco) {
   global $rt_debug, $round_timer;

   if ($aseco->server->gameinfo->mode == 0 || $aseco->server->gameinfo->mode == 2) {
      if ($rt_debug) {
         $aseco->console_text('[RoundTimer] In Rounds/Team Mode...');
      }
      return true;
   } else {
      if ($round_timer) {
         unset($round_timer);
      }

      if ($rt_debug) {
         $aseco->console_text('[RoundTimer] Not in Rounds/Team mode... Should not do anything.');
      }
      return false;
   }
}

dago
sunday driver
sunday driver
Posts: 61
Joined: 20 Feb 2009 18:43
Owned TM-games: tmuf

Re: Plugin autoendround

Post by dago » 16 Jul 2009 12:35

Nice work guys.

Works perfectly now

Thanks a lot all of you :lovetm

:1

Dan
join VITAMINEC
Servermania V 0.98
xaseco 1.10

Xymph
Pit Crew
Pit Crew
Posts: 5650
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: Plugin autoendround

Post by Xymph » 24 Jul 2009 20:29

Assembler Maniac wrote:Looks like I missed a $aseco assign.

in the checkRounds function, add $aseco to the definition.

Should look like this

function checkRounds($aseco) {

I'd be willing to bet it's failing on getting the right value back and thinks it's in rounds all the time.
Yup, 0 == Rounds. But why didn't you edit it into your previous post? I did that now.
nocturne wrote:Might as well add Team mode too, I guess...
And Cup mode? :wink:
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

Post Reply