Jump to content
  • 0

Drop specific item by command


kronobr

Question


  • Group:  Members
  • Topic Count:  32
  • Topics Per Day:  0.02
  • Content Count:  71
  • Reputation:   0
  • Joined:  06/24/19
  • Last Seen:  

/*==========================================
* @dropequip [FE]
* Drop spesific equipment to the ground
*------------------------------------------*/
ACMD_FUNC(dropequip)
{
int i;
unsigned short pos;

nullpo_retr(-1, sd);

if (!message || !*message) {
	clif_displaymessage(fd, "Please enter equip location: @dropequip <equip_location>");
	clif_displaymessage(fd, "  1: Head Low   2: Hand Right  4: Garment   8: Acc Left");
	clif_displaymessage(fd, " 16: Armor     32: Hand Left  64: Shoes   128: Acc Right");
	clif_displaymessage(fd, "256: Head Top 512: Head Mid");
	return -1;
}

pos = atoi(message);

for (i = 0; i < MAX_INVENTORY; i++) {
	if (sd->status.inventory[i].amount && sd->inventory_data[i]->equip&pos) {
		if(sd->status.inventory[i].equip&pos) {
			pc_unequipitem(sd, i, 3);
			pc_dropitem(sd, i, sd->status.inventory[i].amount);
		}
		//-Delete code below if you only want to drop an equipped item---
		else if (!sd->status.inventory[i].equip)
			pc_dropitem(sd, i, sd->status.inventory[i].amount);
		//---------------------------------------------------------------
	}
}
return 0;
}

Could someone help transform this code from 2012 atcommand to work in atcommand.cpp from rathena 2019? Thanks a lot ? the errors are related to ''status.inventory'' and status.inventory[i] equip%pos it looks like it has changed over time.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  41
  • Reputation:   11
  • Joined:  11/17/20
  • Last Seen:  

/*==========================================
* @dropequip [FE]
* Drop spesific equipment to the ground
*------------------------------------------*/
ACMD_FUNC(dropequip)
{
int i;
unsigned short position;

nullpo_retr(-1, sd);

if (!message || !*message) {
	clif_displaymessage(fd, "Please enter equip location: @dropequip <equip_location>");
	clif_displaymessage(fd, "  1: Head Low   2: Hand Right  4: Garment   8: Acc Left");
	clif_displaymessage(fd, " 16: Armor     32: Hand Left  64: Shoes   128: Acc Right");
	clif_displaymessage(fd, "256: Head Top 512: Head Mid");
	return -1;
}

position = atoi(message);

for (i = 0; i < MAX_INVENTORY; i++) {
	if (sd->inventory.u.items_inventory[i].amount && sd->inventory_data[i]->equip & position) {
		if(sd->inventory.u.items_inventory[i].equip & position) {
			pc_unequipitem(sd, i, 3);
			pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount);
		}
		//-Delete code below if you only want to drop an equipped item---
		else if (!sd->inventory.u.items_inventory[i].equip)
			pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount);
		//---------------------------------------------------------------
	}
}
return 0;
}

I have tried to update the codes to 2021. Please try and let me know if you have errors. Thank you

Edited by Pride
Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...