Jump to content
For maintenance and updates, the community will be offline on 31 December 2022 ×
  • 0

Quest Function is_trade


Minion

Question

  • Answers 2
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

2 answers to this question

Recommended Posts

  • 0
  • 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

  • 0
  • 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

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. 1

      Costume shining/costume effect system

    2. 992

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

    3. 3

      Biologist Manager (C++ & LUA)

    4. 3

      Visual studio 2022 compiling issue

    5. 63

      Metin2 | Mount System Renewal

    6. 58

      Metin2 2004 Beta Client

    7. 0

      🔥Paradise2 PVP SERVER GLOBAL!! EN-ES-PT 🕐📢Apertura 11 de diciembre 21 horas de España!

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • 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.