collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Culture Item Recipe Book / or Guild crafters Module  (Read 6743 times)

0 Members and 1 Guest are viewing this topic.

Offline Monk4y

  • BeBot User
  • **
  • Posts: 23
  • Karma: +0/-0
Culture Item Recipe Book / or Guild crafters Module
« on: February 26, 2009, 04:08:58 am »
I have a suggestion for a module.

Description:
The recent introduction of many new crafting recipes to age of conan has introduced a small problem. Nobody knows who has what crafting recipe! This module would show a list each recipe by level, category, crafter(s) and ingredients. It should also contain an itemref link.

Example:
Category Weapon
[Final Say] 80 Crafters: Bob, Jim & Terry
Components: 10 Iron, 6 Oak, 3 Gold & 1 Platinum.

[The Judge] 80 Crafters: Bob
Components: 20 Iron, 16 Oak, 30 Gold & 10 Platinum.

Category Shield
[Medusa's Bane] 80 Crafters: Terry
Components: 30 Iron, 30 Gold, 10 Platinum & 10 Flawless Diamonds.

Commands:

!gcraft (Can be used in tells, privategroup and guildchat)
Lists each item that has been submitted as craftable by a member. A drag and drop function would be very usefull. Subcommands, of add, delete, notes for each item, maybe a way to list ingredients

!admincraft (Can be used in tells, privategroup and guildchat)
For admins to edit items, the notes for the items. To delete obsolete or incorrectly subbmitted items.

thanks for reading.

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Culture Item Recipe Book / or Guild crafters Module
« Reply #1 on: February 26, 2009, 07:49:40 am »
Important before this will be effective is to have the database updated.. :/

Wizhk

Offline jimango

  • BeBot User
  • **
  • Posts: 36
  • Karma: +0/-0
Re: Culture Item Recipe Book / or Guild crafters Module
« Reply #2 on: February 26, 2009, 09:46:51 am »
In my guild we have revrote the !gitems module to do this..
We only need to add the mats needed ;)

But we dont know very much about php-coding, so we have a problem solving a access problem,
the problem is that only i as owner can add recipes to the list..
Probably a small problem that someone can help us with, but no respond at it yet :(


If someone can look at it the code is:

Code: [Select]
<?PHP

$gitems = new GuildItems($bot);

class GuildItems Extends BaseActiveModule {

var $bot;
var $items_list; //Variable to contain list of items.

function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));


$this -> bot -> db -> query("
CREATE TABLE IF NOT EXISTS " . $this->bot->db->define_tablename("guild_items", "false") .
" (id int(11) NOT NULL auto_increment,
item_name varchar(50) NOT NULL,
item_id varchar(20) NOT NULL,
item_ql varchar(3) NOT NULL,
item_color varchar(300) NOT NULL,
item_cat enum('Armor Cloth', 'Armor Silk', 'Armor Light','Armor Medium','Armor Heavy','Armor Plate','Armor Shields','Armor Back','Weapons 1HE','Weapons 2HE','Weapons 1HB','Weapons 2HB','Weapons Daggers','Weapons Polearms','Weapons Staves','Weapons Bows','Weapons Arrows','Weapons Crossbows','Weapons Bolts','Weapons Thrown','Misc Necklaces','Misc Rings','Misc Talismans','Potions Mana','Potions Stamina','Potions Health','Consumable Mana','Consumable Stamina','Consumable Health','Gems Rhombic','Gems Trillion','Gems Oval','Gems Teardrop','Gems Oblique','Gems Cabochon') NOT NULL,
item_addedby varchar(100) NOT NULL,
PRIMARY KEY  (id))");

$this -> bot -> core("settings") -> create ("Guild_Items", "Item_Del", "ADMIN", "Who should be able to delete items?", "SUPERADMIN;ADMIN");

$this -> help['description'] = 'Keeps track of what items the Guild currently can craft to its members';
$this -> help['command']['gitems'] = 'Shows a list of all the items the Guild owns.';
$this -> help['command']['gitems add <category1> <category2> <itemlink>'] = 'Adds an item to the list.';
$this -> help['notes'] = 'Created by Durroch - Invictrum Guild Leader - US-Derketo<br />Adapted by Taxoman and Jimango - Auditor Fortuna Juvat - Guild at EU-Crom<br />to work with crafting recipes, showing crafters name<br /><br />When using the Add sub-command to add an item (i.e. !gitems add Armor Heavy &lt;itemlink&gt;) to the Guild Items list please use the following categories:<br />Armor Cloth<br />Armor Silk<br />Armor Light<br />Armor Medium<br />Armor Heavy<br />Armor Plate<br />Armor Shields<br />Armor Back<br />Weapons 1HE<br />Weapons 2HE<br />Weapons 1HB<br />Weapons 2HB<br />Weapons Daggers<br />Weapons Polearms<br />Weapons Staves<br />Weapons Bows<br />Weapons Arrows<br />Weapons Crossbows<br />Weapons Bolts<br />Weapons Thrown<br />Misc Necklaces<br />Misc Rings<br />Misc Talismans<br />Potions Mana<br />Potions Stamina<br />Potions Health<br />Consumable Mana<br />Consumable Stamina<br />Consumable Health<br />Gems Rhombic<br />Gems Trillion<br />Gems Oval<br />Gems Teardrop<br />Gems Oblique<br />Gems Cabochon';

