Jump to content

Auto Opener by CMD


Recommended Posts

Hi,

 

i did command that can be used for auto opener of items (like 27987)

Spoiler

ACMD(do_fast_opener) 
{

	std::vector<std::string> vecArgs;
	split_argument(argument, vecArgs);
	DWORD whatIsUsed;
	int howMuch, itemSlot; 
	str_to_number(whatIsUsed, vecArgs[1].c_str()); 
	str_to_number(howMuch, vecArgs[2].c_str()); 
	str_to_number(itemSlot, vecArgs[3].c_str()); 
	
	for (int i = 1; i < 3; i++)
	{
		if (!*vecArgs[i].c_str() || !isnhdigit(*vecArgs[i].c_str()))
		{
			return ; 
		}
	}
	
	if (!ch->CanWarp())
		return ;
	
	if (howMuch > 500)
		howMuch = 500;
	LPITEM item = ch->GetInventoryItem(itemSlot);
	struct 
	{
		DWORD itemVnum;
	}
	disabledItems [] = 
	{
		{70038},
		
	};
	for (int i = 0; i < (sizeof(disabledItems) / (1 * sizeof(int))); ++i)
	{
		if (item->GetVnum() == disabledItems[i].itemVnum)
		{
			ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("disabled_item") );
			return;
		}
	}
	if (item)
	{
		if (item->GetVnum() == whatIsUsed)	
		{
			for (int i = 0; i < howMuch; i++)
			{
				ch->UseItem(TItemPos (INVENTORY, itemSlot));
			}

		}
	}
}

 

 

Code of func. is here https://paste.ubuntu.com/p/YPGX6ZXsXg/

Example: /fast_opener itemvnum howMuchtoOpen positionOfItem

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

                elif self.IsTreasureBox(itemSlotIndex):
                    self.SendMultipleUseItemPacket(itemSlotIndex)    

  

  def IsTreasureBox(self, slotIndex):
        itemVnum = player.GetItemIndex(slotIndex)
        item.SelectItem(itemVnum)
        
        if item.GetItemType() == item.ITEM_TYPE_GIFTBOX:
            return True            
        treasures = {
            0: 27987,
            1: 50024,
            2: 50025,
            3: 50031,
            4: 50032,
            5: 80003,
        }
        
        if itemVnum in treasures.values():
            return True
            
        return False    
	def SendMultipleUseItemPacket(self, slotIndex):	
		for i in xrange(player.GetItemCount(slotIndex)):
			self.__SendUseItemPacket(slotIndex)	

 

Link to comment
Share on other sites

2 godziny temu, ManiacRobert napisał:

                elif self.IsTreasureBox(itemSlotIndex):
                    self.SendMultipleUseItemPacket(itemSlotIndex)    

  


  def IsTreasureBox(self, slotIndex):
        itemVnum = player.GetItemIndex(slotIndex)
        item.SelectItem(itemVnum)
        
        if item.GetItemType() == item.ITEM_TYPE_GIFTBOX:
            return True            
        treasures = {
            0: 27987,
            1: 50024,
            2: 50025,
            3: 50031,
            4: 50032,
            5: 80003,
        }
        
        if itemVnum in treasures.values():
            return True
            
        return False    

	def SendMultipleUseItemPacket(self, slotIndex):	
		for i in xrange(player.GetItemCount(slotIndex)):
			self.__SendUseItemPacket(slotIndex)	

 

I can't python thats why i did like that.

Link to comment
Share on other sites

  • Bronze
2 hours ago, ManiacRobert said:

                elif self.IsTreasureBox(itemSlotIndex):
                    self.SendMultipleUseItemPacket(itemSlotIndex)    

  


  def IsTreasureBox(self, slotIndex):
        itemVnum = player.GetItemIndex(slotIndex)
        item.SelectItem(itemVnum)
        
        if item.GetItemType() == item.ITEM_TYPE_GIFTBOX:
            return True            
        treasures = {
            0: 27987,
            1: 50024,
            2: 50025,
            3: 50031,
            4: 50032,
            5: 80003,
        }
        
        if itemVnum in treasures.values():
            return True
            
        return False    

	def SendMultipleUseItemPacket(self, slotIndex):	
		for i in xrange(player.GetItemCount(slotIndex)):
			self.__SendUseItemPacket(slotIndex)	

 

200 packets vs 1 command

thinking-face_1f914.png

Edited by Metin2 Dev
Core X - External 2 Internal
  • Sad 1
  • Love 3
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

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.