Onforum.net - Web and gaming resource community

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members .

Metin2 Freeze player in game by GM

Dean

Well-known member
Credits
118


Code:
#ifdef ENABLE_GM_LOCK_PLAYER
    if (isLocked())
        return false;
#endif

client src
GameLib/ActorInstance.cpp
Code:
// find:
BOOL CActorInstance::IsDead()
{
    return m_isRealDead;
}
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
BOOL CActorInstance::IsLocked()
{
    return m_isLocked;
}
#endif
// find:
void CActorInstance::Stun()
{
    m_isStun = TRUE;
}
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
void CActorInstance::LockPlayer(BYTE state)
{
    m_isLocked = state;
}
#endif
// find:
    m_isResistFallen = FALSE;
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    m_isLocked = FALSE;
#endif
GameLib/ActorInstanceBattle.cpp
Code:
// find in bool CActorInstance::CanAct()
    if (IsSleep())
        return false;
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    if (IsLocked())
        return false;
#endif
GameLib/ActorInstance.h
Code:
// find:
        BOOL        IsDead();
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
        BOOL        IsLocked();
        void        LockPlayer(BYTE state);
#endif
// find:
        BOOL                        m_isRealDead;
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
        BOOL                        m_isLocked;
#endif
UserInterface/Locale_inc.h

Code:
#define ENABLE_GM_LOCK_PLAYER                        // Lock Player Move by GM
UserInterface/InstanceBase.cpp
Code:
// find:
BOOL CInstanceBase::IsSleep()
{
    return m_GraphicThingInstance.IsSleep();
}
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
BOOL CInstanceBase::IsLocked()
{
    return m_GraphicThingInstance.IsLocked();
}
#endif
UserInterface/InstanceBaseBattle.cpp
UserInterface/InstanceBase.h
Code:
// find:
        void                    Die();
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
        void                    SetLockPlayer(BYTE status);
#endif
// find:
        BOOL                    IsSleep();
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
        BOOL                    IsLocked();
#endif
UserInterface/Packet.h
Code:
// find:
    HEADER_GC_MAIN_CHARACTER4_BGM_VOL            = 138,
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    HEADER_GC_LOCK_PLAYER                        = 139,
#endif
// add at the end of the file befor #pragma pack(pop)
#ifdef ENABLE_GM_LOCK_PLAYER
typedef struct SPacketGCLockPlayer
{
    BYTE    bHeader;
    BYTE    status;
    DWORD    vid;
} TPacketGCLockPlayer;
#endif
UserInterface/PythonNetworkStream.cpp
Code:
// find:
            Set(HEADER_GC_ACCE,    CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCAcce), DYNAMIC_SIZE_PACKET));
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
            Set(HEADER_GC_LOCK_PLAYER, CNetworkPacketHeaderMap::TPacketType(sizeof(TPacketGCLockPlayer), STATIC_SIZE_PACKET));
#endif
UserInterface/PythonNetworkStream.h
Code:
// find:
        bool RecvFishing();
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
        bool RecvLockPlayer();
#endif
UserInterface/PythonPlayerInputMouse.cpp
Code:
// find in void CPythonPlayer::NEW_SetMouseSmartState(int eMBS, bool isAuto)
    if (pkInstMain->IsSleep())
    {
        return;
    }
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    if (pkInstMain->IsLocked())
        return;
#endif
UserInterface/PythonNetworkStreamPhaseGame.cpp
Code:
// find:
            default:
                ret = RecvDefaultPacket(header);
                break;
        }
    }
    if (!ret)
        RecvErrorPacket(header);
// add BEFORE!
#ifdef ENABLE_GM_LOCK_PLAYER
            case HEADER_GC_LOCK_PLAYER:
                ret = RecvLockPlayer();
                break;
#endif
// add at the end of the file:
#ifdef ENABLE_GM_LOCK_PLAYER
bool CPythonNetworkStream::RecvLockPlayer()
{
    TPacketGCLockPlayer packet;
    if (!Recv(sizeof(packet), &packet))
        return false;
    CPythonCharacterManager& rkChrMgr = CPythonCharacterManager::Instance();
    CInstanceBase* pkInstSel = rkChrMgr.GetInstancePtr(packet.vid);
    if (pkInstSel)
    {
        pkInstSel->SetLockPlayer(packet.status);
    }
    return true;
}
#endif
server_src
common/service.h
Code:
#define ENABLE_GM_LOCK_PLAYER                    // Lock Player Move by GM
game/cmd.cpp
Code:
// find:
struct command_info cmd_info[] =
// add BEFORE:
#ifdef ENABLE_GM_LOCK_PLAYER
ACMD(do_lock_player);
#endif
// find:
    { "\n",                        NULL,                        0,                POS_DEAD,        GM_IMPLEMENTOR    }
