Jump to content

Quest Function is_trade


Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Premium

int pc_do_something(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen())
	{
		lua_pushboolean(L, 1);
	}
	else
	{
		lua_pushboolean(L, 0);
	}
	return 1;
}
 

 

Untested but should work. When character do something function returns true, if not return false. Simple & clean & usefull.

Link to comment
Share on other sites

  • Honorable Member

LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

lua_pushboolean(L, ch->GetExchange());

return 1;

no work. Help me

CExchange returns a "CExchange *", so you can't directly use it as an argument for boolean:

	int pc_is_trade0(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		lua_pushboolean(L, ch->GetExchange() != NULL);
		return 1;
	}
There are few other ways such as "(ch->GetExchange())" or "!!ch->GetExchange()".

 

int pc_do_something(lua_State* L)
{
	LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
	if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen())
	{
		lua_pushboolean(L, 1);
	}
	else
	{
		lua_pushboolean(L, 0);
	}
	return 1;
}
Untested but should work. When character do something function returns true, if not return false. Simple & clean & usefull.

Simplified:

	int pc_is_busy0(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		lua_pushboolean(L, (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen()));
		return 1;
	}
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


×
×
  • 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.