Jump to content

Is there any quest function which checks how many players are in a Map?


Recommended Posts

  • Premium
struct FPlayerCounter
{
	int nCount;

	void operator () (LPENTITY ent)
	{
		if (ent->IsType(ENTITY_CHARACTER))
		{
			LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);

			if (pChar->IsPC() == true)
			{
				nCount++;
			}
		}
	}
};
ACMD(do_get_player_count)
{
	LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());

	if (pSectree == NULL)
		return;

	FPlayerCounter f;
	f.nCount = 0;

	pSectree->for_each(f);

	ch->ChatPacket(CHAT_TYPE_INFO, "MapIndex: %d PlayerCount %d", ch->GetMapIndex(), f.nCount);
}

 

  • Love 2
Link to comment
Share on other sites

Acum 22 minute, Dobrescu Sebastian a spus:

struct FPlayerCounter
{
	int nCount;

	void operator () (LPENTITY ent)
	{
		if (ent->IsType(ENTITY_CHARACTER))
		{
			LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);

			if (pChar->IsPC() == true)
			{
				nCount++;
			}
		}
	}
};

ACMD(do_get_player_count)
{
	LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());

	if (pSectree == NULL)
		return;

	FPlayerCounter f;
	f.nCount = 0;

	pSectree->for_each(f);

	ch->ChatPacket(CHAT_TYPE_INFO, "MapIndex: %d PlayerCount %d", ch->GetMapIndex(), f.nCount);
}

 

Wow, thank you very much!

But can you please tell me where to put these?

And can it be used as a quest function? I want to check the number of players from a map with a quest

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

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.