mistral.idlekick.php | Stuck with a problem

This Aseco flavor by Mistral contains a comprehensive rank system that orders stats by environment, track and author name. It also contains a built-in lottery system.

Moderators: Mistral, TM-Patrol

User avatar
Kakkoii
happy cruiser
happy cruiser
Posts: 142
Joined: 18 Dec 2007 06:32
Owned TM-games: TMU & TMO
Location: BC Canada, FTW!
Contact:

mistral.idlekick.php | Stuck with a problem

Post by Kakkoii » 04 Apr 2009 08:22

I've been trying to change the mistral.idlekick plugin to force players into spectator instead of kicking them.

Here is the unedited code. It's the newest from XAseco 1.06.

Code: Select all

<?php
/* vim: set noexpandtab tabstop=2 softtabstop=2 shiftwidth=2: */

/****************************************************************************
 *
 * (X)ASECO plugin to kick idle players
 *
 * (C) 2007 by Mistral
 * Updated by Xymph
 *
 * Dependencies: none
 *
 ****************************************************************************/

Aseco::registerEvent('onNewChallenge', 'kickIdleNewChallenge');
Aseco::registerEvent('onPlayerConnect', 'kickIdleInit');
Aseco::registerEvent('onChat', 'kickIdleChat');
Aseco::registerEvent('onCheckpoint', 'kickIdleCheckpoint');
Aseco::registerEvent('onPlayerFinish', 'kickIdleFinish');
Aseco::registerEvent('onEndRace', 'kickIdlePlayers');

global $kickPlayAfter, $kickSpecAfter, $kickSpecToo, $resetOnChat, $resetOnCheckpoint, $resetOnFinish, $idlekickStart, $idlekick_log, $idlekick_debug;

$kickPlayAfter = 2;         // Player idle this number of challenges and get kicked
$kickSpecAfter = 4;         // Spectator idle this number of challenges and get kicked
$kickSpecToo = true;        // Kick spectators too
$resetOnChat = true;        // Reset idle counter on chat use
$resetOnCheckpoint = true;  // Reset idle counter when passing a checkpoint
$resetOnFinish = false;     // Reset idle counter when reaching the finish
// don't use OnFinish in rounds or team mode, because every player will "finish"

// don't touch:
$idlekickStart = true;
$idlekick_log = false;
$idlekick_debug = false;

// called @ onChat
function kickIdleChat($aseco, $chat) {
	global $resetOnChat, $idlekick_debug;

	// if server message, bail out immediately
	if ($chat[0] == $aseco->server->id) return;

	// if no check on chat use, bail out too
	if (!$resetOnChat) return;

	$player = $aseco->server->players->getPlayer($chat[1]);
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on chat");
}  // kickIdleChat

// called @ onCheckpoint
function kickIdleCheckpoint($aseco, $checkpt) {
	global $resetOnCheckpoint, $idlekick_debug;

	// if no check on checkpoints, bail out
	if (!$resetOnCheckpoint) return;

	$player = $aseco->server->players->getPlayer($checkpt[1]);
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on checkpoint");
}  // kickIdleCheckpoint

// called @ onPlayerFinish
function kickIdleFinish($aseco, $finish_item) {
	global $resetOnFinish, $idlekick_debug;

	// if no check on finishes, bail out
	if (!$resetOnFinish) return;

	$player = $finish_item->player;
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on finish");
}  // kickIdleFinish

// called @ onNewChallenge
function kickIdleNewChallenge($aseco, $challenge) {
	global $kickSpecToo, $idlekickStart, $idlekick_debug, $idlekick_log;

	if ($idlekickStart) {
		$idlekickStart = false;
		if ($idlekick_debug)
			$aseco->console("Idlekick: idlekickStart set to false.");
		foreach ($aseco->server->players->player_list as $player)
			kickIdleInit($aseco, $player);
		return;
	}

	foreach ($aseco->server->players->player_list as $player) {
		// get player status
		$spec = $aseco->isSpectator($player);

		// check for admin immunity
		if ($spec ? $aseco->allowAbility($player, 'noidlekick_spec')
		          : $aseco->allowAbility($player, 'noidlekick_play'))
			continue;  // go check next player

		// check for spectator kicking
		if ($kickSpecToo || !$spec)
			$player->mistral['idleCount']++;
		if ($idlekick_log)
			$aseco->console("Idlekick: " . $player->login . " set to " . $player->mistral['idleCount']);
	}
}  // kickIdleNewChallenge

