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

pet.is_mine problem


Grou

Question

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

6 answers to this question

Recommended Posts

  • 0

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 :)

  • Love 1
Link to comment
  • 0
  • Moon
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
  • 0
 

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

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


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.