TrackManiaControl/application/plugins/oldstructure/obstacle.plugin.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2013-11-09 17:23:42 +01:00
<?php
namespace ManiaControl;
/**
* ManiaControl Obstacle Plugin
*
* @author steeffeen
*/
class Plugin_Obstacle extends Plugin {
/**
* Constants
*/
const CB_JUMPTO = 'Obstacle.JumpTo';
const VERSION = '1.0';
/**
* Private properties
*/
2013-11-09 19:26:57 +01:00
private $mc = null;
2013-11-09 17:23:42 +01:00
private $config = null;
/**
* Constuct obstacle plugin
*/
2013-11-09 19:26:57 +01:00
public function __construct($mc) {
$this->mc = $mc;
2013-11-09 17:23:42 +01:00
// Load config
$this->config = Tools::loadConfig('obstacle.plugin.xml');
// Check for enabled setting
if (!Tools::toBool($this->config->enabled)) return;
// Register for jump command
2013-11-09 19:26:57 +01:00
$this->mc->commands->registerCommandHandler('jumpto', $this, 'command_jumpto');
2013-11-09 17:23:42 +01:00
error_log('Obstacle Pugin v' . self::VERSION . ' ready!');
}
/**
* Handle jumpto command
*/
public function command_jumpto($chat) {
$login = $chat[1][1];
$rightLevel = (string) $this->config->jumps_rightlevel;
2013-11-09 19:26:57 +01:00
if (!$this->mc->authentication->checkRight($login, $rightLevel)) {
2013-11-09 17:23:42 +01:00
// Not allowed
2013-11-09 19:26:57 +01:00
$this->mc->authentication->sendNotAllowed($login);
2013-11-09 17:23:42 +01:00
}
else {
// Send jump callback
$params = explode(' ', $chat[1][2], 2);
$param = $login . ";" . $params[1] . ";";
2013-11-09 19:26:57 +01:00
if (!$this->mc->client->query('TriggerModeScriptEvent', self::CB_JUMPTO, $param)) {
trigger_error("Couldn't send jump callback for '" . $login . "'. " . $this->mc->getClientErrorText());
2013-11-09 17:23:42 +01:00
}
}
}
}
?>