Jump to content

Sanchez

Premium
  • Posts

    576
  • Joined

  • Days Won

    43
  • Feedback

    0%

Posts posted by Sanchez

  1. Here it is with text file if someone still interested:
     
    item_block.cpp:

    #include "stdafx.h"
    #include "item_block.h"
    #include <fstream>
    #include <sstream>
    
    CItemBlock::CItemBlock(void)
    {
    
    }
    
    CItemBlock::~CItemBlock(void)
    {
    }
    
    void CItemBlock::Process(void)
    {
    	std::string strMapIndex;
    	std::string strItemVnums;
    
    	std::ifstream File("blocked_items.txt");
    
    	if (!File.is_open())
    		return;
    
    	if (!m_map_BlockedItems.empty())
    		m_map_BlockedItems.clear();
    
    	while (!File.eof())
    	{
    		File >> strMapIndex >> strItemVnums;
    
    		std::string strItemVnum;
    
    		std::istringstream Vnums(strItemVnums);
    
    		while (std::getline(Vnums, strItemVnum, ','))
    		{
    			AddItem(strtoul(strMapIndex.c_str(), NULL, 10), strtoul(strItemVnum.c_str(), NULL, 10));
    		}
    	}
    
    	File.close();
    }
    
    void CItemBlock::AddItem(const long lMapIndex, const DWORD dwVnum)
    {
    	if (lMapIndex < 0 || dwVnum < 0)
    		return;
    
    	m_map_BlockedItems.insert(std::make_pair(lMapIndex, dwVnum));
    }
    
    void CItemBlock::RemoveItem(const long lMapIndex, const DWORD dwVnum)
    {
    	if (lMapIndex < 0 || dwVnum < 0)
    		return;
    
    	for (BLOCKED_ITEMS::const_iterator it = m_map_BlockedItems.begin(); it != m_map_BlockedItems.end()
    	{
    		if (it->first == lMapIndex && it->second == dwVnum)
    			it = m_map_BlockedItems.erase(it);
    		else
    			++it;
    	}
    }
    
    bool CItemBlock::CanUseItem(const long lMapIndex, const DWORD dwVnum) const
    {
    	for (BLOCKED_ITEMS::const_iterator it = m_map_BlockedItems.begin(); it != m_map_BlockedItems.end()
    	{
    		if (it->first == lMapIndex && it->second == dwVnum)
    			return false;
    	}
    
    	return true;
    }
    

    item_block.h:

    #ifndef __ITEM_BLOCK
    #define __ITEM_BLOCK
    
    class CItemBlock : public singleton<CItemBlock>
    {
    	public:
    			CItemBlock();
    			~CItemBlock();
    
    
    	        void	Process(void);
    	        bool	CanUseItem(const long lMapIndex, const DWORD dwVnum) const;
    	        void	AddItem(const long lMapIndex, const DWORD dwVnum);
    	        void	RemoveItem(const long lMapIndex, const DWORD dwVnum);
    
    	private:
    		typedef std::multimap<long, DWORD> BLOCKED_ITEMS;
    		BLOCKED_ITEMS m_map_BlockedItems;
    };
    
    #endif /* __ITEM_BLOCK */
    

    - Item can be removed runtime by using the RemoveItem(map_index, item_vnum) function.
    - Item can be added runtime by using the AddItem(map_index, item_vnum) function
    - To load or reload the txt file use the Process() function

     

    Example of the TXT file:

    50 120229,252391
    51 10000,20000
    52 43232
    • Love 9
  2. You can do it easily, I just don't get the point of it. 

     

     

    Call this in your binary:

    PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "GetTest", Py_BuildValue("()"));
    
    Make a "GetTest" function in game.py:

    	def GetTest(self):
    		net.SetTest(constInfo.Test)
    Add the receiver function to your binary:

    object* netSetTest(PyObject* poSelf, PyObject* poArgs)
    {
    	char* szTest;
    	if (!PyTuple_GetString(poArgs, 0, &szTest))
    		return Py_BuildException();
    
    	// Do something with szTest
    
    	return Py_BuildNone();
    }
    
    I'm sure there is a better way to solve your problem, so please explain what you want to do.
    • 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.