Help with rounds time limiter plugin

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

Post Reply
User avatar
daemon
sunday driver
sunday driver
Posts: 68
Joined: 09 Mar 2006 17:28
Location: México

Help with rounds time limiter plugin

Post by daemon » 29 May 2008 16:06

Hello, as many of you know, if you dont use new rules while playing rounds, you dont get a time limiter.
Now for example: Using old rules(like almost all rounds servers), youre playing a hard track, a round starts and no one can finish it, everyone retires except 1 player who can't finish it either but refuses to retire, and there is no admin around to force the end of the round, so people start leaving the server, what to do about this?

You set a time limit for old rules rounds. :D

Im trying to find a plugin for aseco with this functionality, or in the worst case scenario, make one myself, the problem is I lack programming skills, so if anyone could give me hints/tips/money/the plugin :lol: it would be great. :P

I did this, but I don't know how to break the while cycle in case someone finishes the track/everyone retires/track changes, and also the menus/buttons become non responsive, I think because of usleep, and if I lower its value it starts to lose precision. Also don't think this is the optimal way to do it by any means, just showed it here to explain better what Im trying to achieve. :)

Code: Select all

<?php
class TimeLimitedRounds extends Plugin {
    var $challenge;
    var $tracktime;

	function startRound() {
		$this->challenge = $this->Aseco->server->challenge;
		$this->tracktime = $this->challenge->bronzetime;
		echo "round started";
		while ($this->tracktime > 0) {
			$this->tracktime = $this->tracktime - 1000;
			usleep(1000000);
		}
		if ($this->tracktime <= 0) { 
			$this->Aseco->client->query('ForceEndRound');
			$this->sendServerMessage('$c60>> Round timer has expired');	
			echo "time expired";			
		}		
	}	
	
	function loadTrack() {
		$this->challenge = $this->Aseco->server->challenge;
		$this->tracktime = $this->challenge->bronzetime;
		$tracktimeinsecs = $this->tracktime / 1000;
		$this->sendServerMessage('$c60>> Rounds on this track are limited to '.ceil($tracktimeinsecs).' seconds');	
	}	
}

$_PLUGIN = new TimeLimitedRounds();
$_PLUGIN->setVersion(0.1);
$_PLUGIN->addEvent('onStatusChangeTo4', 'startRound');
$_PLUGIN->addEvent('onNewChallenge', 'loadTrack');
?>
Well if you have some ideas or know how to do it please post, it will be greatly appreciated. :thumbsup:
Image
It's the decisions you make, when you have no time to make them, that define who you are.

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Help with rounds time limiter plugin

Post by f*ckfish » 29 May 2008 18:18

You could have a look at the Fufi Tools for TMN, there was a so called "AutoEndRound" Plugin which did that, you'd just have to port that part to Aseco Forever =)
viewtopic.php?f=127&t=10113&p=74780&hilit=fufi#p74780

Short hints:
  • at the start of a round save the system time and compute a timelimit for the track
  • register a function that reacts "OnMainLoop"
  • compute the difference between the current time and the saved time
  • if it is above the timelimit, end the round and reset your stuff
Additional candy
  • Always check on the start of a round if this is really necessary, so check the game mode and the "new Rules" stuff
inactive, sorry

User avatar
daemon
sunday driver
sunday driver
Posts: 68
Joined: 09 Mar 2006 17:28
Location: México

Re: Help with rounds time limiter plugin

Post by daemon » 29 May 2008 20:52

Thank you very much man, Ill check it and see if I can find the way to port it. :D
Image
It's the decisions you make, when you have no time to make them, that define who you are.

User avatar
daemon
sunday driver
sunday driver
Posts: 68
Joined: 09 Mar 2006 17:28
Location: México

Re: Help with rounds time limiter plugin

Post by daemon » 30 May 2008 16:20

Man you're not ****fish, you're ****god!! :roflol:

I was able to port it i think, only tested with 2 people, but seems to be working good, need to clean code and do some more validations hehe.

I saw that there is an idle player kicker too, maybe gonna try to port that too, but I have a question.

Does the code for idle kicker have to be in the same toolsTimer function as the autoendround code? or can I create the same function in a different plugin file.

Thanks a lot man. :thumbsup:
Image
It's the decisions you make, when you have no time to make them, that define who you are.

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Help with rounds time limiter plugin

Post by f*ckfish » 01 Jun 2008 20:54

daemon wrote:Man you're not ****fish, you're ****god!! :roflol:

I was able to port it i think, only tested with 2 people, but seems to be working good, need to clean code and do some more validations hehe.

I saw that there is an idle player kicker too, maybe gonna try to port that too, but I have a question.

Does the code for idle kicker have to be in the same toolsTimer function as the autoendround code? or can I create the same function in a different plugin file.

Thanks a lot man. :thumbsup:
Thanks =)

It can be a seperate plugin, I just tried to not stress the system too much with lots of plugins reacting on every loop, so I combined it into one symbiotic plugin pack.
inactive, sorry

Post Reply