Jump to content

Check level of party members


Go to solution Solved by PetePeter,

Recommended Posts

  • Active+ Member

Hi, i'm trying to create a simple dungeon, but i want to check the level of the members inside the party for example, for youself it is pc.get_level() <= level or >= level, but for the other members, how can we do it?

Link to comment
Share on other sites

  • Premium
local pc_data = {};
for _, pid in ipairs({party.get_member_pids()}) do
	q.begin_other_pc_block(pid);
	--
	table.insert(pc_data, {["name"] = pc.get_name(), ["level"] = pc.get_level()});
	--
	q.end_other_pc_block();
end -- for

for index, data in ipairs(pc_data) do
	say(string.format("%d. %s's level is %d.", index, data["name"], data["level"]))
end -- for

 

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium
if party.is_party() and party.is_leader() then
  	...
 
	local errLev = false
	local errMemb = {}

	local pids = {party.get_member_pids()}
	for i, pid in next, pids, nil do
		-->>>>>>>>>>>>>
		q.begin_other_pc_block(pid)
		if pc.get_level() < DUNGEON_LEVEL then
			errLev = true
			table.insert(errMemb, pc.get_name())
		end
		q.end_other_pc_block()
		--<<<<<<<<<<<<<
	end

	if errLev then
		lorem...
		return
	end
end

Try like this example for LUA, the commonest.

I made a safest function for it. The example above is not 100% safe.

  • Metin2 Dev 1
Link to comment
Share on other sites

  • Premium
2 minutes ago, WeedHex said:

I made a safest function for it. The example above is not 100% safe.

Care to expand on that? 😄 What do you mean it's not safe?

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium
4 minutes ago, Syreldar said:

Care to expand on that? 😄 What do you mean it's not safe?

Ehhhm sorry I'm not LUA addict ahaha.

I did with c++ an other way (based on what I need to check) because happened some guys exploit the begin_other_pc_block in some server. (With change channel and shits like that)

Of course if is only for level you can check it again in the dungeon and kick him out, but better to be careful in big servers about these things.

 

PS. WTF only I see my messages x2? 

Edited by WeedHex
Link to comment
Share on other sites

  • Premium
1 minute ago, WeedHex said:

Ehhhm sorry I'm not LUA addict ahaha.

I did with c++ an other way (based on what I need to check) because happened some guys exploit the begin_other_pc_block in some server. (With change channel and shits like that)

Of course if is only for level you can check it again in the dungeon and kick him out, but better to be careful in big servers about these things.

 

PS. WTF only I see my messages x2? 

I can assure you that if they can bug it you made a mistake in the quest. There's no reason to use C++ whatsoever.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Management
9 minutes ago, WeedHex said:

Ehhhm sorry I'm not LUA addict ahaha.

I did with c++ an other way (based on what I need to check) because happened some guys exploit the begin_other_pc_block in some server. (With change channel and shits like that)

Of course if is only for level you can check it again in the dungeon and kick him out, but better to be careful in big servers about these things.

 

PS. WTF only I see my messages x2? 

Known bug, sorry..

  • Good 1
Link to comment
Share on other sites

  • Active+ Member

Thanks for your comments, i appreciate!

Sry for pushing the post, isn't it better if it goes like this?

party.get_min_level()

 

Sry for pushing the post, isn't it better if it goes like this?

party.get_min_level()

Link to comment
Share on other sites

  • Solution
10 hours ago, Th1Doose said:

Thanks for your comments, i appreciate!

Sry for pushing the post, isn't it better if it goes like this?

party.get_min_level()

 

Sry for pushing the post, isn't it better if it goes like this?

party.get_min_level()

 

// questlua_party.cpp

ALUA(party_get_min_level)
{
  LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

  if (ch->GetParty())
    lua_pushnumber(L,ch->GetParty()->GetMemberMinLevel());
  else
    lua_pushnumber(L, 1);

  return 1;
}

// party.cpp

BYTE CParty::GetMemberMinLevel()
{
	BYTE bMin = PLAYER_MAX_LEVEL_CONST;

	itertype(m_memberMap) it = m_memberMap.begin();
	while (it!=m_memberMap.end())
	{
		if (!it->second.bLevel)
		{
			++it;
			continue;
		}

		if (!bMin)
			bMin = it->second.bLevel;
		else if (it->second.bLevel)
			bMin = MIN(bMin, it->second.bLevel);
		++it;
	}
	return bMin;
}

// party.h
BYTE		GetMemberMinLevel();

 

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.