Hey guys,
I try to set every player an ffa flag, when they enter my custom map (ID 9999). DBC editing is not possible, because my map is a copy of outlands…yeah…so I worked something out, but its…little broken…a player get ffa flaged, but if he change the area or zone, he lose the flag…
yeah…here my script:
[CODE]
#include “ScriptPCH.h”
enum Enums
{
FIRST_TELEDELAY = 1000,
};
class Teleport : public BasicEvent
{
public:
Teleport(Player* player) : _player(player) { }
bool Execute(uint64 /*time*/, uint32 /*diff*/)
{
printf("TIME EVENT\n");
_player->pvpInfo.IsInFFAPvPArea = true;
_player->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
return true;
}
Player* _player;
};
class OnMapEnter : public PlayerScript
{
public:
OnMapEnter() : PlayerScript(“OnMapEnter”) { }
void OnUpdateZone(Player* player, uint32 /*newZone*/, uint32 newArea) override
{
printf("FIRSTUPDATEZONE\n");
player->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
if (player->GetAreaId() == 0)
{
printf("UPDATE ZONE!\n");
player->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
Teleport* tele = new Teleport(player);
player->m_Events.AddEvent(tele, player->m_Events.CalculateTime(FIRST_TELEDELAY));
}
return;
}
void OnMapChanged(Player * player) override
{
if (player->GetMapId() == 9999)
{
player->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
Teleport* tele = new Teleport(player);
player->m_Events.AddEvent(tele, player->m_Events.CalculateTime(FIRST_TELEDELAY));
printf("UPDATE MAP!\n");
}
}
};
void AddSC_OnMapEnter()
{
new OnMapEnter();
}
[/CODE]hope someone has an idea, how to solve this…