Jump to content

Check level of party members


Go to solution Solved by PetePeter,

Recommended Posts

  • Bot

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?

english_banner.gif

Link to comment
https://metin2.dev/topic/29224-check-level-of-party-members/
Share on other sites

  • Honorable Member
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

  • 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
  • Honorable Member
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

  • 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
  • Honorable Member
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

  • Former Staff
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
  • Bot

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

english_banner.gif

  • 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();

 

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

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.