$this -> bot -> core("colors") -> define_scheme("gitems", "highlight1", "White");
$this -> bot -> core("colors") -> define_scheme("gitems", "highlight2", "Green");
$this -> bot -> core("colors") -> define_scheme("gitems", "heading1", "White");
$this -> bot -> core("colors") -> define_scheme("gitems", "heading2", "Gold");


$this -> register_command('all', 'gitems', 'MEMBER', array('add' => 'MEMBER', 'del' => 'ADMIN'));

$this -> load_gitems();
}

function command_handler($name, $msg, $origin)
{
$this -> error -> reset(); //Reset the error message so we don't trigger the handler by old error messages.

$com = $this -> parse_com($msg, array('com', 'sub', 'arg1', 'arg2', 'arg3'));

switch($com['sub'])
{
case 'add':
return $this -> add_gitems($name, $com['arg1'] . ' ' . $com['arg2'], $com['arg3']);
break;
case 'del':
return $this -> del_gitems($name, $com['arg1']);
break;
default:
return $this -> show_gitems($name);
break;
}
}

//Generate item link in color
function itemlink($link, $color, $title)
{
return "<a style='text-decoration:none' href='chatcmd:///tell " . $this -> bot -> botname . " <pre>" . $link . "'><font color=#" . $color . ">" . $title . "</font></a>";
}

//Parse an item
function parseitem($item)
{
preg_match_all("/(<a style=\"text-decoration:none\" href=\"itemref:\/\/([0-9]*)\/([0-9]*)\/([0-9]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\/([0-9a-f]*\:[0-9a-f]*\:[0-9a-f]*:[0-9a-f]*)\"><font color=#([0-9a-f]*)>\[([\-\-a-zA-Z0-9_'&\s]*)\]<\/font><\/a>)/i", $item, $matches,PREG_SET_ORDER);
foreach ($matches as $match)
{
$a[id] = $match[2];
$a[ql] = $match[4];
$a[color] = $match[7];
$a[name] = $match[8];
}
return $a;
}

//Loads the Guild Items into items_list
function load_gitems()
{
$result = $this -> bot -> db -> select("SELECT * FROM #___guild_items ORDER BY item_cat, item_name");
if (!empty($result))
{
$a = array();
foreach ($result AS $row)
{
$a[] = array('id' => $row[0], 'item_name' => $row[1], 'item_id' => $row[2], 'item_ql' => $row[3], 'item_color' => $row[4], 'item_cat' => $row[5], 'item_addedby' => $row[6]);
}
$this -> items_list = $a;
}
else
{
$this -> items_list = array();
}
}


