Development
Documentation for UASECO
In this documentation I assume that you have enough PHP skill and you know how to code in OOP, begin to learn PHP and want to write a plugin are not a very good idea!
In this tutorial I use the latest offical release. So it is the best if you start a new plugin with this releases or newer too, to make sure that you do not run into complications.
Development
Start developing for UASECO
For those who want to start to write a own plugin, here is a plugin code base to start with.
What this example plugin exactly does makes not really sense, it is just for demostration of the most used functions, possibilities and requirements. This example already includes the new locales support for UASECO.
You can download this plugin here:
File | Version | Build | Downloads | Author(s) |
---|---|---|---|---|
plugin.example.php | 0.0.3 | 2019-09-30 | 174 | undef.de |
plugins/plugin.example.php
<?php /* * Plugin: PLUGIN_NAME * ~~~~~~~~~~~~~~~~~~~ * » PLUGIN_DESCRIPTION * * ---------------------------------------------------------------------------------- * * LICENSE: This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * ---------------------------------------------------------------------------------- * */ // Start the plugin $_PLUGIN = new PluginCLASSNAME(); /* #///////////////////////////////////////////////////////////////////////# # # #///////////////////////////////////////////////////////////////////////# */ class PluginCLASSNAME extends Plugin { public $config = array(); /* #///////////////////////////////////////////////////////////////////////# # # #///////////////////////////////////////////////////////////////////////# */ public function __construct () { // Describe the Plugin $this->setVersion('PLUGIN_VERSION'); $this->setBuild('PLUGIN_BUILD'); $this->setAuthor('AUTHORNAME'); $this->setCopyright('PLUGIN_COPYRIGHT'); $this->setDescription(new Message('plugin.example', 'plugin_description')); // Add required dependencies $this->addDependence('PluginLocalRecords', Dependence::REQUIRED, '1.0.0', null); $this->addDependence('PluginRaspJukebox', Dependence::WANTED, '1.0.0', null); // Register events to interact on $this->registerEvent('onSync', 'onSync'); $this->registerEvent('onPlayerConnect', 'onPlayerConnect'); // Register chat commands $this->registerChatCommand('hello', 'chat_hello', new Message('plugin.example', 'slash_hello_description'), Player::PLAYERS); } /* #///////////////////////////////////////////////////////////////////////# # # #///////////////////////////////////////////////////////////////////////# */ public function onSync ($aseco) { // Read Configuration if (!$xml = $aseco->parser->xmlToArray('config/example.xml', true, true)) { trigger_error('[CLASSNAME] Could not read/parse config file "config/example.xml"!', E_USER_ERROR); } $this->config = $xml['SETTINGS']; // Check for settings. If missed, setup defaults. if ( !isset($this->config['MY_WIDGET'][0]['POS_X'][0]) ) { $this->config['MY_WIDGET'][0]['POS_X'][0] = -102.02; } if ( !isset($this->config['MY_WIDGET'][0]['POS_Y'][0]) ) { $this->config['MY_WIDGET'][0]['POS_Y'][0] = -22.025; } } /* #///////////////////////////////////////////////////////////////////////# # # #///////////////////////////////////////////////////////////////////////# */ public function onPlayerConnect ($aseco, $player) { // Build message $message = new Message('plugin.example', 'max_records_settings'); // Replace e.g. {1} with these entries $message->addPlaceholders( $player->nickname, $aseco->plugins['PluginLocalRecords']->settings['max_records'] // Demostrate handling with a Dependence::REQUIRED Plugin (without check for existence) ); // sendChatMessage() does automatic replace {#highlite} and {#server} with $FFF from config/UASECO.xml <colors> $message->sendChatMessage($player->login); // Demostrate handling with a Dependence::WANTED Plugin if (isset($aseco->plugins['PluginRaspJukebox']) && !empty($aseco->plugins['PluginRaspJukebox']->jukebox)) { // Build message $message = new Message('plugin.example', 'maps_in_jukebox'); // Show chat message $message->sendChatMessage($login); } } /* #///////////////////////////////////////////////////////////////////////# # # #///////////////////////////////////////////////////////////////////////# */ public function chat_hello ($aseco, $login, $chat_command, $chat_parameter) { // Build message $message = new Message('plugin.example', 'slash_hello_message'); // Show chat message $message->sendChatMessage($player->login); } } ?>
config/example.xml
<?xml version="1.0" encoding="utf-8"?> <settings> <!-- Comment that describes this section //--> <my_widget> <pos_x>-102.02</pos_x> <pos_y>-22.025</pos_y> </my_widget> </settings>
locales/example.xml
<?xml version="1.0" encoding="utf-8"?> <locales> <!-- Version: 2024-10-13 Authors: [EN] AUTHORNAME [DE] AUTHORNAME //--> <plugin_description> <en>Example plugin to start with</en> <de>Beispiel Plug-In zum starten</de> </plugin_description> <slash_hello_description> <en>Display a hello message</en> <de>Zeigt eine "Hallo" Nachricht</de> </slash_hello_description> <max_records_settings> <en>Hello {#highlite}{1}{#server}, the max. records settings are: </en> <de>Hallo {#highlite}{1}{#server}, die Einstellung für die max. Anzahl an Rekorden ist: </de> </max_records_settings> <maps_in_jukebox> <en>There are Maps in the Jukebox!</en> <de>Es sind Strecken in der Wiedergabeliste!</de> </maps_in_jukebox> <slash_hello_message> <en>{#server}» {#highlite}Hello dude!</en> <de>{#server}» {#highlite}Hallo Freund!</de> </slash_hello_message> </locales>
Please note that you have to replace all BLUE marked parts with your own names/notices...
You can include a other license also, if the GPL3 does not fit your wishes.
Development
Start developing for UASECO
The most of the settings of a Modescript changed from a server controller are resetted to the default values on a voted or forced Map restart. This list are affected ListMethods/Triggers and has to be send/set again after a map restart. For details see the post from Eole at the closed beta forum.
- SetModeScriptSettings (
ListMethod
) - UI_DisplaySmallScoresTable (
TriggerModeScriptEvent
) - LibScoresTable2_SetStyleFromXml (
TriggerModeScriptEventArray
) - Rounds_SetPointsRepartition (
TriggerModeScriptEventArray
)
This is a private enthusiast Website. Maniaplanet, Trackmania, Shootmania, Nadeo are trademarks of Ubisoft Entertainment.
Windows is a registered trademark of Microsoft Corporation.