// called @ onPlayerConnect
function kickIdleInit($aseco, $player) {
	global $idlekick_debug;

	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " initialised with 0");
}  // kickIdleInit

// called @ onEndRace
function kickIdlePlayers($aseco, $data) {
	global $kickPlayAfter, $kickSpecAfter, $idlekick_debug;

	foreach ($aseco->server->players->player_list as $player) {
		$spec = $aseco->isSpectator($player);
		// check for spectator or player challenge counts
		if ($player->mistral['idleCount'] == ($spec ? $kickSpecAfter
		                                            : $kickPlayAfter)) {
			if ($spec) {
				// log console message
				$aseco->console("Idlekick spectator: " . $player->login . " after " . $kickSpecAfter . " challenge(s) without action.");
				$message = formatText($aseco->getChatMessage('IDLEKICK_SPEC'),
				                      $player->nickname,
				                      $kickSpecAfter, ($kickSpecAfter == 1 ? '' : 's'));
			} else {
				// log console message
				$aseco->console("Idlekick player: " . $player->login . " after " . $kickPlayAfter . " challenge(s) without action.");
				$message = formatText($aseco->getChatMessage('IDLEKICK_PLAY'),
				                      $player->nickname,
				                      $kickPlayAfter, ($kickPlayAfter == 1 ? '' : 's'));
			}
			// show chat message
			$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
			// kick idle player
			$aseco->client->query('Kick', $player->login);
		}
		elseif ($idlekick_debug)
			$aseco->console("Idlekick: " . $player->login . " current value is " . $player->mistral['idleCount']);
	}
}  // kickIdlePlayers
?>
I've tried changing "$aseco->client->query('Kick', $player->login);" to "$aseco->client->query('ForceSpectator', $player->login);"
But it doesn't seem to send them to spectate. I even tried copying the whole section of ForceSpectator from admin.chat.php, and even aseco.php. So I'm quite stuck on what else to do to make this work. Seeing as how 'ForceSpectator' is an aseco function just like 'Kick'.
Come visit our server
Tet19 Music Tower

User avatar
Kakkoii
happy cruiser
happy cruiser
Posts: 142
Joined: 18 Dec 2007 06:32
Owned TM-games: TMU & TMO
Location: BC Canada, FTW!
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Kakkoii » 08 Apr 2009 10:20

Mistral, ya dead? XD
Come visit our server
Tet19 Music Tower

corto-72
smooth traffic navigator
smooth traffic navigator
Posts: 284
Joined: 28 Jul 2008 16:12
Owned TM-games: TMUF
Location: Toulouse
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by corto-72 » 08 Apr 2009 11:49

ForceSpectator method requires 2 parameters: Login, and spectator mode

Code: Select all

ForceSpectator(string, int): Force the spectating status of the player. You have to pass the login and the spectator mode (0: user selectable, 1: spectator, 2: player). Only available to Admin.
(extracted from this site)

So I guess you need:

$aseco->client->query('ForceSpectator', $player->login,1);

to force a player into spectator...

User avatar
Big_Al
road tourist
road tourist
Posts: 80
Joined: 09 Apr 2009 07:52
Owned TM-games: TMU TMUF TMN TMNF

Re: mistral.idlekick.php | Stuck with a problem

Post by Big_Al » 21 Apr 2009 07:41

Hello.
Is there any solution for that Problem?
Because i would love to use the same feature...

User avatar
Mistral
Pit Crew
Pit Crew
Posts: 1304
Joined: 02 May 2006 15:13
Owned TM-games: tmuf
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Mistral » 21 Apr 2009 08:09

Big_Al wrote:Hello.
Is there any solution for that Problem?
Because i would love to use the same feature...
What _is_ the problem?

didnt the above code work?

As i never used the function, you have to read the dedicated help (and it is posted in the above article by corto-72).

User avatar
Kakkoii
happy cruiser
happy cruiser
Posts: 142
Joined: 18 Dec 2007 06:32
Owned TM-games: TMU & TMO
Location: BC Canada, FTW!
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Kakkoii » 22 Apr 2009 11:14

