Hi!
Here's is first version of my plugin which generates table and shows it to user. It's open source, free and other thigs so you can edit it and release again but please remember to don't forget to write my nick as first creator.
Here's is first version of my plugin which generates table and shows it to user. It's open source, free and other thigs so you can edit it and release again but please remember to don't forget to write my nick as first creator.
<?php
php
class table extends Plugins
{
const NAME = 'Table Plugin Example';
const AUTHOR = 'misiek08';
const VERSION = PHPInSimMod::VERSION;
const DESCRIPTION = 'Plugin to generate button table. Can be used for showing results or other info.';
private $data = array(array('test', 'test2', 'test3'),array('teste', 'teste2', 'teste3'),array('tester', 'tester2', 'tester3'));
private $header = array('1st', '2nd', '3rd');
private $width = 10;
private $height = 8;
private $x = 50;
private $y = 50;
/* Remember about this:
define('IS_X_MIN', 0);
define('IS_X_MAX', 110);
define('IS_Y_MIN', 30);
define('IS_Y_MAX', 170);
*/
public function __construct()
{
$this->registerSayCommand('prism table', 'cmdTable', "Shows defined in code table for used.");
}
public function cmdTable($Msg, $UCID, $packet)
{
$cols = count($this->header);
$rows = count($this->data);
$id = 70;
for($i = 0; $i < $rows; $i++){
for($j = 0; $j < $cols; $j++){
$this->createButton($UCID,
$id,
(($j + 1) * $this->width) + $this->x,
(($i + 1) * $this->height) + $this->y,
$this->width,
$this->height,
$this->data[$i][$j]);
$id ++;
echo (($i + 1) * $this->height) + $this->y . PHP_EOL;
}
}
return PLUGIN_HANDLED;
}
private function createButton($ucid, $id, $x, $y, $w, $h, $text){
$btn = new IS_BTN();
$btn->UCID($ucid)
->L($x)
->T($y)
->ClickID($id)
->W($w)
->H($h)
->Text($text)
->Send();
}
}
?>