ffa flag when player enter map

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…:slight_smile:

— Canned message start —
This thread is not related to the official Trinity codebase and was moved to the Custom Code section.
Please read the stickies next time.
— Canned message end —

Hmm… why the DBC editing is not possible?

This works for me on non custom maps:

[CODE]#include “ScriptPCH.h”

class Teleport : public BasicEvent
{
public:
Teleport(Player* player) : _player(player)
{
player->m_Events.AddEvent(this, player->m_Events.CalculateTime(0));
}

bool Execute(uint64 /*time*/, uint32 /*diff*/)
{
    printf("TIME EVENT\n");
    _player->pvpInfo.IsInFFAPvPArea = true;
    _player->UpdatePvPState(true);
    return true;
}

Player* _player;

};

class OnMapEnter : public PlayerScript
{
public:
OnMapEnter() : PlayerScript(“OnMapEnter”) { }

void OnUpdateZone(Player* player, uint32 /*newZone*/, uint32 /*newArea*/) override
{
    if (player->GetMapId() == 1)
    {
        printf("UPDATE ZONE!\n");
        new Teleport(player);
    }
}

void OnMapChanged(Player * player) override
{
    if (player->GetMapId() == 1)
    {
        printf("UPDATE MAP!\n");
        new Teleport(player);
    }
}

};

void AddSC_OnMapEnter()
{
new OnMapEnter();
}[/CODE]