Mistral wrote:
Big_Al wrote:Hello.
Is there any solution for that Problem?
Because i would love to use the same feature...
What _is_ the problem?

didnt the above code work?

As i never used the function, you have to read the dedicated help (and it is posted in the above article by corto-72).

Yeah it doesn't seem to work. Just tried it out. It just doesn't do anything. Don't know much more that I can say.
Come visit our server
Tet19 Music Tower

User avatar
Mistral
Pit Crew
Pit Crew
Posts: 1304
Joined: 02 May 2006 15:13
Owned TM-games: tmuf
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Mistral » 22 Apr 2009 13:28

Just tested:

Code: Select all

$aseco->client->query('ForceSpectator', $player->login,1);
works perfectly.

User avatar
Kakkoii
happy cruiser
happy cruiser
Posts: 142
Joined: 18 Dec 2007 06:32
Owned TM-games: TMU & TMO
Location: BC Canada, FTW!
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Kakkoii » 22 Apr 2009 18:07

Mistral wrote:Just tested:

Code: Select all

$aseco->client->query('ForceSpectator', $player->login,1);
works perfectly.
Ok, yeah it works. Guess I didn't test it long enough.

Now I have another problem lol. I can't switch back out of spectator.

Edit: Fixed that problem with:

Code: Select all

			// kick idle player
					$rtn = $aseco->client->query('ForceSpectator', $player->login, 1);
					sleep(1);
						// allow spectator to switch back to player
						$rtn = $aseco->client->query('ForceSpectator', $player->login, 0);
						sleep(1);  // wait for server to process spectator switch
Come visit our server
Tet19 Music Tower

User avatar
Mistral
Pit Crew
Pit Crew
Posts: 1304
Joined: 02 May 2006 15:13
Owned TM-games: tmuf
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Mistral » 22 Apr 2009 20:05

Kakkoii wrote:Now I have another problem lol. I can't switch back out of spectator.
Today someone told me thats fixed with the newest version of the dedicated!?

Try to remove the sleep(1)s (both) .... i dont think they are necessary and they might delay the script up to a timeout or other sideeffects.

User avatar
Kakkoii
happy cruiser
happy cruiser
Posts: 142
Joined: 18 Dec 2007 06:32
Owned TM-games: TMU & TMO
Location: BC Canada, FTW!
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Kakkoii » 22 Apr 2009 20:19

Mistral wrote:
Kakkoii wrote:Now I have another problem lol. I can't switch back out of spectator.
Today someone told me thats fixed with the newest version of the dedicated!?

Try to remove the sleep(1)s (both) .... i dont think they are necessary and they might delay the script up to a timeout or other sideeffects.
Nah, I don't get stuck in spec anymore. That's what the EDIT is about, that I fixed that problem.
I took that code out of the forcespec command in chat.admin.php. And yeah the sleep's probably aren't a necessary part of the code.
Come visit our server
Tet19 Music Tower

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

Re: mistral.idlekick.php | Stuck with a problem

Post by Xymph » 22 Apr 2009 20:29

Mistral wrote:
Kakkoii wrote:Now I have another problem lol. I can't switch back out of spectator.
Today someone told me thats fixed with the newest version of the dedicated!?
No, you still need the second ForceSpectator back to 0, or the player is stuck in spectator mode.
Mistral wrote:Try to remove the sleep(1)s (both) .... i dont think they are necessary and they might delay the script up to a timeout or other sideeffects.
Kakkoii left out the next step from my chat.admin.php code, ForceSpectatorTarget into free camera mode (2). The target is accepted by the dedicated if it follows immediately after a ForceSpectator, so I added the 1 second delay. It's ugly because everything else stops too, but I just had the better idea to use addCall which queues the method (unlike query which sends it immediately). That provides enough of a delay.

So the whole section in my chat.admin.php becomes:

