Jump to content
  • 0

Jeden Spieler auswählen/go through all players


Benhero

Question

Hallo M2Dev Com,

 

Ich wollte mir eben einen neuen GM Command erstellen.

 

2 Funktionieren auch soweit ohne Probleme.

Ledegleich beim 3 bzw. 4 Stoße ich aktuell an meine Grenzen.

 

Wie schaffe ich es auf jeden Spieler auf der Aktuellen Map zuzugreifen

und seine Daten abzufangen. z.B. ch->GetName().

 

Ich habe schon versucht mir das von anderen Funktionen abzuschauen (z.B. notice_map, notice ...)

Jedoch habe in diesem zusammenhang den Content nicht ganz verstanden.

 

Ich vermute ja, das die Lösung hier liegt:

struct notice_map_packet_func
{
	const char* m_str;
	int m_mapIndex;
	bool m_bBigFont;

	notice_map_packet_func(const char* str, int idx, bool bBigFont) : m_str(str), m_mapIndex(idx), m_bBigFont(bBigFont)
	{
	}

	void operator() (LPDESC d)
	{
		if (d->GetCharacter() == NULL) return;
		if (d->GetCharacter()->GetMapIndex() != m_mapIndex) return;

		d->GetCharacter()->ChatPacket(m_bBigFont == true ? CHAT_TYPE_BIG_NOTICE : CHAT_TYPE_NOTICE, "%s", m_str);
	}
};

void SendNoticeMap(const char* c_pszBuf, int nMapIndex, bool bBigFont)
{
	const DESC_MANAGER::DESC_SET & c_ref_set = DESC_MANAGER::instance().GetClientSet();
	std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_map_packet_func(c_pszBuf, nMapIndex, bBigFont));
}

Aber leider verstehe ich es nicht so ganz.

 

Ich hoffe sehr ihr könnt mir helfen!

 

Mit freundlichen Grüßen

Benhero

Link to comment

4 answers to this question

Recommended Posts

  • 0

I want to create a Command which will chance a Effect with "ch->RemoveAffect(xxx)" from all players on my actuall map.

I don't know how go through all player on my acutal map. I think the soulution for my question is in here:

struct notice_map_packet_func
{
    const char* m_str;
    int m_mapIndex;
    bool m_bBigFont;
 
    notice_map_packet_func(const char* str, int idx, bool bBigFont) : m_str(str), m_mapIndex(idx), m_bBigFont(bBigFont)
    {
    }
 
    void operator() (LPDESC d)
    {
        if (d->GetCharacter() == NULL) return;
        if (d->GetCharacter()->GetMapIndex() != m_mapIndex) return;
 
        d->GetCharacter()->ChatPacket(m_bBigFont == true ? CHAT_TYPE_BIG_NOTICE : CHAT_TYPE_NOTICE, "%s", m_str);
    }
};
 
void SendNoticeMap(const char* c_pszBuf, int nMapIndex, bool bBigFont)
{
    const DESC_MANAGER::DESC_SET & c_ref_set = DESC_MANAGER::instance().GetClientSet();
    std::for_each(c_ref_set.begin(), c_ref_set.end(), notice_map_packet_func(c_pszBuf, nMapIndex, bBigFont));
}

But i can't find it..

 

Please help :(

Link to comment
  • 0
  • VIP
void RemoveAffectInMap(const long lMapIndex, const DWORD dwAffect)
{
	if (lMapIndex)
	{
		const DESC_MANAGER::DESC_SET & c_ref_set = DESC_MANAGER::instance().GetClientSet();
		std::for_each(c_ref_set.begin(), c_ref_set.end(), aff_remove_func(lMapIndex, dwAffect));
	}
}

struct aff_remove_func
{
	const long  m_lMapIndex;
	const DWORD m_dwAffect;

	aff_remove_func(const long lMapIndex, const DWORD dwAffect) : m_lMapIndex(lMapIndex), m_dwAffect(dwAffect)
	{
	}

	void operator () (LPDESC d)
	{
		if (!d)
			return;

		LPCHARACTER ch;

		if (!(ch = d->GetCharacter()))
			return;

		if (ch->GetMapIndex() == m_lMapIndex && ch->FindAffect(dwAffect))
			ch->RemoveAffect(dwAffect);
	}
};
  • Love 2
Link to comment

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


×
×
  • 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.