Jump to content

new function item.GetItemNameByVnum(..) needed


Recommended Posts

  • Forum Moderator
2 hours ago, Kafa said:

@xP3NG3Rx

@VegasForPresident

 

@VegaS™

 

Hey guys, i really need a function to  get the item name from vnum, can someone help me? Official added it here is how they call it: item.GetItemNameByVnum(changelookvnum)

Hey,

 

You better remove these tags really quick, thank you :)

Edited by Gurgarath
  • Love 3

Gurgarath
coming soon

Link to comment
Share on other sites

3 hours ago, Kafa said:

Hey guys, i really need a function to  get the item name from vnum, can someone help me? Official added it here is how they call it: item.GetItemNameByVnum(changelookvnum)


PythonItemModule.cpp

PyObject * itemGetItemNameByVnum(PyObject * poSelf, PyObject * poArgs)
{
	int iIndex;
	if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
		return Py_BadArgument();

	if (!CItemManager::Instance().SelectItemData(iIndex))
	{
		TraceError("Cannot find item by %d", iIndex);
		return Py_BuildNone(); // or
		// CItemManager::Instance().SelectItemData(60001);
	}

	CItemData * pItemData = CItemManager::Instance().GetSelectedItemDataPointer();
	if (!pItemData)
		return Py_BuildException("no selected item data");

	return Py_BuildValue("s", pItemData->GetName());
}

and 

{ "GetItemNameByVnum",					itemGetItemNameByVnum,						METH_VARARGS },

 

  • Love 2

I completely abandoned working on the files for this game. I do not respond to private messages.

.png

Link to comment
Share on other sites

  • Forum Moderator

You can do it directly with python, without doing a new function in binary.

item.SelectItem(changelookvnum)
print(item.GetItemName())

 

On 3/19/2020 at 4:46 PM, Nirray said:


PyObject * itemGetItemNameByVnum(PyObject * poSelf, PyObject * poArgs)
{
	int iIndex;
	if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
		return Py_BadArgument();

	if (!CItemManager::Instance().SelectItemData(iIndex))
	{
		TraceError("Cannot find item by %d", iIndex);
		return Py_BuildNone(); // or
		// CItemManager::Instance().SelectItemData(60001);
	}

	CItemData * pItemData = CItemManager::Instance().GetSelectedItemDataPointer();
	if (!pItemData)
		return Py_BuildException("no selected item data");

	return Py_BuildValue("s", pItemData->GetName());
}

And if you really need it, you can do it as:

This is the hidden content, please

 

 

Edited by VegaS™
  • Metin2 Dev 15
  • Good 7
  • Love 8
Link to comment
Share on other sites

32 minutes ago, Nirray said:


PythonItemModule.cpp


PyObject * itemGetItemNameByVnum(PyObject * poSelf, PyObject * poArgs)
{
	int iIndex;
	if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
		return Py_BadArgument();

	if (!CItemManager::Instance().SelectItemData(iIndex))
	{
		TraceError("Cannot find item by %d", iIndex);
		return Py_BuildNone(); // or
		// CItemManager::Instance().SelectItemData(60001);
	}

	CItemData * pItemData = CItemManager::Instance().GetSelectedItemDataPointer();
	if (!pItemData)
		return Py_BuildException("no selected item data");

	return Py_BuildValue("s", pItemData->GetName());
}

and 


{ "GetItemNameByVnum",					itemGetItemNameByVnum,						METH_VARARGS },

 

 

Now i have 3 people to quote if i need help (Nirray, Vegas, Penger) ❤️

 

Thank you guys (vegas,nirray) 

Edited by Kafa
  • Sad 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.