Code: Select all

        if (!$aseco->isSpectator($target)) {
          // force player into spectator
          $rtn = $aseco->client->query('ForceSpectator', $target->login, 1);
          if (!$rtn) {
            trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
          } else {
            // allow spectator to switch back to player
            $rtn = $aseco->client->query('ForceSpectator', $target->login, 0);
            // force free camera mode on spectator
            $aseco->client->addCall('ForceSpectatorTarget', array($target->login, '', 2));
            // log console message
            $aseco->console('{1} [{2}] forces player {3} into spectator!', $logtitle, $login, stripColors($target->nickname));
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

User avatar
Big_Al
road tourist
road tourist
Posts: 80
Joined: 09 Apr 2009 07:52
Owned TM-games: TMU TMUF TMN TMNF

Re: mistral.idlekick.php | Stuck with a problem

Post by Big_Al » 11 May 2009 08:01

Okay, one last question.
What do i have to modify exactly to set the idlekick into spectator?

Just modify my chat.admin.php with that code?:

Code: Select all

      if (!$aseco->isSpectator($target)) {
          // force player into spectator
          $rtn = $aseco->client->query('ForceSpectator', $target->login, 1);
          if (!$rtn) {
            trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
          } else {
            // allow spectator to switch back to player
            $rtn = $aseco->client->query('ForceSpectator', $target->login, 0);
            // force free camera mode on spectator
            $aseco->client->addCall('ForceSpectatorTarget', array($target->login, '', 2));
            // log console message
            $aseco->console('{1} [{2}] forces player {3} into spectator!', $logtitle, $login, stripColors($target->nickname));
Or do i have modify anything else? :?

User avatar
Mistral
Pit Crew
Pit Crew
Posts: 1304
Joined: 02 May 2006 15:13
Owned TM-games: tmuf
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Mistral » 11 May 2009 09:31

Why not try before asking?

The solution is all above and there is no "anything else".

User avatar
Big_Al
road tourist
road tourist
Posts: 80
Joined: 09 Apr 2009 07:52
Owned TM-games: TMU TMUF TMN TMNF

Re: mistral.idlekick.php | Stuck with a problem

Post by Big_Al » 11 May 2009 12:36

Okay i changed in the mistral.idlekick.php

that code:

Code: Select all

// kick idle player
$aseco->client->query('Kick', $player->login);
into that:

Code: Select all

// kick idle player
$rtn = $aseco->client->query('ForceSpectator', $player->login, 1);
sleep(1);
// allow spectator to switch back to player
$rtn = $aseco->client->query('ForceSpectator', $player->login, 0);
sleep(1);  // wait for server to process spectator switch
Aseco starts without problems but there is no Idlekick ingame.

Then i changed in the chat.admin.php that code:

Code: Select all

if (!$aseco->isSpectator($target)) {
// force player into free spectator
$rtn = $aseco->client->query('ForceSpectator', $target->login, 1);
if (!$rtn) {
trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
} else {
// allow spectator to switch back to player
$rtn = $aseco->client->query('ForceSpectator', $target->login, 0);
sleep(1);  // wait for server to process spectator switch
// force free camera mode on spectator
$rtn = $aseco->client->query('ForceSpectatorTarget', $target->login, '', 2);
if (!$rtn) {
trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
} else {
// log console message
$aseco->console('{1} [{2}] forces player {3} into spectator!', $logtitle, $login, stripColors($target->nickname));
into that:

Code: Select all

if (!$aseco->isSpectator($target)) {
// force player into free spectator
$rtn = $aseco->client->query('ForceSpectator', $target->login, 1);
if (!$rtn) {
trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
} else {
// allow spectator to switch back to player
$rtn = $aseco->client->query('ForceSpectator', $target->login, 0);
sleep(1);  // wait for server to process spectator switch
// force free camera mode on spectator
$rtn = $aseco->client->query('ForceSpectatorTarget', $target->login, '', 2);
if (!$rtn) {
trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
} else {
// log console message
$aseco->console('{1} [{2}] forces player {3} into spectator!', $logtitle, $login, stripColors($target->nickname));
Then i start aseco and it shutsdown. Parse-Error in chat.admin.php line 3964.

here my complete code of mistal.idlekick.php:

Code: Select all

<?php
/* vim: set noexpandtab tabstop=2 softtabstop=2 shiftwidth=2: */

/****************************************************************************
 *
 * (X)ASECO plugin to kick idle players
 *
 * (C) 2007 by Mistral
 * Updated by Xymph
 *
 * Dependencies: none
 *
 ****************************************************************************/

Aseco::registerEvent('onNewChallenge', 'kickIdleNewChallenge');
Aseco::registerEvent('onPlayerConnect', 'kickIdleInit');
Aseco::registerEvent('onChat', 'kickIdleChat');
Aseco::registerEvent('onCheckpoint', 'kickIdleCheckpoint');
Aseco::registerEvent('onPlayerFinish', 'kickIdleFinish');
Aseco::registerEvent('onEndRace', 'kickIdlePlayers');

global $kickPlayAfter, $kickSpecAfter, $kickSpecToo, $resetOnChat, $resetOnCheckpoint, $resetOnFinish, $idlekickStart, $idlekick_log, $idlekick_debug;

$kickPlayAfter = 1;         // Player idle this number of challenges and get kicked
$kickSpecAfter = 999;         // Spectator idle this number of challenges and get kicked
$kickSpecToo = false;        // Kick spectators too
$resetOnChat = true;        // Reset idle counter on chat use
$resetOnCheckpoint = true;  // Reset idle counter when passing a checkpoint
$resetOnFinish = false;     // Reset idle counter when reaching the finish
// don't use OnFinish in rounds or team mode, because every player will "finish"

// don't touch:
$idlekickStart = true;
$idlekick_log = false;
$idlekick_debug = false;

// called @ onChat
function kickIdleChat($aseco, $chat) {
	global $resetOnChat, $idlekick_debug;

	// if server message, bail out immediately
	if ($chat[0] == $aseco->server->id) return;

	// if no check on chat use, bail out too
	if (!$resetOnChat) return;

	$player = $aseco->server->players->getPlayer($chat[1]);
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on chat");
}  // kickIdleChat

// called @ onCheckpoint
function kickIdleCheckpoint($aseco, $checkpt) {
	global $resetOnCheckpoint, $idlekick_debug;

	// if no check on checkpoints, bail out
	if (!$resetOnCheckpoint) return;

	$player = $aseco->server->players->getPlayer($checkpt[1]);
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on checkpoint");
}  // kickIdleCheckpoint

// called @ onPlayerFinish
function kickIdleFinish($aseco, $finish_item) {
	global $resetOnFinish, $idlekick_debug;

	// if no check on finishes, bail out
	if (!$resetOnFinish) return;

	$player = $finish_item->player;
	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " reset on finish");
}  // kickIdleFinish

// called @ onNewChallenge
function kickIdleNewChallenge($aseco, $challenge) {
	global $kickSpecToo, $idlekickStart, $idlekick_debug, $idlekick_log;

	if ($idlekickStart) {
		$idlekickStart = false;
		if ($idlekick_debug)
			$aseco->console("Idlekick: idlekickStart set to false.");
		foreach ($aseco->server->players->player_list as $player)
			kickIdleInit($aseco, $player);
		return;
	}

	foreach ($aseco->server->players->player_list as $player) {
		// get player status
		$spec = $aseco->isSpectator($player);

		// check for admin immunity
		if ($spec ? $aseco->allowAbility($player, 'noidlekick_spec')
		          : $aseco->allowAbility($player, 'noidlekick_play'))
			continue;  // go check next player

		// check for spectator kicking
		if ($kickSpecToo || !$spec)
			$player->mistral['idleCount']++;
		if ($idlekick_log)
			$aseco->console("Idlekick: " . $player->login . " set to " . $player->mistral['idleCount']);
	}
}  // kickIdleNewChallenge

// called @ onPlayerConnect
function kickIdleInit($aseco, $player) {
	global $idlekick_debug;

	$player->mistral['idleCount'] = 0;
	if ($idlekick_debug)
		$aseco->console("Idlekick: " . $player->login . " initialised with 0");
}  // kickIdleInit

// called @ onEndRace
function kickIdlePlayers($aseco, $data) {
	global $kickPlayAfter, $kickSpecAfter, $idlekick_debug;

	foreach ($aseco->server->players->player_list as $player) {
		$spec = $aseco->isSpectator($player);
		// check for spectator or player challenge counts
		if ($player->mistral['idleCount'] == ($spec ? $kickSpecAfter
		                                            : $kickPlayAfter)) {
			if ($spec) {
				// log console message
				$aseco->console("Idlekick spectator: " . $player->login . " after " . $kickSpecAfter . " challenge(s) without action.");
				$message = formatText($aseco->getChatMessage('IDLEKICK_SPEC'),
				                      $player->nickname,
				                      $kickSpecAfter, ($kickSpecAfter == 1 ? '' : 's'));
			} else {
				// log console message
				$aseco->console("Idlekick player: " . $player->login . " after " . $kickPlayAfter . " challenge(s) without action.");
				$message = formatText($aseco->getChatMessage('IDLEKICK_PLAY'),
				                      $player->nickname,
				                      $kickPlayAfter, ($kickPlayAfter == 1 ? '' : 's'));
			}
			// show chat message
			$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
         // kick idle player
               $rtn = $aseco->client->query('ForceSpectator', $player->login, 1);
               sleep(1);
                  // allow spectator to switch back to player
                  $rtn = $aseco->client->query('ForceSpectator', $player->login, 0);
                  sleep(1);  // wait for server to process spectator switch
		}
		elseif ($idlekick_debug)
			$aseco->console("Idlekick: " . $player->login . " current value is " . $player->mistral['idleCount']);
	}
}
?>
and the force-part code of chat.admin.php:

Code: Select all

	/**
	 * Forces player into free camera spectator (TMF).
	 */
	} elseif ($command['params'][0] == 'forcespec' && $command['params'][1] != '') {

		if ($aseco->server->getGame() == 'TMF') {
			// get player information
			if ($target = $aseco->getPlayerParam($admin, $command['params'][1])) {
		if (!$aseco->isSpectator($target)) {
          // force player into spectator
          $rtn = $aseco->client->query('ForceSpectator', $target->login, 1);
          if (!$rtn) {
            trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
          } else {
            // allow spectator to switch back to player
            $rtn = $aseco->client->query('ForceSpectator', $target->login, 0);
            // force free camera mode on spectator
            $aseco->client->addCall('ForceSpectatorTarget', array($target->login, '', 2));
            // log console message
            $aseco->console('{1} [{2}] forces player {3} into spectator!', $logtitle, $login, stripColors($target->nickname));

							// show chat message
							$message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} forces player {#highlite}{3}$z$s{#admin} into spectator!',
							                      $chattitle, $admin->nickname, str_ireplace('$w', '', $target->nickname));
							$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
						}
					}
				} else {
					$message = formatText('{#server}> {#highlite}{1} {#error}is already a spectator!',
					                      stripColors($target->nickname));
					$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
				}
			}
		} else {
			$message = $aseco->getChatMessage('FOREVER_ONLY');
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
		}

	/**
	 * Forces a spectator into free camera mode (TMF).
	 */
	} elseif ($command['params'][0] == 'specfree' && $command['params'][1] != '') {

		if ($aseco->server->getGame() == 'TMF') {
			// get player information
			if ($target = $aseco->getPlayerParam($admin, $command['params'][1])) {
				if ($aseco->isSpectator($target)) {
					// force free camera mode on spectator
					$rtn = $aseco->client->query('ForceSpectatorTarget', $target->login, '', 2);
					if (!$rtn) {
						trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
					} else {
						// log console message
						$aseco->console('{1} [{2}] forces spectator free mode on {3}!', $logtitle, $login, stripColors($target->nickname));

						// show chat message
						$message = formatText('{#server}>> {#admin}{1}$z$s {#highlite}{2}$z$s{#admin} forces spectator free mode on {#highlite}{3}$z$s{#admin} !',
						                      $chattitle, $admin->nickname, str_ireplace('$w', '', $target->nickname));
						$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
					}
				} else {
					$message = formatText('{#server}> {#highlite}{1} {#error}is not a spectator!',
					                      stripColors($target->nickname));
					$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
				}
			}
		} else {
			$message = $aseco->getChatMessage('FOREVER_ONLY');
			$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
		}
Any ideas? What am I doing wrong?

User avatar
Mistral
Pit Crew
Pit Crew
Posts: 1304
Joined: 02 May 2006 15:13
Owned TM-games: tmuf
Contact:

Re: mistral.idlekick.php | Stuck with a problem

Post by Mistral » 11 May 2009 14:05

I dont know why you are using a Xymph XAseco-Plugin in my script.

The above code isnt from my controller at all.

I cant even remember to have any ForceSpectator in my chat.admin.php.

Post Reply