Jump to content

alondark

Member
  • Posts

    259
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by alondark

  1. 23 hours ago, wezt said:

    Hello!

    I'd like to show you how you can check position for shops (probably offline shops too).
    I don't like when the map is full of shops or when shops are too close for each other. So I've made few functions for checking if the shop is in safezone or if it too close to other shops.

    Let's start :)

    char.h

    Find there:

    
    		void			CloseMyShop();
    
    	protected:
    
    		LPSHOP			m_pkShop;
    		LPSHOP			m_pkMyShop;
    		std::string		m_stShopSign;
    		LPCHARACTER		m_pkChrShopOwner;

    Add few new lines:

    
    		void			CloseMyShop();
    		void			SetShopValidPos(bool value) { m_bShopValidPos = value; }
    		bool			GetShopValidPos() { return m_bShopValidPos; }
    
    	protected:
    
    		LPSHOP			m_pkShop;
    		LPSHOP			m_pkMyShop;
    		std::string		m_stShopSign;
    		LPCHARACTER		m_pkChrShopOwner;
    		bool			m_bShopValidPos;

    char.cpp

    In 'void CHARACTER::Initialize()' find:

    
    	m_pkMyShop		= NULL;

    Add below:

    
    	m_bShopValidPos = true;

    Then search for 'void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount)'

    Add above new function:

    
    struct CheckShopPos
    {
    	LPCHARACTER m_ch;
    	CheckShopPos(LPCHARACTER ch)
    	{
    		m_ch = ch;
    	}
    
    	void operator()(LPENTITY ent)
    	{
    		if (ent->IsType(ENTITY_CHARACTER))
    		{
    			LPCHARACTER ch = (LPCHARACTER) ent;
    			if (ch->GetRaceNum()!=30000) //shop mob vnum
    				return;
    
    			if (DISTANCE_APPROX(ch->GetX() - m_ch->GetX(), ch->GetY() - m_ch->GetY()) < 200) //distance between shops
    			{
    				m_ch->SetShopValidPos(false);
    			}
    		}
    	}
    };

    Then in 'void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount)' search for:

    
    	if (bItemCount == 0)
    		return;

    Add below:

    
    	//shops pos check
    	LPSECTREE sectree = NULL;
    	sectree = GetSectree();
    	if (sectree)
    	{
    
    		SetShopValidPos(true);
    
    		CheckShopPos f(this);
    		sectree->ForEachAround(f);
    
    		if(!GetShopValidPos())
    		{
    			ChatPacket(CHAT_TYPE_INFO, "You cannot open a shop here (too close to other shop).");
    			return;
    		}
    
    		if (!sectree->IsAttr(GetX(), GetY(), ATTR_BANPK))
    		{
    			ChatPacket(CHAT_TYPE_INFO, "You cannot open a shop here (use safezone).");
    			return;
    		}
    	}
    	//shops pos check

     

    P.s:

      Reveal hidden contents

    1. Make backups before change your source.
    2. If you'll repost this solution somewhere, please keep credits.
    3. Likes and comments appreciated.

     

    That's all, have fun ;)
    Regards.

    hello 

    how we do new markets

    https://metin2.download/picture/ge83X21H0XvckjfT9uk0h3qTfr3S6hI1/.png

    the codes of the market

    mob cod (30002)30003)30004)

     

     

    These New Markets Are Blocked

     

    system thank you 

     

  2. Just now, VegaS said:

    :blink:

    Not equal to a != b
    not_eq b

    Yes Yes bool K::operator !=(S const& b); bool K::operator!=(S const& b) const; bool operator !=(K const& a, S const& b);

    Greater than or equal to

    a >= b Yes Yes bool K::operator >=(S const& b) const; bool operator >=(K const& a, S const& b); Less than or equal to a <= b Yes Yes bool K::operator <=(S const& b); bool operator <=(K const& a, S const& b);

     

    sorry my fail

    • Love 1
×
×
  • 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.