Jump to content
×
×
  • Create New...
  • 0

How can i talk to a NPC via Python?


OnlyGood

Question

Hey, how can i talk to a specific NPC?
 

I know about

vid = player.GetTargetVID()
net.SendOnClickPacket(vid)

but with this, the NPC has to be marked.

 

The problem is, the vid of this specific NPC always changes if i teleport away.

 

Is there a way, how i can scan the vid of a specific NPC nearby and automatic talk to it, if im in x range?

Edited by OnlyGood
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 1

CPythonCharacterManager has functions like CharacterInstanceBegin and CharacterInstanceEnd so you can iterate over the characters nearby like:

TPixelPosition myPos;
CPythonPlayer::instance().NEW_GetMainActorPosition(&myPos);

CPythonCharacterManager& chrMgr = CPythonCharacterManager::instance();
for (auto it = chrMgr.CharacterInstanceBegin(); it != chrMgr.CharacterInstanceEnd(); ++it)
{
	if (CInstanceBase* ch = *it)
	{
		TPixelPosition otherPos;
		ch->NEW_GetPixelPosition(&otherPos);
		if(GetPixelPositionDistance(myPos, otherPos) <= SOME DISTANCE && some other thing to identify your npc)
		{
			CPythonNetworkStream::Instance().SendOnClickPacket(ch->GetVirtualID());
		}
	}
}

 

Edited by Distraught
  • Love 1

WRnRW3H.gif

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 0

      Looking for Someone to create the queries etc for armors and weapons

    2. 13

      Official Private Shop Search

    3. 944

      [40250] Reference Serverfile + Client + Src [15 Available Languages]

    4. 79

      GUI Teleport System

    5. 0

      inventory slot marking system cant compile

    6. 8

      Inventory Bug

    7. 63

      Metin2 Dev - Changelogs

  • Recently Browsing

    • No registered users viewing this page.

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.