Prevent Player movement/Stun Player

Hello TC-Community,

I’m looking for a method to stun the player, that means the player shouldn’t be allowed to move, autoattack, cast, use items etc.

While he’s stunned, i want to play an emote, so i cant just stun him by a spell.

I’ve already tried following:

[COLOR=rgb(40,40,40)]player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);

[COLOR=rgb(40,40,40)]player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); (Or something like stunned, forgot the name)

[COLOR=rgb(40,40,40)]I hope you guys can help me.

[COLOR=rgb(40,40,40)]~Kaev

use command .freeze

        if (player && (player != handler->GetSession()->GetPlayer()))
        {
            handler->PSendSysMessage(LANG_COMMAND_FREEZE, name.c_str());

            // stop combat + make player unattackable + duel stop + stop some spells
            player->setFaction(35);
            player->CombatStop();
            if (player->IsNonMeleeSpellCast(true))
                player->InterruptNonMeleeSpells(true);
            player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

            // if player class = hunter || warlock remove pet if alive
            if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK))
            {
                if (Pet* pet = player->GetPet())
                {
                    pet->SavePetToDB(PET_SAVE_AS_CURRENT);
                    // not let dismiss dead pet
                    if (pet->IsAlive())
                        player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
                }
            }
        if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(9454))
            Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player);

I cant use .freeze, because my character is sleeping then.

I want to play my emote (eat), what i cant do then.

But this could be a possible solution if i can’t find another way. Thank you!

EDIT: I found this: http://wotlk.openwow.com/spell=52165

This could it be, still testing.

EDIT2: This was the solution. Thanks for your help!

FFR:

[CODE]
int SetPlayerLock(lua_State* L, Player* player)
{
bool apply = luaL_optbool(L, 1, true);

    if (apply)
    {
        player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED);
        player->SetClientControl(player, 0);
    }
    else
    {
        player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED);
        player->SetClientControl(player, 1);
    }
    return 0;
}[/CODE]

^From mangos eluna

Originally from Arc:
https://github.com/arcemu/arcemu/blob/a816536509479765b54025fedc4b40492c4cd07e/src/scripts/src/luabridge/object_functions/unit_functions.cpp#L2006

Will disable spell casting and moving etc.