Jump to content

Jeden Spieler auswählen/go through all players


Recommended Posts

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
Share on other sites

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
Share on other sites

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