Jump to content
  • 0
keough

@itemdestroy

Question

I want to request a plugin @itemdestroy just like in EAMOD!

 

When you use @itemdestroy it will destroy the item in the whole server whether it is in Inventory / Cart Inventory / Storage / Mail

 

usage: @itemdestroy <Item ID or Item Name>

It will totally destroy the item and vanish it from the server and no one will have it in an instant once you use this command just like in eaMOD

Link - https://github.com/zephyrus-cr/eamod/search?q=itemdestroy

 

This will be useful to everyone when there is a limited event.

Edited by keough

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

  • 0
On 11/20/2020 at 4:02 AM, keough said:

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[i].nameid != nameid)
				continue;
			pc->delitem(psd, i, psd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
		}
		for (i = 0; i < MAX_CART; ++i) { // Cart Removal
			if (psd->status.cart[i].nameid != nameid)
				continue;
			pc->cart_delitem(psd, i, psd->status.cart[i].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[i].nameid != nameid)
					continue;
				gstorage->delitem(psd, stor, i, stor->items[i].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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.