- Add/remove ressource with associated comment. ressources can be removed from ingame blob.
- Spam announce every 2hours in guild chat, can be modified at the beginning of the module.
i don't know how it will work with russian language, feedback welcome.
credits: this module is a version of a modified module find in this forum all credits goes to the author.
English:
<?php
$city = new city($bot);
class city Extends BaseActiveModule
{
var $bot;
var $city_list;
function __construct ($bot)
{
parent::__construct($bot, get_class($this));
// Interval for GUILD CHAT SPAM (1hour, 2hour, 3hour ...)
$this -> register_event("cron","2hour");
$this -> register_command("all", "city", "MEMBER", array('add' => 'MEMBER', 'del' => 'MEMBER'));
$this -> help['command']['city'] = "Show the list of ressources needed for Guild City";
$this -> help['command']['city add <ressource> : <comment>'] = "Add a ressource with a comment.";
$this -> help['command']['city del <ressource>'] = "Delete a ressource";
$this -> help['notes'] = "Deletion can be done from the ingame script interface";
$this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS `citylist` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`ressource` VARCHAR( 100 ) NOT NULL ,
`addedby` VARCHAR( 100 ) NOT NULL ,
`reason` VARCHAR( 255 ) NULL ,
PRIMARY KEY ( `id` )
);"
);
$this -> load_city();
}
function command_handler($name, $msg, $origin)
{
if (preg_match("/^city$/i", $msg))
return $this -> show_city();
else if (preg_match("/^city del (.*)$/i", $msg, $info))
return $this -> delete_city($info[1]);
// else if (preg_match("/^city add (([0-9]|[a-z]|[A-Z]| )+):(.*)$/i", $msg, $info)) //
else if (preg_match("/^city add (([a-zA-ZàâçèéêîôùûÄÆÇÊÌÍÎÏÒÓÔÕÖØÙÚÛÜÝáãäåæçëìíïñòóôõöøùúûüýÿ0-9]| )+):(.*)$/i", $msg, $info))
return $this -> add_city($name, $info[1], $info[3]);
else return "Unknown command. Consult help: <pre>help city";
}
function show_city()
{
if (empty($this -> city_list))
{
return "No ressource, add one. Consult help: <pre>help city.";
}
$blob = "<center><IMG SRC=rdb://3987520><br><font color='#f35f00' face='headline'>Guild City</font><BR><font color='#58933D'>Ressource needs</font></center>";
foreach ($this -> city_list AS $rcity)
{
$ressource = ucfirst($rcity['ressource']);
$line = "<BR>";
$supr = "<a href='chatcmd:///tell <botname> <pre>city del $ressource' STYLE=text-decoration:none><font face='small' color='#8A8A89'>[Delete]</font></a>";
$blob .= "\n<font color='#f35f00'>Ressource: </font><font color='#b7b7b7'>$ressource</font>";
empty($rcity['reason']) ? $reason = "none" : $reason = $rcity['reason'];
$blob .= "\n<font color='#f35f00'>Comment: </font></font><font color='#b7b7b7'>$reason</font>";
$addedby = ucfirst($rcity['addedby']);
$blob .= "\n$supr<font face='small' color='#585858'> Added by: $addedby</font>$line";
}
$help = "<a href='chatcmd:///tell <botname> <pre>help city' STYLE=text-decoration:none><font color='#58933D'>Help</font></a>";
$reload = "<a href='chatcmd:///tell <botname> <pre>city' STYLE=text-decoration:none><font color='#58933D'>Reload</font></a>";
$blob .= "<BR><center>$help | $reload</center>";
return "<font face='hyboriansmall' color=red>Guild City Needs :: </font>" . $this -> bot -> core("tools") -> make_blob("<IMG SRC=rdb://3987520>Show", $blob);
}
function add_city($name, $ressource, $reason)
{
$ressource = strtolower($ressource);
$result = $this -> bot -> db -> select("SELECT * FROM citylist WHERE ressource = '$ressource'");
if (!empty($result))
{
return ucfirst($ressource) . " :: This ressource already exist.";
}
$reason = trim($reason);
$this -> bot -> db -> query("INSERT INTO citylist (ressource, addedby, reason) VALUES ('$ressource', '$name', '$reason')");
$this -> load_city();
return ucfirst($ressource) . " :: Added to ressource list.";
}
function delete_city($ressource)
{
$ressource = strtolower($ressource);
$result = $this -> bot -> db -> select("SELECT * FROM citylist WHERE ressource = '$ressource'");
if (empty($result))
{
return ucfirst($ressource) . " :: This ressource doesn't exist.";
}
$this -> bot -> db -> query("DELETE FROM citylist WHERE ressource = '$ressource'");
$this -> load_city();
return ucfirst($ressource) . " :: Ressource deleted.";
}
function load_city()
{
$result = $this -> bot -> db -> select("SELECT * FROM citylist ORDER BY ressource ASC");
if (!empty($result))
{
$a = array();
foreach ($result AS $row)
{
$a[] = array('ressource' => $row[1], 'addedby' => $row[2], 'reason' => $row[3]);
}
$this -> city_list = $a;
}
else
{
$this -> city_list = array();
}
}
function cron($interval)
{
$this->bot->send_gc($this->show_city());
}
}
?>
French:
<?php
$city = new city($bot);
class city Extends BaseActiveModule
{
var $bot;
var $city_list;
function __construct ($bot)
{
parent::__construct($bot, get_class($this));
// Interval pour les répetion du message dans le chat guilde.
$this -> register_event("cron","3hour");
$this -> register_command("all", "city", "MEMBER", array('add' => 'MEMBER', 'del' => 'MEMBER'));
$this -> help['command']['city'] = "Afficher les besoins en ressource en cours pour la ville de Guilde.";
$this -> help['command']['city add <ressource> : <commentaire>'] = "Ajouter une ressource et un commentaire associé.";
$this -> help['command']['city del <ressource>'] = "Supprimer une ressource.";
$this -> help['notes'] = "La suppression de ressource se fait également depuis l'interface graphique du jeu.";
$this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS `citylist` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`ressource` VARCHAR( 100 ) NOT NULL ,
`addedby` VARCHAR( 100 ) NOT NULL ,
`reason` VARCHAR( 255 ) NULL ,
PRIMARY KEY ( `id` )
);"
);
$this -> load_city();
}
function command_handler($name, $msg, $origin)
{
if (preg_match("/^city$/i", $msg))
return $this -> show_city();
else if (preg_match("/^city del (.*)$/i", $msg, $info))
return $this -> delete_city($info[1]);
// else if (preg_match("/^city add (([0-9]|[a-z]|[A-Z]| )+):(.*)$/i", $msg, $info)) //
else if (preg_match("/^city add (([a-zA-ZàâçèéêîôùûÄÆÇÊÌÍÎÏÒÓÔÕÖØÙÚÛÜÝáãäåæçëìíïñòóôõöøùúûüýÿ0-9]| )+):(.*)$/i", $msg, $info))
return $this -> add_city($name, $info[1], $info[3]);
else return "Commande inconnue. Consultez l'aide: <pre>help city";
}
function show_city()
{
if (empty($this -> city_list))
{
return "Aucun besoin en ressource pour la Ville. Consultez l'aide: <pre>help city.";
}
$blob = "<center><IMG SRC=rdb://3987520><br><font color='#f35f00' face='headline'>Village de Guilde</font><BR><font color='#58933D'>Ressources nécessaires</font></center>";
foreach ($this -> city_list AS $rcity)
{
$ressource = ucfirst($rcity['ressource']);
$line = "<BR>";
$supr = "<a href='chatcmd:///tell <botname> <pre>city del $ressource' STYLE=text-decoration:none><font face='small' color='#8A8A89'>[Supprimer]</font></a>";
$blob .= "\n<font color='#f35f00'>Ressource: </font><font color='#b7b7b7'>$ressource</font>";
empty($rcity['reason']) ? $reason = "none" : $reason = $rcity['reason'];
$blob .= "\n<font color='#f35f00'>Commentaire: </font></font><font color='#b7b7b7'>$reason</font>";
$addedby = ucfirst($rcity['addedby']);
$blob .= "\n$supr<font face='small' color='#585858'> Ajouté par: $addedby</font>$line";
}
$help = "<a href='chatcmd:///tell <botname> <pre>help city' STYLE=text-decoration:none><font color='#58933D'>Aide</font></a>";
$reload = "<a href='chatcmd:///tell <botname> <pre>city' STYLE=text-decoration:none><font color='#58933D'>Recharger</font></a>";
$blob .= "<BR><center>$help | $reload</center>";
return "<font face='hyboriansmall' color=red>Besoins Pour le Village de Guilde :: </font>" . $this -> bot -> core("tools") -> make_blob("<IMG SRC=rdb://3987520>Afficher", $blob);
}
function add_city($name, $ressource, $reason)
{
$ressource = strtolower($ressource);
$result = $this -> bot -> db -> select("SELECT * FROM citylist WHERE ressource = '$ressource'");
if (!empty($result))
{
return ucfirst($ressource) . " :: Cette ressource existe déjà dans la liste.";
}
$reason = trim($reason);
$this -> bot -> db -> query("INSERT INTO citylist (ressource, addedby, reason) VALUES ('$ressource', '$name', '$reason')");
$this -> load_city();
return ucfirst($ressource) . " :: Ajouté à la liste des ressources.";
}
function delete_city($ressource)
{
$ressource = strtolower($ressource);
$result = $this -> bot -> db -> select("SELECT * FROM citylist WHERE ressource = '$ressource'");
if (empty($result))
{
return ucfirst($ressource) . " :: Cette ressource n'éxiste pas.";
}
$this -> bot -> db -> query("DELETE FROM citylist WHERE ressource = '$ressource'");
$this -> load_city();
return ucfirst($ressource) . " :: Ressource supprimée.";
}
function load_city()
{
$result = $this -> bot -> db -> select("SELECT * FROM citylist ORDER BY ressource ASC");
if (!empty($result))
{
$a = array();
foreach ($result AS $row)
{
$a[] = array('ressource' => $row[1], 'addedby' => $row[2], 'reason' => $row[3]);
}
$this -> city_list = $a;
}
else
{
$this -> city_list = array();
}
}
function cron($interval)
{
$this->bot->send_gc($this->show_city());
}
}
?>