Jump to content

pet.is_mine problem


Go to solution Solved by Alina,

Recommended Posts

Hi metin2dev, I have a problem with pet.is_mine function...
In questlua_pet.ccp I have this:

 


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;
}

 

In quest this:

 

when 34001.click with pet.is_mine() begin
say_title("Pet")
end

 

and when I click on pet, so game will write this :X

 

SYSERR: Mar 31 18:42:13 :: RunState: LUA_ERROR: [string "pet_system"]:1: attempt to call global `is_mine' (a nil value)
SYSERR: Mar 31 18:42:13 :: WriteRunningStateToSyserr: LUA_ERROR: quest pet_system.start click

 

Many thanks for help  :)

 
Link to comment
Share on other sites

int pet_is_mine(lua_State * L)
{
	LPCHARACTER ch = CQuestManager::Instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::Instance().GetCurrentNPCCharacterPtr();
	CPetSystem * pPetSystem = ch->GetPetSystem();
	
	if (!pPetSystem)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	CPetActor * pPetActor = pPetSystem->GetByVID(npc->GetVID());
	
	if (!pPetActor)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	LPCHARACTER pet = pPetActor->GetCharacter();
	
	if (!pet)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	lua_pushboolean(L, pet->GetVID() == npc->GetVID());
	return 1;
}

Kind Regards

Ken

  • Love 2

Do not be sorry, be better.

Link to comment
Share on other sites

 

Did you write the pet_is_mine_function into the pet function table?

In the same file (questlua_pet.cpp) scroll down and check if you made an entry. The error is caused due to the server not knowing what 'is_mine' from the pet-class actually is. So I guess you just forgot to add it  :)

 

Oh jesus, I forgot it :D Thanks :)

 

int pet_is_mine(lua_State * L)
{
	LPCHARACTER ch = CQuestManager::Instance().GetCurrentCharacterPtr();
	LPCHARACTER npc = CQuestManager::Instance().GetCurrentNPCCharacterPtr();
	CPetSystem * pPetSystem = ch->GetPetSystem();
	
	if (!pPetSystem)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	CPetActor * pPetActor = pPetSystem->GetByVID(npc->GetVID());
	
	if (!pPetActor)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	LPCHARACTER pet = pPetActor->GetCharacter();
	
	if (!pet)
	{
		lua_pushboolean(L, false);
		return 0;
	}
	
	lua_pushboolean(L, pet->GetVID() == npc->GetVID());
	return 1;
}

Kind Regards

Ken

 

 

Thanks Ken, I will try it :)

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.