feat(Scripts/Command): Update gm fly to behave like a toggle (#20925)
This commit is contained in:
@@ -92,22 +92,31 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleGMFlyCommand(ChatHandler* handler, bool enable)
|
static bool HandleGMFlyCommand(ChatHandler* handler, Optional<bool> enable)
|
||||||
{
|
{
|
||||||
Player* target = handler->getSelectedPlayer();
|
Player* target = handler->getSelectedPlayer();
|
||||||
if (!target)
|
if (!target)
|
||||||
target = handler->GetSession()->GetPlayer();
|
target = handler->GetSession()->GetPlayer();
|
||||||
|
|
||||||
WorldPacket data(12);
|
WorldPacket data(12);
|
||||||
if (enable)
|
|
||||||
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
|
bool canFly = false;
|
||||||
|
if (enable.has_value())
|
||||||
|
{
|
||||||
|
data.SetOpcode(*enable ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY);
|
||||||
|
canFly = *enable;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
|
{
|
||||||
|
canFly = handler->GetSession()->GetPlayer()->CanFly();
|
||||||
|
data.SetOpcode(canFly ? SMSG_MOVE_UNSET_CAN_FLY : SMSG_MOVE_SET_CAN_FLY);
|
||||||
|
canFly = !canFly;
|
||||||
|
}
|
||||||
|
|
||||||
data << target->GetPackGUID();
|
data << target->GetPackGUID();
|
||||||
data << uint32(0); // unknown
|
data << uint32(0); // unknown
|
||||||
target->SendMessageToSet(&data, true);
|
target->SendMessageToSet(&data, true);
|
||||||
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), enable ? "on" : "off");
|
handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), canFly ? "on" : "off");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user