Jump to content

pet.is_mine() quest function


Go to solution Solved by xP3NG3Rx,

Recommended Posts

  • Premium
	int pet_is_mine(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		LPCHARACTER pet = CQuestManager::instance().GetCurrentNPCCharacterPtr();

		lua_pushboolean(L, pet && pet->GetRider() == ch);
		return 1;
	}

doesn't work

 

do anyone know an other solution?

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

try this

int pet_is_mine(lua_State* L)
{
    CQuestManager& q = CQuestManager::instance();
    LPCHARACTER ch = q.GetCurrentCharacterPtr();
    LPCHARACTER pet = q.GetCurrentNPCCharacterPtr();

    lua_pushboolean(L, ch->IsPet() || pet && pet->GetOwner() == ch);
    return 1;
}

http://www.elitepvpers.com/forum/metin2-pserver-guides-strategies/3064054-sammelthread-40k-function-wishes-6.html#post26763453

Link to comment
Share on other sites

  • Honorable Member
  • Solution
	int pet_is_mine(lua_State* L)
	{
		CQuestManager& q = CQuestManager::instance();
		LPCHARACTER mch = q.GetCurrentCharacterPtr();
		LPCHARACTER tch = q.GetCurrentNPCCharacterPtr();
		CPetSystem* petSystem = mch->GetPetSystem();
		CPetActor* petActor = petSystem->GetByVID(tch->GetVID());

		// ~ DEBUG Messages:
		/*
		sys_log(0, "mch->GetVID : %d", mch->GetVID());
		sys_log(0, "npc->GetVID : %d", npc->GetVID());
		sys_log(0, "petSystem : %s", (petSystem ? "True":"False"));
		sys_log(0, "petActor : %s", (petActor ? "True":"False"));
		sys_log(0, "npc->IsPet() : %s", (npc->IsPet() ? "True":"False"));
		if (petActor)
			sys_log(0, "petActor->GetOwner()->GetVID() : %d", petActor->GetOwner()->GetVID());
		*/

		lua_pushboolean(L, tch && tch->IsPet() && petActor && petActor->GetOwner() == mch);
		return 1;
	}

I'm using this and works completely.

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.