Jump to content
×
×
  • Create New...
  • 0

Transfer costume bonus


EnKor

Question

  • Premium

Hi there.

I have installed this system in my server, but i have one crazy bug. 

 

if i add same costume to transfer bonus from SLOT2 to SLOT1 (but with same costume), my core go down.

 

print

 

can any one help me to make a function to return if item from SLOT2 have same id as item in SLOT1? 

i have to add that function in here. But have no ideia how to do it.

 

void AttrTransfer_add_item(LPCHARACTER ch, int w_index, int i_index)
{
	LPITEM	item;
	LPITEM	*attr_transfer_item;
	RETURN_IF_ATTR_TRANSFER_IS_NOT_OPENED(ch);
	
	if (i_index < 0 || INVENTORY_MAX_NUM <= i_index || w_index < 0 || MAX_ATTR_TRANSFER_SLOT <= w_index)
		return;
	
	item = ch->GetInventoryItem(i_index);
	if (item == NULL)
		return;
	
	if (w_index == 0 && item->GetType() != ITEM_TRANSFER_SCROLL)
		return;
	
	if ((w_index == 1 && item->GetType() != ITEM_COSTUME )|| (w_index == 2 && item->GetType() != ITEM_COSTUME))
		return;
	
	if (gAttrTransferLimit != 1 && item->GetSubType() != COSTUME_BODY)
		return;
	
	attr_transfer_item = ch->GetAttrTransferItem();
	for (int i = 0; i < MAX_ATTR_TRANSFER_SLOT; ++i)
	{
		if (item == attr_transfer_item[i])
		{
			attr_transfer_item[i] = NULL;
			break;
		}
	}
	
	if (w_index != 0 && attr_transfer_item[0] == NULL)
	{
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Attr Transfer> For do this, you must add the Transfer Scroll into their slot."));
		return;
	}
	else if (w_index == 2 && item->GetSubType() != attr_transfer_item[1]->GetSubType())
	{
		return;
	}
	
	if (w_index == 2)
	{
		ch->ChatPacket(CHAT_TYPE_COMMAND, "AttrTransferMessage");
	}
	
	attr_transfer_item[w_index] = item;
	if (test_server)
		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Attr Transfer> attach from inventory slot number [%d] to attr transfer slot number [%d]."), i_index, w_index);
	
	return;
}

 

ACMD(do_attr_transfer)
{
	
	sys_log(1, "%s has used an Attr Transfer command: %s.", ch->GetName(), argument);
	
	int w_index = 0, i_index = 0;
	const char *line;
	char arg1[256], arg2[256], arg3[256];
	line = two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
	one_argument(line, arg3, sizeof(arg3));
	if (0 == arg1[0])
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Usage:");
		ch->ChatPacket(CHAT_TYPE_INFO, "- attrtransfer open");
		ch->ChatPacket(CHAT_TYPE_INFO, "- attrtransfer close");
		ch->ChatPacket(CHAT_TYPE_INFO, "- attrtransfer add <attr_transfer_slot> <inventory_slot>");
		ch->ChatPacket(CHAT_TYPE_INFO, "- attrtransfer delete <attr_transfer_slot>");
		return;
	}
	
	const std::string& strArg1 = std::string(arg1);
	if (strArg1 == "open")
	{
		AttrTransfer_open(ch);
		return;
	}
	else if (strArg1 == "close")
	{
		AttrTransfer_close(ch);
		return;
	}
	else if (strArg1 == "make")
	{
		AttrTransfer_make(ch);
		return;
	}
	else if (strArg1 == "add")
	{
		if (0 == arg2[0] || !isdigit(*arg2) || 0 == arg3[0] || !isdigit(*arg3))
			return;
		
		str_to_number(w_index, arg2);
		str_to_number(i_index, arg3);
		AttrTransfer_add_item(ch, w_index, i_index);
		return;
	}
	else if (strArg1 == "delete")
	{
		if (0 == arg2[0] || !isdigit(*arg2))
			return;
		
		str_to_number(w_index, arg2);
		AttrTransfer_delete_item(ch, w_index);
		return;
	}
	
	switch (LOWER(arg1[0]))
	{
		case 'o':
			AttrTransfer_open(ch);
			break;
		case 'c':
			AttrTransfer_close(ch);
			break;
		case 'm':
			AttrTransfer_make(ch);
			break;
		case 'a':
			{
				if (0 == arg2[0] || !isdigit(*arg2) || 0 == arg3[0] || !isdigit(*arg3))
					return;
				
				str_to_number(w_index, arg2);
				str_to_number(i_index, arg3);
				AttrTransfer_add_item(ch, w_index, i_index);
			}
			break;
		case 'd':
			{
				if (0 == arg2[0] || !isdigit(*arg2))
					return;
				
				str_to_number(w_index, arg2);
				AttrTransfer_delete_item(ch, w_index);
			}
			break;
		default:
			return;
	}
}

 

Link to comment
  • Answers 7
  • Created
  • Last Reply

Top Posters For This Question

7 answers to this question

Recommended Posts

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.