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, f*ckfish, Assembler Maniac, TM-Patrol

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 » 25 Jan 2009 22:38

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');
?>
New version... switched around some things to add a little more redundancy, and added some debugging code (set to true at top).

Edit: Fixed code to current version, in case someone digs this up from a search...
Last edited by nocturne on 24 Jan 2010 20:02, edited 5 times in total.

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 » 25 Jan 2009 22:59

Alright, touched up a bit on it... new version is edited into the post directly above.

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 » 28 Jan 2009 19:32

i might add for others, that these 2 lines at the top need to be set to true for it to work.

private $IsInRounds=false;
private $round_active=false;

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: rounds auto round end

Post by oliverde8 » 28 Jan 2009 22:44

can you add a activate desactivate to it,
I am working on a game setting plugin 50% done and if you add such an option I will do as sort as if the plugin exist admin should be able to control it, directly from there. I didn't create a real setting menu just included settings in menu. but if Next Game Mode is Round only Round settings appears and not TA settings.
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

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 » 30 Jan 2009 05:37

fordry wrote:i might add for others, that these 2 lines at the top need to be set to true for it to work.

private $IsInRounds=false;
private $round_active=false;
Just set all the privates to 'var', and it should work fine (was a mixing my php 4 and 5, I guess)...

For the switch, it'd be easy enough.... just have to write the code. Hacking up my juke right now, so it'll have to wait until tomorrow...

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

Re: rounds auto round end

Post by dago » 09 Jul 2009 13:01

I tried this plugin and i get this

Fatal error: Call to undefined method RoundTimer::addEvent() in C:\xaseco\plugin
s\plugin.autoendround.php on line 81


Running xaseco 1.09

Any ideas ?

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: rounds auto round end

Post by Assembler Maniac » 09 Jul 2009 13:24

dago wrote:I tried this plugin and i get this

Fatal error: Call to undefined method RoundTimer::addEvent() in C:\xaseco\plugin
s\plugin.autoendround.php on line 81


Running xaseco 1.09

Any ideas ?

Dan
Since the error is coming out of an XASECO plugin, you might want to go ask in the XASECO forum.

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

Re: rounds auto round end

Post by dago » 09 Jul 2009 14:06

Assembler Maniac wrote: Since the error is coming out of an XASECO plugin, you might want to go ask in the XASECO forum.

Right Thanks, didnt even realise where i was :roflol:

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: rounds auto round end

Post by nocturne » 09 Jul 2009 18:44

The plugin isn't Xaseco, but his controller is... that's the problem.

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

Re: rounds auto round end

Post by Assembler Maniac » 09 Jul 2009 21:53

nocturne wrote:The plugin isn't Xaseco, but his controller is... that's the problem.
Yeah, figured that out when he posted a link to the rounds plugin in AR/2 over in the xaseco forum.

Thx Noc

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 » 24 Jan 2010 20:01

bump for new version... was a bug that prevented it from checking rounds at all...

Changed in posts above, but here it is anyways...

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');
?>

Post Reply