//Shows Guild Items List
function show_gitems($name)
{
if (empty($this -> items_list)) return "There are currently no Guild Items.";

$blob = "<font color='SILVER' face='hyborianlarge'>:: Available Crafted Items In Guild ::</font>\n";
if (!empty($this -> items_list))
{
$item_cat = "";
$item_cat2 = "";
foreach ($this -> items_list AS $items)
{
$item_category = preg_split('/ /', $items['item_cat']);
if ($this -> bot -> core("security") -> check_access($name, $this -> bot -> core("settings") -> get('Guild_Items', 'Item_Del')))
{
$delete = "##gitems_highlight1##|##end## [ " . $this -> bot -> core("tools") -> chatcmd("gitems del $items[id]", "Delete") . " ]";
}
$itemlink = $this -> itemlink("item $items[item_id]", "$items[item_color]", "$items[item_name]");
if($item_cat<>$item_category[0])
{
$blob .= "\n##gitems_heading1##$item_category[0]##end##\n";
if($item_cat2<>$item_category[1])
{
$blob .= "&nbsp;&nbsp;##gitems_heading2##$item_category[1]##end##\n";
$blob .= "&nbsp;&nbsp;&nbsp;&nbsp;$itemlink ##gitems_highlight1##|##end## ##gitems_highlight2##QL:##end## $items[item_ql] ##gitems_highlight1##|##end## ##gitems_highlight2##Added by:##end## $items[item_addedby] $item_loaned $delete\n";
} else {
$blob .= "&nbsp;&nbsp;&nbsp;&nbsp;$itemlink ##gitems_highlight1##|##end## ##gitems_highlight2##QL:##end## $items[item_ql] ##gitems_highlight1##|##end## ##gitems_highlight2##Added by:##end## $items[item_addedby] $item_loaned $delete\n";
}
$item_cat2 = $item_category[1];
} else {
if($item_cat2<>$item_category[1])
{
$blob .= "&nbsp;&nbsp;##gitems_heading2##$item_category[1]##end##\n";
$blob .= "&nbsp;&nbsp;&nbsp;&nbsp;$itemlink ##gitems_highlight1##|##end## ##gitems_highlight2##QL:##end## $items[item_ql] ##gitems_highlight1##|##end## ##gitems_highlight2##Added by:##end## $items[item_addedby] $item_loaned $delete\n";
} else {
$blob .= "&nbsp;&nbsp;&nbsp;&nbsp;$itemlink ##gitems_highlight1##|##end## ##gitems_highlight2##QL:##end## $items[item_ql] ##gitems_highlight1##|##end## ##gitems_highlight2##Added by:##end## $items[item_addedby] $item_loaned $delete\n";
}
$item_cat2 = $item_category[1];
}
$item_cat = $item_category[0];
}
}
return $this -> bot -> core("tools") -> make_blob("Guild Items", $blob);
}


//Add items to Guild Item list
function add_gitems($name, $item_cat, $arg)
{
$item = $this -> parseitem($arg);
$item_name = str_replace("'", "\'", $item[name]);

$result = $this -> bot -> db -> select("SELECT * FROM #___guild_items WHERE item_id = '$item[id]'");
##if (!empty($result))
##{
## $this -> error -> set($arg . " is already in the database.");
## return $this -> error;
#}
$this -> bot -> db -> query("INSERT INTO #___guild_items (item_id, item_name, item_color, item_ql, item_cat, item_addedby) VALUES ('$item[id]', '$item_name', '$item[color]', '$item[ql]', '$item_cat', '$name')");
$this -> load_gitems();
return "Thank you " . $name . ", " . $arg . " was added to Guild Items list.";
}


//Remove items from Guild Item list
function del_gitems($name, $id)
{
if (empty($id)) return "You did not input an ID, please try again with the correct format.";
$result = $this -> bot -> db -> select("SELECT * FROM #___guild_items WHERE id = '$id'");
if (empty($result)) return "Sorry, that item does not exist.";

$this -> bot -> db -> query("DELETE FROM #___guild_items WHERE id = '$id'");
$this -> load_gitems();
return "Thank you " . $name . ", " . $id . " was removed from Guild Items list.";
}

}

?>



We will add mats needed for crafting and consumables ;)
« Last Edit: February 27, 2009, 10:14:07 am by jimango »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Culture Item Recipe Book / or Guild crafters Module
« Reply #3 on: February 26, 2009, 07:47:52 pm »
You should go back to the register_command() call with subcommands, it's the way it should be done for access rights. Instead of that setting, which isn't used anyways I believe.

And did you check !commands for the access rights of !gitems? Can't remember the syntax out of my head, but you should get an interface where you can select a channel (take All if in doubt), and then the commands and the access rights.

Offline jimango

  • BeBot User
  • **
  • Posts: 36
  • Karma: +0/-0
Re: Culture Item Recipe Book / or Guild crafters Module
« Reply #4 on: February 27, 2009, 08:36:33 am »
Ok, thank u it worked, now we will just add the mats needed and its done i think..

Exept when i did the "!commands subs gitems" i saw the old commands to the module, why?
i thougt we have take them away..
Does it store in an other database?

I dont know much about php-coding, so ill ask the guy in our guild that helps us as well, even tho he feels a bit rusty himself ;)

I have edited the code to the old register_command() now
I also made it possible for more then one member to add the same item
( i just marked out this function for u to see, and maby disagree
« Last Edit: February 27, 2009, 10:16:31 am by jimango »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Culture Item Recipe Book / or Guild crafters Module
« Reply #5 on: February 27, 2009, 05:02:20 pm »
Exept when i did the "!commands subs gitems" i saw the old commands to the module, why?
i thougt we have take them away..
Does it store in an other database?

I have edited the code to the old register_command() now
I also made it possible for more then one member to add the same item
( i just marked out this function for u to see, and maby disagree
Access rights for subcommands are stored in the db too, like all access rights. And currently there is no way except directly accessing the table to remove an entry in there.

And otherwise your function looks ok - though no guarantees, I haven't run your code ;)

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

* Who's Online
  • Dot Guests: 71
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal