Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2 > Metin2 Private Server > Metin2 PServer Guides & Strategies
You last visited: Today at 20:21

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[mini func](int(bool)) player.IsAntiFlagBySlot(iSlot, iAntiFlag)

Discussion on [mini func](int(bool)) player.IsAntiFlagBySlot(iSlot, iAntiFlag) within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1

 
Mr. 'Avenue™'s Avatar
 
elite*gold: 222
The Black Market: 101/0/0
Join Date: Oct 2012
Posts: 2,369
Received Thanks: 3,389
[mini func](int(bool)) player.IsAntiFlagBySlot(iSlot, iAntiFlag)

Die Funktion gibt zurück, ob der Gegenstand im Slot X den AntiFlag Y besitzt.
in Python wird es wie folgt genutzt:
Code:
//usage
player.IsAntiFlagBySlot(iSlot, iAntiFlag)

//example
if player.IsAntiFlagBySlot(SrcSlotNumber, item.ANTIFLAG_GIVE):
SVN/Client/UserInterface/PythonPlayerModule.cpp
Code:
/*
paste following code under
PyObject * playerisItem(PyObject* poSelf, PyObject* poArgs)
{ ... }
*/

PyObject * playerIsAntiFlagBySlot(PyObject* poSelf, PyObject* poArgs)
{
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 1, &iFlag))
		return Py_BadArgument();

	const TItemData * pData;
	pData = CPythonPlayer::Instance().GetItemData(TItemPos(INVENTORY, iSlotIndex));
	
	if (NULL == pData)
	{
		pData = CPythonPlayer::Instance().GetItemData(TItemPos(DRAGON_SOUL_INVENTORY, iSlotIndex));
		if (NULL == pData)
			return false;
	}

	DWORD dwItemIndex = pData->vnum;

	CItemManager::Instance().SelectItemData(dwItemIndex);
	CItemData * pItemData = CItemManager::Instance().GetSelectedItemDataPointer();

	if (!pItemData)
		return Py_BuildException("no selected item data");

	return Py_BuildValue("i", pItemData->IsAntiFlag(iFlag));
}

/*
paste following code under
{ "isItem",						playerisItem,						METH_VARARGS },
*/


{ "IsAntiFlagBySlot",			playerIsAntiFlagBySlot,				METH_VARARGS },
Mr. 'Avenue™ is offline  
Old 05/16/2018, 01:53   #2
 
xP3NG3Rx's Avatar
 
elite*gold: 50
Join Date: May 2011
Posts: 270
Received Thanks: 991
This is the same way what you can do with python
Code:
item.SelectItem(player.GetItemIndex(slot)
item.IsAntiflag(flag)
But wait, what would you do if the item is not in the inventory?
For example dragon soul inventory and so on. As may you know the ItemPos isn't finished so, the equipments and belt-items are part of the inventory, but in fact you cannot use the function for other windows in this way. I personally don't prefer the use of selectitem either.

And this isn't good either:
Code:
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 0, &iFlag))
		return Py_BadArgument();
xP3NG3Rx is offline  
Old 05/16/2018, 17:25   #3

 
Mr. 'Avenue™'s Avatar
 
elite*gold: 222
The Black Market: 101/0/0
Join Date: Oct 2012
Posts: 2,369
Received Thanks: 3,389
Quote:
Originally Posted by xP3NG3Rx View Post
This is the same way what you can do with python
Code:
item.SelectItem(player.GetItemIndex(slot)
item.IsAntiflag(flag)
But wait, what would you do if the item is not in the inventory?
For example dragon soul inventory and so on. As may you know the ItemPos isn't finished so, the equipments and belt-items are part of the inventory, but in fact you cannot use the function for other windows in this way. I personally don't prefer the use of selectitem either.

And this isn't good either:
Code:
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 0, &iFlag))
		return Py_BadArgument();


If you give a look at PyObject * playerGetItemIndex(..) - it's the same.
Code:
	switch (PyTuple_Size(poArgs))
	{
	case 1:
		{
			int iSlotIndex;
			if (!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
				return Py_BuildException();

			int ItemIndex = CPythonPlayer::Instance().GetItemIndex(TItemPos (INVENTORY, iSlotIndex));
			return Py_BuildValue("i", ItemIndex);
		}
	case 2:
		{ ... }
	default:
		return Py_BuildException();

	}
int ItemIndex = CPythonPlayer::Instance().GetItemIndex(TItemPos (INVENTORY, iSlotIndex));

Now, when you ask yourself, "Why is he doing something new for this?"
I'm about to use the newer root python files. And that, without great changes to the Python code.
example:
Code:
	if app.WJ_ENABLE_TRADABLE_ICON:
		def CantCheckInItem(self, slotIndex):
			itemIndex = player.GetItemIndex(slotIndex)
		
			if itemIndex:
				return player.IsAntiFlagBySlot(slotIndex, item.ANTIFLAG_SAFEBOX)
But yeah, one fact is true though. This function is used by uiExchange, uiPrivateShopBuilder, uiSafeBox. So yeah, I have to change something, 'cause I saw that the function is used after following if-clause:
Code:
if (player.SLOT_TYPE_INVENTORY == attachedSlotType
				or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType):
So I've changed following part:
Code:
	const TItemData * pData;
	pData = CPythonPlayer::Instance().GetItemData(TItemPos(INVENTORY, iSlotIndex));
	
	if (NULL == pData)
	{
		pData = CPythonPlayer::Instance().GetItemData(TItemPos(DRAGON_SOUL_INVENTORY, iSlotIndex));
		if (NULL == pData)
			return false;
	}
I know, maybe it's coded bad, I ain't a professional programmer, it's just a hobby. But it works (at least the way I tested it).

And idk why this shouldn't be good (?)
Code:
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 0, &iFlag))
		return Py_BadArgument();
How else can you solve that, do you have a suggestion for improvement?
Mr. 'Avenue™ is offline  
Old 05/16/2018, 18:25   #4
 
elite*gold: 0
Join Date: Nov 2012
Posts: 29
Received Thanks: 7
Quote:
Originally Posted by Mr. 'Avenue™ View Post
I know, maybe it's coded bad, I ain't a professional programmer, it's just a hobby. But it works (at least the way I tested it).

And idk why this shouldn't be good (?)
Code:
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 0, &iFlag))
		return Py_BadArgument();
How else can you solve that, do you have a suggestion for improvement?
You did mistake in PyTuple_GetInteger(poArgs, 0, &iFlag))
it's good:

Code:
	int iSlotIndex;
	if(!PyTuple_GetInteger(poArgs, 0, &iSlotIndex))
		return Py_BuildException();

	int iFlag;
	if(!PyTuple_GetInteger(poArgs, 1, &iFlag))
		return Py_BadArgument();
Hachiwari is offline  
Thanks
1 User
Old 05/17/2018, 01:13   #5
 
xP3NG3Rx's Avatar
 
elite*gold: 50
Join Date: May 2011
Posts: 270
Received Thanks: 991
I wasn't against you, I just told you what have you done with the code, is that bad? Why did you take it too serious? I know why we need this, I already wrote it when I saw it in the official binary at the first time.

If you have couple of minutes take a look on this video, I can prove the official version here:
xP3NG3Rx is offline  
Thanks
1 User
Reply

Tags
function, metin2, python, source


Similar Threads Similar Threads
[Mini-Release] Perc_Chance-Funktion (bool return)
05/05/2015 - Metin2 PServer Guides & Strategies - 7 Replies
Muss man wohl nicht viel zu sagen. Ist einfach dazu da, um bei Chancen unter 1% nicht mit number(1, 1000) usw. rechnen zu müssen. function math.chance(i) return math.random() <= (i/100) end So benutzbar: if math.chance(0.0001) then trifft zu, wenn die Chance von 0.0001 zutrifft.
Func nach der func ausführen problem
08/15/2011 - AutoIt - 6 Replies
Hi, ich hab hier mal nen code schnipel der nicht funktioniert.. Die error Erkennung... if StringInStr($oWebTcp.body, "Du kannst nicht weitermachen...") Then GUICtrlSetData($list1, "Login failed. Please fix"&" = "&$array&" ANR: ")
Func in Func ?
02/11/2011 - AutoIt - 8 Replies
Hallo E*PvP, Ich habe eine frage , ich will ein shortcut ..ding machen ..xD also wen ich z.b F1 drücke,soll ich in ein Menü reinkommen und dan auch für F1 etwas anderes amchen also z.b F1= Begrüßungs hotkeys => Press F1 =>
[Fragen zu] Gui Hide & Show / Admin Rights / Func in Func
12/12/2010 - AutoIt - 29 Replies
Hi Leute, wie ihr oben ja bereits lesen könnt habe ich ein paar Fragen. 1. Könnte mir jmd. eine Hotkeyset-Func schreiben, womit ich mit nur einer (!) Taste die GUI verstecken und wieder anzeigen lassen kann ? 2. Gibt es etwas, dass dem gescripteten Tool von selbst Adminrechte verschafft? Ich rede NICHT von RequireAdmin, da muss man ja Administrator des PCs sein. €: Kann "#requireadmin" rausgezögert werden ?! Ich möchte, dass das passiert, aber erst, wenn ich einen Knopf gedrückt...



All times are GMT +1. The time now is 20:22.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.