I want to request a plugin @itemdestroy just like in EAMOD!
eamod's `@itemdestroy` doesn't include cards
so `@itemdestroy 4001` will not destroy the poring card that already slot into the equipment
the purpose of this mod is just to remove certain ... event related items I guess
.... hmmm ....
upon reading the code, I don't really think this will work ... let me test
#include "common/hercules.h"
#include "map/pc.h"
#include "map/itemdb.h"
#include "map/storage.h"
#include "common/nullpo.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"
HPExport struct hplugin_info pinfo = {
"itemdestroy",
SERVER_TYPE_MAP,
"0.1",
HPM_VERSION,
};
ACMD(itemdestroy) {
int nameid = atoi(message);
if (itemdb->exists(nameid) == 0) {
clif->message(fd, "Enter a Valid Item ID. Usage: @itemdestroy <itemid>");
return false;
}
int i;
struct map_session_data *psd;
struct s_mapiterator *iter = mapit_getallusers();
for (psd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); psd = BL_UCAST(BL_PC, mapit->next(iter))) {
for (i = 0; i < MAX_INVENTORY; ++i) { // Inventory Removal
if (psd->status.inventory
.nameid != nameid)
continue;
pc->delitem(psd, i, psd->status.inventory.amount, 0, 0, LOG_TYPE_COMMAND);
}
for (i = 0; i < MAX_CART; ++i) { // Cart Removal
if (psd->status.cart.nameid != nameid)
continue;
pc->cart_delitem(psd, i, psd->status.cart.amount, 0, LOG_TYPE_COMMAND);
}
for (i = 0; i < VECTOR_LENGTH(psd->storage.item); ++i) { // Storage Removal
struct item *sitem = &VECTOR_INDEX(psd->storage.item, i);
nullpo_ret(sitem);
if (sitem->nameid == nameid)
storage->delitem(psd, i, sitem->amount);
}
storage->close(psd);
if (psd->status.guild_id > 0) { // Guild Storage Removal
gstorage->open(sd);
struct guild_storage *stor;
nullpo_ret(stor=idb_get(gstorage->db, psd->status.guild_id));
for (i = 0; i < MAX_GUILD_STORAGE; ++i) {
if (stor->items.nameid != nameid)
continue;
gstorage->delitem(psd, stor, i, stor->items.amount);
}
gstorage->close(psd);
}
}
mapit->free(iter);
return true;
}
HPExport void plugin_init(void) {
addAtcommand("itemdestroy", itemdestroy);
}
yup doesn't work, the guild storage opens up, and there are delay between map-server and char-server when determine the client actually accessing the guild storage or not
in fact, eamod's item destroy doesn't even include guild storage or mail removal
/*==========================================
Item Removal
*------------------------------------------*/
void pc_item_remove4all(int nameid, bool char_server)
{
if( char_server )
chrif_item_remove4all(nameid);
else
{
struct map_session_data *sd;
struct s_mapiterator* iter;
int index;
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
{
for( index = 0; index < MAX_INVENTORY; index++ )
{ // Inventory Removal
if( sd->status.inventory[index].nameid != nameid )
continue;
pc_delitem(sd, index, sd->status.inventory[index].amount, 0, 0, LOG_TYPE_COMMAND);
}
for( index = 0; index < MAX_CART; index++ )
{ // Cart Removal
if( sd->status.cart[index].nameid != nameid )
continue;
pc_cart_delitem(sd, index, sd->status.cart[index].amount, 0, LOG_TYPE_COMMAND);
}
for( index = 0; index < MAX_STORAGE; index++ )
{ // Storage Removal
if( sd->status.storage.items[index].nameid != nameid )
continue;
storage_delitem(sd, index, sd->status.storage.items[index].amount);
}
for( index = 0; index < MAX_EXTRA_STORAGE; index++ )
{ // Extra Storage
if( sd->status.ext_storage.items[index].nameid != nameid )
continue;
ext_storage_delitem(sd, index, sd->status.ext_storage.items[index].amount);
}
}
mapit_free(iter);
}
}
this idea is fantastic, only in theory, but doesn't work on live server
better just run DELETE syntax from MySQL and remove the item when server is offline