Jump to content

VegaS™

Forum Moderator
  • Posts

    656
  • Joined

  • Last visited

  • Days Won

    187
  • Feedback

    100%

Posts posted by VegaS™

  1. On 3/4/2019 at 1:54 AM, WLsj24 said:

    And how could we block the following?
    A player links an item in the chat, and then another player links the same item (without having it), doing the same process in the hyperlink. Basically copy the item visually. Is it possible to do that?

    Yes, we can do this in server/client-side, but need some extra-checks for item attr/scokets + if exists in inventory.
    But have no sense to fix it since you don't want the players to do this.
    Why you don't disable the function chatGetLinkFromHyperlink from source client and python and showing just the tooltip when you put the mouse over the link, remove ALT+LEFT CLICK.

    • root/game.py

    This is the hidden content, please

    • root/uiWhisper.py
    Spoiler
    # 1.1) Search for:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.IsPressed(app.DIK_LALT):
    				link = chat.GetLinkFromHyperlink(hyperlink)
    				ime.PasteString(link)
    			else:
    				self.interface.MakeHyperlinkTooltip(hyperlink)
    # 1.2) Replace it with:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.ENABLE_LINK_FROM_HYPERLINK:
    				if app.IsPressed(app.DIK_LALT):
    					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
    					return
    
    			self.interface.MakeHyperlinkTooltip(hyperlink)

     

    • root/uiChat.py
    Spoiler
    #1.1) Search for:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.IsPressed(app.DIK_LALT):
    				link = chat.GetLinkFromHyperlink(hyperlink)
    				ime.PasteString(link)
    			else:
    				self.interface.MakeHyperlinkTooltip(hyperlink)
    #1.2) Replace it with:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.ENABLE_LINK_FROM_HYPERLINK:
    				if app.IsPressed(app.DIK_LALT):
    					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
    					return
    
    			self.interface.MakeHyperlinkTooltip(hyperlink)
                
    # 2.1) Search for:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.IsPressed(app.DIK_LALT):
    				link = chat.GetLinkFromHyperlink(hyperlink)
    				ime.PasteString(link)
    			else:
    				self.interface.MakeHyperlinkTooltip(hyperlink)
    		else:
    			ui.EditLine.OnMouseLeftButtonDown(self)
    # 2.2) Replace it with:
    	def OnMouseLeftButtonDown(self):
    		hyperlink = ui.GetHyperlink()
    		if hyperlink:
    			if app.ENABLE_LINK_FROM_HYPERLINK:
    				if app.IsPressed(app.DIK_LALT):
    					ime.PasteString(chat.GetLinkFromHyperlink(hyperlink).strip())
    					return
    
    			self.interface.MakeHyperlinkTooltip(hyperlink)
    		else:
    			ui.EditLine.OnMouseLeftButtonDown(self)

     

    • Srcs/Client/UserInterface/PythonChatModule.cpp
    Spoiler
    // 1.1) Search for:
    		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
    // 1.2) Replace it with:
    #ifdef ENABLE_LINK_FROM_HYPERLINK
    		// Link
    		{ "GetLinkFromHyperlink",	chatGetLinkFromHyperlink,	METH_VARARGS },
    #endif

     

    • Srcs/Client/UserInterface/PythonApplicationModule.cpp
    Spoiler
    // 1.1) Search for:
    	PyModule_AddIntConstant(poModule, "CAMERA_STOP",			CPythonApplication::CAMERA_STOP);
    // 1.2) Add after:
    #ifdef ENABLE_LINK_FROM_HYPERLINK
    	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 1);
    #else
    	PyModule_AddIntConstant(poModule, "ENABLE_LINK_FROM_HYPERLINK", 0);
    #endif

     

    • Srcs/Client/UserInterface/Locale_inc.h
    Spoiler
    //#define ENABLE_LINK_FROM_HYPERLINK // Enable copy a item link from hyperlink with ALT+CLICK.

     

     

    • Metin2 Dev 15
    • Good 4
    • Love 8
  2. Try this.

    Search for:

    	self.itemSlot = self.GetChild("item_slot")

    Add after:

    	self.itemSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
    	self.itemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))

    Search for:

            self.itemSlot.SetOverInItemEvent = lambda arg = vnum: self.OverInItem(arg)
            self.itemSlot.SetOverOutItemEvent = lambda arg = self.tooltipItem: self.OverOutItem(arg)

    Replace it with:

    	# Clear the tooltip line.
    	self.tooltipItem.ClearToolTip()
    	# Insert the description of item.
    	self.tooltipItem.SetInventoryItem(vnum)
    	# Hide the tooltip line because after you insert a description, the ShowToolTip is called.
    	self.tooltipItem.HideToolTip()

    Search for:

    	def OverInItem(self, vnum):
    		self.tooltipItem.SetInventoryItem(vnum)
    		self.tooltipItem.Show()
       
    	def OverOutItem(self, tooltip):
    		self.tooltipItem.HideToolTip()
    		self.tooltipItem.ClearToolTip()

    Replace it with:

        def OverInItem(self):
    		if self.tooltipItem:
    			self.tooltipItem.ShowToolTip()
       
        def OverOutItem(self):
    		if self.tooltipItem:
    			self.tooltipItem.HideToolTip()

     

    • Love 2
  3. In your case WARP_SCROLLS is the index not the tuple or list that you are searching, because it is non-iterable type, you are getting this error.

    m2devList = [1000, 2000, 3000]
    for item in m2devList:
    	print item
    
    >> 1000
    >> 2000
    >> 3000

    You're attempting to check if 22010 is in itemVnum, which does not make sense.

    in smth operator expects an iterable object on the right side but you are providing an integer.

    Either use:

    #elif itemVnum in WARP_SCROLLS:
    elif itemVnum == WARP_SCROLLS:
    	# do smth

    Or fix your problem, go in uiToolTip.py and replace:

    WARP_SCROLLS=22010

    With:

    WARP_SCROLLS = (22010, )

     

    • Love 1
  4. On 2/24/2019 at 4:59 PM, xP3NG3Rx said:

    Btw, here is my reversed class for the Monstercard render target, you can check it for your own ideas.

    This one is still not compatible with this base, so you have to code it by yourself to make it work.
    Practice :D.

    Haha, i did it long time ago, now you make it public, danke sexy p3nger. ?

    I think i will post my full version, soon.

     

    • Love 10
  5. I don't know why you need it, but have fun.

    How-To-Use:

    # General:
    chrmgr.GetPlayerID(vid)
    
    # Example: uiTarget.py
    import chat, chrmgr
    
    def SetTargetVID(self, vid):
    	self.vid = vid
    	chat.AppendChat(chat.CHAT_TYPE_INFO, 'SetTargetVID - vid({:d}), pid({:d})'.format(self.vid, chrmgr.GetPlayerID(self.vid)))

    95c8af78d699536eea4cd1104a1f2801.gif

     

    • Src/Client/UserInterface/InstanceBase.h
    //1.1) Search for:
    	public:
    		const TPixelPosition&	NEW_GetDstPixelPositionRef();
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	public:
    		void SetPlayerID(const DWORD dwPID)
    		{
    			m_dwPlayerID = dwPID;
    		}
    		const DWORD GetPlayerID()
    		{
    			return m_dwPlayerID;
    		}
    	protected:
    		DWORD m_dwPlayerID;
    #endif
    • Src/Client/UserInterface/InstanceBase.cpp
    //1.1) Search for:
    	SetVirtualID(c_rkCreateData.m_dwVID);
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	if (IsPC())
    		SetPlayerID(c_rkCreateData.m_dwPlayerID);
    #endif
    
    //2.1) Search for:
    	m_dwEmoticonTime = 0;
    //2.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	m_dwPlayerID = 0;
    #endif
    • Src/Client/UserInterface/PythonCharacterManagerModule.cpp
    //1.1) Search for:
    		{ "RegisterTitleColor",			chrmgrRegisterTitleColor,				METH_VARARGS },
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    		{ "GetPlayerID",				chrmgGetPID,							METH_VARARGS },
    #endif
    
    //2.1) Search for:
    		{ "RegisterTitleColor",			chrmgrRegisterTitleColor,				METH_VARARGS },
    //2.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    PyObject * chrmgGetPID(PyObject* poSelf, PyObject* poArgs)
    {
    	int nVID;
    	if (!PyTuple_GetInteger(poArgs, 0, &nVID))
    		return Py_BadArgument();
    	
    	CPythonCharacterManager & rkChrMgr = CPythonCharacterManager::Instance();
    	CInstanceBase * pkInstBase = rkChrMgr.GetInstancePtr(nVID);
    	if (!pkInstBase)
    		return Py_BuildValue("i", 0); 
    	
    	return Py_BuildValue("i", (pkInstBase->IsPC()) ? pkInstBase->GetPlayerID() : 0);
    }
    #endif
    • Src/Client/UserInterface/NetworkActorManager.cpp
    //1.1) Search for:
    	CInstanceBase::SCreateData kCreateData;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	kCreateData.m_dwPlayerID=rkNetActorData.m_dwPlayerID;
    #endif
    
    //2.1) Search in SNetworkActorData::SNetworkActorData() for:
    	m_dwVID=0;
    //2.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	m_dwPlayerID = 0;
    #endif
    
    //3.1) Search in void SNetworkActorData::__copy__(const SNetworkActorData& src) for:
    	m_dwVID = src.m_dwVID;
    //3.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	m_dwPlayerID = src.m_dwPlayerID;
    #endif
    • Src/Client/UserInterface/NetworkActorManager.h
    //1.1) Search for:
    	DWORD	m_dwVID;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	DWORD	m_dwPlayerID;
    #endif
    • Src/Client/UserInterface/PythonNetworkStreamPhaseGameActor.cpp
    //1.1) Search for:
    		kNetActorData.m_stName = chrInfoPacket.name;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    		kNetActorData.m_dwPlayerID = chrInfoPacket.dwPlayerID;
    #endif
    • Src/Client/UserInterface/Packet.h
    //1.1) Search in packet_char_additional_info for:
    	DWORD   dwVID;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	DWORD	dwPlayerID;
    #endif

    Src/Client/UserInterface/Locale_inc.h

    #define ENABLE_PID_TO_CLIENT

    ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

    • Src/Server/game/src/char.cpp
    //1.1) Search for:
    		addPacket.bEmpire = m_bEmpire;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    		addPacket.dwPlayerID = IsPC() ? GetPlayerID() : 0;
    #endif
    • Src/Server/game/src/packet.h
    //1.1) Search in packet_char_additional_info for:
    	DWORD   dwVID;
    //1.2) Add after:
    #ifdef ENABLE_PID_TO_CLIENT
    	DWORD	dwPlayerID;
    #endif
    • Src/Server/common/service.h
    #define ENABLE_PID_TO_CLIENT

     

    • Love 1
  6. You can use:

    • localeInfo.NumberToMoneyString
    def NumberToMoneyString(n) :
    	if n <= 0 :
    		return "0 %s" % (MONETARY_UNIT0)
    	return "%s %s" % ('.'.join([ i-3<0 and str(n)[:i] or str(n)[i-3:i] for i in range(len(str(n))%3, len(str(n))+1, 3) if i ]), MONETARY_UNIT0)

    The current  function return a value + MONETARY_UNIT0, you can split it and don't need any new function.

    print localeInfo.NumberToMoneyString(2147483647)
    #Result: 2.147.483.647 Yang
    
    print localeInfo.NumberToMoneyString(2147483647).split(' ')[0]
    #Result: 2.147.483.647

    I don't know what structure you have in hpMobsList, but here's a example.

    maxHP = self.hpMobsList[chr.GetRace()]
    minHP = int(float(hpPercentage) / 100.00 * float(maxHP))
    self.textHP.SetText("TP: {:s}/{:s}".format(localeInfo.NumberToMoneyString(minHP).split(' ')[0], localeInfo.NumberToMoneyString(int(maxHP)).split(' ')[0]))
  7. M2 Download Center

    This is the hidden content, please
    ( Internal )

    This is the hidden content, please
    ( GitHub )

    Metin2 Color Formatter

    A simple class writted for Python and C++ which convert the param-values into an string by a specific color rgb as hexadecimals.

    • Color constants module:
      https://www.webucator.com/blog/2015/03/python-color-constants-module/
      https://www.color-hex.com/color/ccffff
    • Python:
      from cff import CFF
      text = CFF.format('Metin2', 'green')
      text = CFF.format(8000, 'banana')
      text = CFF.format(412.55, 'red')
      text = CFF.format('Pending', '#113355')
      text = CFF.format('Item name:', 'springgreen', CFF.FLAG_NEW_TAB) + CFF.format(item.GetItemName(), 'chocolate')
      text = CFF.multi_format(('a', 'b', 'c'), 'red') # text[0], text[1], text[2]
    • C++:
      #include "cff.h"
      std::string text = CFF::format("Metin2", "green");
      std::string text = CFF::format(std::to_string(8000), "banana");
      std::string text = CFF::format(std::to_string(412.55), "red");
      std::string text = CFF::format("Pending", "#113355");
      std::string text = CFF::format("Item name:", "springgreen", CFF::FLAG_NEW_TAB) + CFF::format(pItemData->GetName(), "chocolate");
      
      std::vector<string> text = CFF::multi_format({"a", "b", "c"}, "red"); // text[0], text[1], text[2]

    Github repository: 

    This is the hidden content, please

    • Metin2 Dev 25
    • Dislove 1
    • Think 1
    • Good 5
    • Love 3
    • Love 22
  8. (1.3) Spamming

    Do not spam in this board. Posting a topic or a question once is enough. If you don't get an answer maybe your question needs more description. Or nobody is able to help you there. Double post aswell as double threads will be punished with an infraction.

     

    • Love 1
  9. Good idea, but you should return false if GetDesc is nullptr, not true.

    static const bool __FN_check_ip_ptr(const LPCHARACTER pkChr, const LPCHARACTER pkTargetChr)
    {
    	if (!pkChr || !pkTargetChr)
    		return false;
    	
    	const LPDESC pkDesc = pkChr->GetDesc();
    	const LPDESC pkTargetDesc = pkTargetChr->GetDesc();
    	if (!pkDesc || !pkTargetDesc)
    		return false;
    	
    	const std::string & stIPAddress1 = pkDesc->GetHostName();
    	const std::string & stIPAddress2 = pkTargetDesc->GetHostName();
    	return (!stIPAddress1.compare(stIPAddress2));
    }
    
    static const bool __FN_check_ip_str(const std::string & stIPAddress1, const std::string & stIPAddress2)
    {
    	return (!stIPAddress1.compare(stIPAddress2));
    }
    
    // const bool bIsSameIP = __FN_check_ip_ptr(ch, tch);
    // const bool bIsSameIP = __FN_check_ip_str(row[0], row[1]);

    It's a little bit useless if two guys play metin2 from same network connection, as @Chyu ^^ said.
    We can use HWID (Hardware Identification) for this detection, much better.

    • Love 5
  10. Nice idea, but I'd use crypt.triple_des, for save data, like:

    # write
    open(fileName, 'wb').write((crypt.triple_des(unhex(your_hex_str))).encrypt(cPickle.dumps({'userID': userID, 'userPassword': userPassword}), ' '))
    # read
    self.loginDataDict = cPickle.loads((crypt.triple_des(unhex(your_hex_str))).decrypt(open(fileName, "rb").read(), ' '))

     

    • Metin2 Dev 2
    • Love 1
  11. @avertuss 

    Your compiler doesn't support this feature (list initialization (since C++11)). 

    Replace:

    	const std::vector<const std::string> vecTitleName{c_szTitleNameF, c_szTitleNameM};

    With:

    	std::vector<const std::string> vecTitleName;
    	vecTitleName.push_back(c_szTitleNameF);
    	vecTitleName.push_back(c_szTitleNameM);

    Or:

    	const char * c_szTitles[] = {c_szTitleNameF, c_szTitleNameM};
    	const std::vector<const std::string> vecTitleName(c_szTitles, c_szTitles + sizeof(c_szTitles) / sizeof(c_szTitles[0]));

     

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