// add BEFORE:
#ifdef ENABLE_GM_LOCK_PLAYER
    { "lock_player",            do_lock_player,                0,                POS_DEAD,        GM_IMPLEMENTOR },
#endif
game/char.h
Code:
// add at the end of the file
BEFORE:
};
ESex GET_SEX(LPCHARACTER ch);
this:
#ifdef ENABLE_GM_LOCK_PLAYER
    public:
        bool    isLocked() const;
        void    LockPlayer(BYTE status);
    protected:
        BOOL    m_isLocked;
#endif
game/cmd_general.cpp
Code:
// find in ACMD(do_user_horse_ride):
    if (ch->IsDead() || ch->IsStun())
// replace it with:
    if (ch->IsDead() || ch->IsStun()
#ifdef ENABLE_GM_LOCK_PLAYER
         || ch->isLocked()
#endif
        )
// find in ACMD(do_ride):
    if (ch->IsDead() || ch->IsStun())
// replace it with:
    if (ch->IsDead() || ch->IsStun()
#ifdef ENABLE_GM_LOCK_PLAYER
        || ch->isLocked()
#endif
        )
game/cmd_gm.cpp
Code:
// add at the end of the file:
#ifdef ENABLE_GM_LOCK_PLAYER
ACMD(do_lock_player)
{
    char arg1[256];
    one_argument(argument, arg1, sizeof(arg1));
    const char* name = arg1;
    if (!*arg1)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Invalid argument.");
        return;
    }
    LPCHARACTER sas = CHARACTER_MANAGER::instance().FindPC(name);
    if (!sas)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "Der Spieler ist nicht Online");
        return;
    }
    if (!sas->IsPC())
        return;
    DWORD vid = sas->GetVID();
    LPCHARACTER tch = CHARACTER_MANAGER::instance().Find(vid);
    const char* spieler = sas->GetName();
    if (!tch)
    {
        ch->ChatPacket(CHAT_TYPE_INFO, "<Sytem> Der Spieler existiert nicht!");
        return;
    }
    if (!tch->IsPC())
        return;
    BYTE status;
    if (tch->isLocked())
        status = 0;
    else
        status = 1;
    if (status == 1)
        tch->ChatPacket(CHAT_TYPE_INFO, "You have been locked by a GM");
    else
        tch->ChatPacket(CHAT_TYPE_INFO, "You have benn unlocked by a GM");
    tch->ChatPacket(CHAT_TYPE_INFO, "You was stucked by a GM.");
    tch->LockPlayer(status);
    TPacketGCLockPlayer packet;
    packet.bHeader = HEADER_GC_LOCK_PLAYER;
    packet.status = status;
    packet.vid = vid;
    tch->GetDesc()->Packet(&packet, sizeof(packet));
    if (status == 1)
        ch->ChatPacket(CHAT_TYPE_INFO, "Locked %s(%d)", spieler, vid);
    else
        ch->ChatPacket(CHAT_TYPE_INFO, "Unlocked %s(%d)", spieler, vid);
}
#endif
game/packet.h
Code:
// find:
    HEADER_GC_MAIN_CHARACTER4_BGM_VOL            = 138,
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    HEADER_GC_LOCK_PLAYER                        = 139,
#endif
// add at the end of the file before #pragma pack()
#ifdef ENABLE_GM_LOCK_PLAYER
typedef struct SPacketGCLockPlayer
{
    BYTE    bHeader;
    BYTE    status;
    DWORD    vid;
} TPacketGCLockPlayer;
#endif
game/char.cpp
Code:
// find:
void CHARACTER::Initialize()
{
    CEntity::Initialize(ENTITY_CHARACTER);
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    m_isLocked = FALSE;
#endif
// find in bool CHARACTER::CanMove() const
    if (GetMyShop())
        return false;
// add after:
#ifdef ENABLE_GM_LOCK_PLAYER
    if (isLocked())
        return false;
#endif
// add at the end of the file:
#ifdef ENABLE_GM_LOCK_PLAYER
bool CHARACTER::isLocked() const
{
    return m_isLocked;
}
void CHARACTER::LockPlayer(BYTE status)
{
    m_isLocked = status;
}
#endif
 
You could also add affects (minus moving and attacking speed) then player can not run and attack.
 

Similar threads


Top

Dear User!

We found that you are blocking the display of ads on our site.

Please add it to the exception list or disable AdBlock.

The advertises that you'll see aren't intrusive they just help us to keep the community alive

If you don't want to see those ads just buy an upgrade.

Thank you for understanding!

Baba2

Baba2 Purchase

User upgrade! at

🔥 Upgrade Now

Escanor25 Purchase

User upgrade! at

🔥 Upgrade Now
Tigrex

Tigrex Purchase

User upgrade! at

🔥 Upgrade Now