rounds auto round end

This forum is dedicated to the Aseco/Rasp 2 server records and control script by Flo and Assembler Maniac. Announcements and issues can be discussed in this forum.

Moderators: Flo, Assembler Maniac, f*ckfish, TM-Patrol

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

rounds auto round end

Post by fordry » 10 Nov 2008 05:18

couldn't find this anywhere, is there a way to get rounds to end automatically if no one finishes? I know there is a way to do, just not sure if its Aseco, or something else.

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: rounds auto round end

Post by w1lla » 10 Nov 2008 10:06

its for (X)aseco i can give a headstart;

Code: Select all

	/**
	 * Forces end of current round.
	 */
	} elseif ($command['params'][0] == 'endround' ||
	          $command['params'][0] == 'er') {
		global $chatvote;  // from plugin.rasp_votes.php

		// cancel possibly ongoing endround vote
		if (!empty($chatvote) && $chatvote['type'] == 0) {
			$chatvote = array();
			// disable all vote panels
			if ($aseco->server->getGame() == 'TMF')
				allvotepanels_off($aseco);
		}

		// end this round
		$aseco->client->query('ForceEndRound');

		// log console message
		$aseco->console('{1} [{2}] forces round end!', $logtitle, $login);

		// show chat message
		$message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} forces round end!',
		                      $chattitle, $admin->nickname);
		$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
You just need to make it work for aseco thats the job.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

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

Re: rounds auto round end

Post by nocturne » 10 Nov 2008 16:44

Well, if it's an admin command you need, RASP already has the '/admin endround' command... If you mean something like an automatic timer, it's certainly possible to code up.

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 10 Nov 2008 19:05

an auto timeout would be what i would like, cause then an admin doesn't have to bother unless they really want to.

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

Re: rounds auto round end

Post by nocturne » 10 Nov 2008 19:57

Not too much of a tall order...

So, an onMainLoop function that checks the round time versus 'authortime X a multiplier + a buffer'... I don't know much about rounds, honestly. Doesn't it end automatically at some point if some racers finish, but not end at all if none finish? Either way, I don't think it'd be too important in terms of compatibility. Also, would you want it to work the same way if there were no players connected, which would just cause it to keep cycling through tracks (would keep mysql active, at least)?

Can catch me on rock later to iron out the details, if need be... :1

pm: Also, could make an endround callvote function... but seems pointless if an autotimer would work -- would just have to wait another 30-60 secs...

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 11 Nov 2008 01:58

yea, in rounds, you have i think a 10 second countdown from when the first person finishes. And Xaseco and/or Fast have an auto-timeout feature that will end the round i think based on the author time. Kinda like the auto timer in TA i guess.

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

Re: rounds auto round end

Post by nocturne » 11 Nov 2008 02:06

So... how about 1.25 X 'authortime'?

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 11 Nov 2008 02:17

that would be fine, even less might be ok, like 1.15. Granted, thats probably gonna be fairly easy to adjust if you know where to look.

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

Re: rounds auto round end

Post by nocturne » 11 Nov 2008 03:52

This should do it... haven't tested it yet, but looks like it'll work:

Code: Select all

<?php
// Automatically forces end of round based on AuthorTime

class RoundTimer extends Plugin {

private $IsInRounds;
private $round_timer;
private $round_time;
private $round_active;
private $debug = false;

function startup() {
	$this->round_active = false;
	$this->IsInRounds = false;
	$this->checkRounds();
	$this->set_timer();
	$this->start_timer();
}

function set_timer() {

   $this->checkRounds();
   if (!$this->IsInRounds) {return;}
   
    $this->Aseco->client->query('GetCurrentChallengeInfo');
    $result = $this->Aseco->client->getResponse();
    $authortime = $result['AuthorTime'] / 1000;
    $this->round_timer = ( $authortime * 1.25 ) + 10;
    $this->round_timer = round($this->round_timer);
    if ($this->debug) {
      $this->Aseco->console_text('[RoundTimer] Author Time: '.$authortime.'  Round Time:'.
      $this->round_timer);
    }
}

function start_timer() {
   if ( $this->IsInRounds ) {
     $this->round_time = $this->round_timer + time();
     $this->round_active = true;
      if ($this->debug) {
      $this->Aseco->console_text('[RoundTimer] Round Started!');
     }
   }
}

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

function disable_timer() {
   if ( $this->IsInRounds && $this->round_active ) {
      $this->round_active = false;
      if ($this->debug) {
         $this->Aseco->console_text('[RoundTimer] End of round...');
      }
   }
}

function checkRounds(){
	$servermode = $this->Aseco->server->gameinfo->getMode();
   if ( $servermode == 'Rounds' || $servermode == 'Team' || $servermode == 'Cup' ) {
      $this->IsInRounds = True;
      if ($this->debug) {
      $this->Aseco->console_text('[RoundTimer] In Rounds...');
     }
     return;
   } else {
      $this->IsInRounds = False;
     if ($this->round_timer) {
      unset($this->round_timer);
     }
      if ($this->debug) {
      $this->Aseco->console_text('[RoundTimer] Not in rounds... Should not do anything.');
     }
      return;
   }
}


}
$_PLUGIN = new RoundTimer();
$_PLUGIN->setAuthor('-nocturne=-');
$_PLUGIN->setVersion(.20);
$_PLUGIN->setDescription('Automatically forces end of round based on AuthorTime');
$_PLUGIN->addEvent('onSync', 'startup');
$_PLUGIN->addEvent('onNewChallenge', 'set_timer');
$_PLUGIN->addEvent('onStatusChangeTo4', 'start_timer');
$_PLUGIN->addEvent('onMainLoop', 'check_timer');
$_PLUGIN->addEvent('onEndRound', 'disable_timer');
?>
Just edit line 21 ( $this->round_timer = ( $authortime * 1.10 ) + 5; ) to what ever magical formula you wish...

Edit: updated code above to current version, in case somebody digs this up in a search..
Last edited by nocturne on 24 Jan 2010 20:02, edited 8 times in total.

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 11 Nov 2008 04:04

kewls

just checking, this is its own plugin?

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

Re: rounds auto round end

Post by nocturne » 11 Nov 2008 04:11

Yep, standalone plugin...

ps: edited the plugin a little bit... just took out some redundant rounding

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 11 Nov 2008 04:16

great, thanks, that should make things a little more smooth on roundhouse.

I'll try it out as soon as i get home.

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: rounds auto round end

Post by fordry » 11 Nov 2008 07:53

i'm getting this

[Load Plugin] [plugin.dedimania.php] [Name:DediMania] [Ver:0.6a]
[Load Plugin] [chat.dedimania.php] [Name:DediMania_Chat] [Ver:0.6a]
[Load Plugin] [plugin.fufi.autoqueue.php] [Name:AutoQueue] [Ver:0.35]
[Load Plugin] [plugin.infoteam.php] [Name:InfoTeam] [Ver:0.91]
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in C:\Docum
ents and Settings\Administrator\My Documents\TMFServer\Aseco2\plugins\plugin.aut
oendround.php on line 15

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

Re: rounds auto round end

Post by nocturne » 11 Nov 2008 08:10

Oops... :oops:

Typo on line 15...

Code: Select all

unset $this->round_timer;
Should be:

Code: Select all

unset($this->round_timer);
Fixed in the post above...

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: rounds auto round end

Post by w1lla » 11 Nov 2008 08:19

hmm if i edited the line its keeps reporting end round without ending the round by itself.
Last edited by w1lla on 11 Nov 2008 08:24, edited 1 time in total.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

Post Reply