It's done, when it's done! It worked atm. But i must clean the code, prepare for release etc. ;-) Im work only solo on it!
Es wird Zeit für eine kleine Vorschau, für die Entwicklung von Eigenen Modulen. Es wird voraussichtlich zum Wochenende eine PUBLIC-ALPHA geben. Um natürlich in erster Linie das Modul-System unter die Lupe zu nehmen, wie auch alles andere. ;-)
Ich werde mich auch drum bemühen, eine Dokumentation mit beizulegen, wobei der Quellcode eig. sehr selbsterklärend ist. Die Benutzerdaten werden immer über ein Array übergeben und die Änderungen erst beim Ausführen vom Modul übernommen. Es können hier zumindest die Benutzerdaten ausgelesen werden, wie auch die Daten, welche Übermittelt worden sind, vor dem Senden bzw. danach! (
siehe $args['post'][title, subject, sendto])
Code:
<?php
/**
* Module: MyPostModule
*
* @author AUTHOR
* @copyright 2011 (C) by AUTHOR
*
* @license Attribution-NonCommercial-NoDerivs 3.0 Unported <http://creativecommons.org/licenses/by-nc-nd/3.0/>
* @version 1.0.0
*/
class MyPostModule extends Modules {
/**
* This function is required for proper installation.
*
* @access public
* @return array
*/
public function install ()
{
return array(
'modulename' => __CLASS__
,'modulefile' => basename(__FILE__)
,'moduleauthor' => 'AUTHOR'
,'moduleversion' => '1.0.0'
);
}
/**
* This function is needed for running the module.
*
* @param string $event
* @param array $args
*
* @access public
* @return array
*/
public function execute ( $event, $args )
{
switch ($event) {
/**
* With "before" the source code is executed before sending the actual
* action. Here the user can for example the query-level players, or even
* whether the user has been found.
*/
case 'before':
// if user not level 10, return error
if ($args['user']['level'] <= 10) return 'E084';
// if we dont found the user, abort the action - return error
else if (!is_array($args['post'])) return '204';
// last but not least - continue.
else {
// say user, you cant send message to ur self
if ($args['user']['userid'] == $args['post']['userid']) return '205';
}
break;
/**
* With "after" the source code is executed after sending the actual
* action. Here the user can change the amount of gold, as well as install
* in the event of "before" or other queries.
*/
case 'after':
// give user 10 silver for send message
$args['user']['gold']+=10;
break;
}
return $args;
}
}
?>