Enchanting
#31
The IsEnchantable() function is used only in the older protocol versions that didn't support enchantments on all items; with current protocols any item could be enchanted, so you should use the normal approach:
When a player places an item in the enchantment slot, ask plugins using a hook to give you the list of enchantments available for this item. The plugins should modify a list of enchantments that the server can choose from for the item.
When the player chooses the enchantment cost, find the (default) enchantments that the server would give the item, then fire a plugin hook saying user is about to enchant something at a specified cost, letting the plugins to modify the final enchantments.

HOOK_GET_APPLICABLE_ENCHANTMENTS: Called when the player places an item in the enchantment table's slot
Receives arguments:
- the player
- the item
- array-table of cEnchantments, each containing a single allowed enchantment (represented as std::vector<cEnchantments> in the C++ code); the server initializes this to the default list of enchantments applicable for that item
Return values:
- continue hook execution (bool) - when true, no more hooks in the chain are called (if not given, false if assumed)
- array-table of cEnchantments, each containing a single allowed enchantment (if not given, the default list given in the parameter is assumed)
After the hook returns, the server stores the list of applicable enchantments in the cPlayer object, so that it can retrieve it later, and displays the XP costs, if applicable.

HOOK_ENCHANTING_ITEM: Called when the player chooses the XP cost in the enchantment table's UI
Receive arguments:
- the player
- the item
- the XP cost that the player has chosen
- single cEnchantments class containing all the enchantments that the item will receive, initialized by the server from the list of applicable enchantments; plugins may directly modify this object
Return values:
- continue hook execution (bool) - when true, no more hooks in the chain are called (if not given, false if assumed)
Reply
Thanks given by: daniel0916


