Jump to content

Is possible create this functions?


Recommended Posts

Hi all, my question is the next:

 

Is possible create two new functions for quest, pc.get_otherpc_quest_flag and pc.set_otherpc_quest_flag

 

Same pc.getf and pc.setf, but for others players.

 

pc.get_otherpc_quest_flag(namepc,namequest,questqf)

 

pc.set_otherpc_quest_flag(namepc,namequest,questqf,value)

 

Thanks.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Premium

Well I just made this two functions for you, but I didn't test it, so please do it for me (but it should work) ;)

Write these into the questlua_pc.cpp:

	int pc_get_another_pcs_flag(lua_State * L)
	{
		if (lua_gettop(L) != 3 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3))
		{
			lua_pushnumber(L, -1);
			return 1;
		}

		const char * sPC = lua_tostring(L, 1);
		std::string qName = lua_tostring(L, 2);
		std::string qFlag = lua_tostring(L, 3);

		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
		if (!selPC)
		{
			lua_pushnumber(L, -1);
			return 1;
		}
		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
		if (!qPC)
		{
			lua_pushnumber(L, -1);
			return 1;
		}
		lua_pushnumber(L, qPC->GetFlag(qName + "." + qFlag));
		return 1;
	}

	int pc_set_another_pcs_flag(lua_State * L)
	{
		if (lua_gettop(L) != 4 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3) && !lua_isnumber(L, 4))
			return 0;

		const char * sPC = lua_tostring(L, 1);
		std::string qName = lua_tostring(L, 2);
		std::string qFlag = lua_tostring(L, 3);

		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
		if (!selPC)
			return 0;
		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
		if (!qPC)
			return 0;

		qPC->SetFlag(qName + "." + qFlag, int(rint(lua_tonumber(L, 4))));
		return 0;
	}

Then scroll down to it's end, and write these into the luaL_reg pc_functions[] matrix:

{ "get_otherpc_quest_flag", pc_get_another_pcs_flag },
{ "set_otherpc_quest_flag", pc_set_another_pcs_flag },

The arguments the same that you wrote in the first post of this topic. If an error trigger durning get_otherpc_quest_flag, it will push back -1 as the flag's value.

Note that it maybe works only if the other pc is online!

The one and only UI programming guideline

Link to comment
Share on other sites

Well I just made this two functions for you, but I didn't test it, so please do it for me (but it should work) ;)

Write these into the questlua_pc.cpp:

	int pc_get_another_pcs_flag(lua_State * L)
	{
		if (lua_gettop(L) != 3 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3))
		{
			lua_pushnumber(L, -1);
			return 1;
		}

		const char * sPC = lua_tostring(L, 1);
		std::string qName = lua_tostring(L, 2);
		std::string qFlag = lua_tostring(L, 3);

		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
		if (!selPC)
		{
			lua_pushnumber(L, -1);
			return 1;
		}
		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
		if (!qPC)
		{
			lua_pushnumber(L, -1);
			return 1;
		}
		lua_pushnumber(L, qPC->GetFlag(qName + "." + qFlag));
		return 1;
	}

	int pc_set_another_pcs_flag(lua_State * L)
	{
		if (lua_gettop(L) != 4 && !lua_isstring(L, 1) && !lua_isstring(L, 2) && !lua_isstring(L, 3) && !lua_isnumber(L, 4))
			return 0;

		const char * sPC = lua_tostring(L, 1);
		std::string qName = lua_tostring(L, 2);
		std::string qFlag = lua_tostring(L, 3);

		LPCHARACTER selPC = CHARACTER_MANAGER::instance().FindPC(sPC);
		if (!selPC)
			return 0;
		PC * qPC = CQuestManager::instance().GetPCForce(selPC->GetPlayerID());
		if (!qPC)
			return 0;

		qPC->SetFlag(qName + "." + qFlag, int(rint(lua_tonumber(L, 4))));
		return 0;
	}

Then scroll down to it's end, and write these into the luaL_reg pc_functions[] matrix:

{ "get_otherpc_quest_flag", pc_get_another_pcs_flag },
{ "set_otherpc_quest_flag", pc_set_another_pcs_flag },

The arguments the same that you wrote in the first post of this topic. If an error trigger durning get_otherpc_quest_flag, it will push back -1 as the flag's value.

Note that it maybe works only if the other pc is online!

Thanks masodikbela, after compile and test write pm to you :)

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.