Messages In This Thread
Enchanting - by daniel0916 - 01-19-2014, 09:05 PM
RE: Enchanting - by NiLSPACE - 01-19-2014, 09:17 PM
RE: Enchanting - by daniel0916 - 01-19-2014, 09:39 PM
RE: Enchanting - by tonibm19 - 01-20-2014, 12:07 AM
RE: Enchanting - by xoft - 01-20-2014, 12:16 AM
RE: Enchanting - by daniel0916 - 01-20-2014, 02:03 AM
RE: Enchanting - by tonibm19 - 01-20-2014, 03:05 AM
RE: Enchanting - by daniel0916 - 01-20-2014, 03:30 AM
RE: Enchanting - by daniel0916 - 01-20-2014, 05:45 AM
RE: Enchanting - by tonibm19 - 01-20-2014, 06:02 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 12:35 AM
RE: Enchanting - by tonibm19 - 01-21-2014, 01:58 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 02:05 AM
RE: Enchanting - by tonibm19 - 01-21-2014, 02:53 AM
RE: Enchanting - by NiLSPACE - 01-21-2014, 02:58 AM
RE: Enchanting - by ThuGie - 01-21-2014, 03:03 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 03:24 AM
RE: Enchanting - by ThuGie - 01-21-2014, 03:38 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 03:43 AM
RE: Enchanting - by tonibm19 - 01-21-2014, 03:43 AM
RE: Enchanting - by ThuGie - 01-21-2014, 03:47 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 03:56 AM
RE: Enchanting - by ThuGie - 01-21-2014, 04:02 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 04:16 AM
RE: Enchanting - by ThuGie - 01-21-2014, 04:21 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 04:27 AM
RE: Enchanting - by bearbin - 01-21-2014, 05:04 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 05:15 AM
RE: Enchanting - by tigerw - 01-21-2014, 09:17 AM
RE: Enchanting - by daniel0916 - 01-21-2014, 10:57 PM
RE: Enchanting - by xoft - 01-22-2014, 12:54 AM
RE: Enchanting - by daniel0916 - 01-22-2014, 01:29 AM
RE: Enchanting - by xoft - 01-22-2014, 07:27 AM
RE: Enchanting - by daniel0916 - 01-22-2014, 08:03 AM
RE: Enchanting - by xoft - 01-22-2014, 08:05 AM
RE: Enchanting - by daniel0916 - 01-23-2014, 12:59 AM
RE: Enchanting - by xoft - 01-26-2014, 04:08 AM
RE: Enchanting - by daniel0916 - 01-26-2014, 06:23 AM
RE: Enchanting - by xoft - 01-26-2014, 07:51 AM
RE: Enchanting - by daniel0916 - 01-26-2014, 05:58 PM
RE: Enchanting - by xoft - 01-26-2014, 08:58 PM
RE: Enchanting - by daniel0916 - 01-26-2014, 11:23 PM
RE: Enchanting - by daniel0916 - 01-26-2014, 10:10 PM
RE: Enchanting - by xoft - 01-27-2014, 01:58 AM
RE: Enchanting - by daniel0916 - 01-27-2014, 05:06 AM
RE: Enchanting - by xoft - 01-27-2014, 05:39 AM
RE: Enchanting - by daniel0916 - 01-27-2014, 05:52 AM
RE: Enchanting - by tigerw - 01-27-2014, 06:51 AM
RE: Enchanting - by daniel0916 - 01-28-2014, 05:38 AM
RE: Enchanting - by xoft - 01-28-2014, 05:55 AM
RE: Enchanting - by daniel0916 - 01-28-2014, 06:14 AM
RE: Enchanting - by xoft - 01-28-2014, 06:41 AM
RE: Enchanting - by daniel0916 - 01-31-2014, 12:04 AM
RE: Enchanting - by daniel0916 - 02-01-2014, 03:14 AM
RE: Enchanting - by tigerw - 02-01-2014, 04:11 AM
RE: Enchanting - by NiLSPACE - 02-01-2014, 04:13 AM
RE: Enchanting - by daniel0916 - 02-01-2014, 04:48 AM
RE: Enchanting - by ThuGie - 02-01-2014, 05:10 AM
RE: Enchanting - by daniel0916 - 02-01-2014, 07:48 AM
RE: Enchanting - by ThuGie - 02-01-2014, 11:38 AM
RE: Enchanting - by daniel0916 - 02-01-2014, 05:17 PM
RE: Enchanting - by ThuGie - 02-01-2014, 08:36 PM
RE: Enchanting - by daniel0916 - 04-08-2014, 04:35 AM
RE: Enchanting - by tonibm19 - 04-08-2014, 04:39 AM
RE: Enchanting - by bearbin - 04-08-2014, 04:48 AM
RE: Enchanting - by daniel0916 - 04-09-2014, 12:23 AM
RE: Enchanting - by daniel0916 - 04-12-2014, 10:48 PM
RE: Enchanting - by NiLSPACE - 04-12-2014, 10:53 PM
RE: Enchanting - by xoft - 04-12-2014, 10:55 PM
RE: Enchanting - by daniel0916 - 04-12-2014, 11:06 PM
RE: Enchanting - by LO1ZB - 04-12-2014, 11:45 PM
RE: Enchanting - by LO1ZB - 04-12-2014, 11:28 PM
RE: Enchanting - by daniel0916 - 04-12-2014, 11:35 PM
RE: Enchanting - by daniel0916 - 04-12-2014, 11:59 PM
RE: Enchanting - by LO1ZB - 04-13-2014, 12:13 AM
RE: Enchanting - by daniel0916 - 04-13-2014, 12:28 AM
RE: Enchanting - by LO1ZB - 04-13-2014, 12:39 AM
RE: Enchanting - by daniel0916 - 04-13-2014, 02:03 AM
RE: Enchanting - by LO1ZB - 04-13-2014, 02:40 AM
RE: Enchanting - by daniel0916 - 04-13-2014, 02:53 AM
RE: Enchanting - by tonibm19 - 04-13-2014, 04:55 AM
RE: Enchanting - by daniel0916 - 04-13-2014, 06:15 AM
RE: Enchanting - by daniel0916 - 04-13-2014, 09:37 PM
RE: Enchanting - by daniel0916 - 04-14-2014, 01:42 AM
RE: Enchanting - by xoft - 04-14-2014, 01:52 AM
RE: Enchanting - by daniel0916 - 04-14-2014, 06:12 AM
RE: Enchanting - by daniel0916 - 04-15-2014, 01:01 AM
RE: Enchanting - by daniel0916 - 04-16-2014, 10:05 PM
RE: Enchanting - by daniel0916 - 04-17-2014, 05:11 AM
RE: Enchanting - by NiLSPACE - 04-17-2014, 05:31 AM
RE: Enchanting - by xoft - 04-17-2014, 05:43 AM
RE: Enchanting - by daniel0916 - 04-17-2014, 05:59 AM
RE: Enchanting - by xoft - 04-17-2014, 03:09 PM
RE: Enchanting - by daniel0916 - 04-18-2014, 10:51 PM
RE: Enchanting - by daniel0916 - 04-19-2014, 07:36 PM
RE: Enchanting - by xoft - 04-19-2014, 09:17 PM
RE: Enchanting - by daniel0916 - 04-19-2014, 09:36 PM
RE: Enchanting - by xoft - 04-19-2014, 10:51 PM
RE: Enchanting - by daniel0916 - 04-19-2014, 11:07 PM
RE: Enchanting - by daniel0916 - 04-25-2014, 11:02 PM
RE: Enchanting - by SamJBarney - 04-26-2014, 04:31 AM
RE: Enchanting - by daniel0916 - 04-26-2014, 04:36 AM
RE: Enchanting - by tigerw - 04-26-2014, 06:33 AM
RE: Enchanting - by xoft - 04-26-2014, 07:00 AM
RE: Enchanting - by SamJBarney - 04-26-2014, 11:25 AM
RE: Enchanting - by daniel0916 - 04-27-2014, 12:16 AM
RE: Enchanting - by tigerw - 04-27-2014, 07:34 AM
RE: Enchanting - by daniel0916 - 04-28-2014, 03:34 AM
RE: Enchanting - by xoft - 04-28-2014, 07:25 AM
RE: Enchanting - by tonibm19 - 06-18-2014, 12:49 AM



Users browsing this thread: 18 Guest(s)