Ejemplo n.º 1
0
bool
ChatHandler::Command_NPC_GUID (const char* args)
{
    WorldPacket data;

    uint64 guid;
    guid = m_session->GetPlayer()->GetSelection();
    if (guid == 0)
    {
        FillSystemMessageData(&data, m_session, LANG_CMD_NOSEL);
        m_session->SendPacket( &data );
        return true;
    }

	m_session->SystemMessage(LANG_CMD_NPC_GUID, GUID_LOPART(guid), GUID_HIPART(guid));
    return true;
}
Ejemplo n.º 2
0
void ChatHandler::SendGlobalSysMessage(const char *str)
{
    // Chat output
    WorldPacket data;

    // need copy to prevent corruption by strtok call in LineFromMessage original string
    char* buf = strdup(str);
    char* pos = buf;

    while (char* line = LineFromMessage(pos))
    {
        FillSystemMessageData(&data, line);
        sWorld->SendGlobalMessage(&data);
    }

    free(buf);
}
Ejemplo n.º 3
0
bool ChatHandler::HandleModifyEnergyCommand(const char* args)
{
    WorldPacket data;

    // char* pmana = strtok((char*)args, " ");
    // if (!pmana)
    //     return false;

    // char* pmanaMax = strtok(NULL, " ");
    // if (!pmanaMax)
    //     return false;

    // int32 manam = atoi(pmanaMax);
    // int32 mana = atoi(pmana);
    int32 mana = atoi((char*)args)*10;
    int32 manam = atoi((char*)args)*10;

    if (mana <= 0 || manam <= 0 || manam < mana)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        PSendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    PSendSysMessage(LANG_YOU_CHANGE_ENERGY, mana/10, manam/10, chr->GetName());

    char buf[256];
    sprintf((char*)buf,LANG_YOURS_ENERGY_CHANGED, m_session->GetPlayer()->GetName(), mana/10, manam/10);
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    chr->SetMaxPower(POWER_ENERGY,manam );
    chr->SetPower(POWER_ENERGY, mana );

    sLog.outString(LANG_CURRENT_ENERGY,chr->GetMaxPower(POWER_ENERGY));

    return true;
}
Ejemplo n.º 4
0
bool ChatHandler::HandleHoverCommand(const char* args)
{
    WorldPacket data;

    data.Initialize(SMSG_MOVE_SET_HOVER);
    data << m_session->GetPlayer()->GetGUID();
    m_session->SendPacket( &data );

    WorldPacket data1;
    std::stringstream sstext;
    sstext << "Hover Enabled" << '\0';
    FillSystemMessageData(&data1, m_session, sstext.str().c_str());
    m_session->SendPacket( &data1 );



    return true;
}
Ejemplo n.º 5
0
bool ChatHandler::HandleLevelUpCommand(const char* args)
{
    uint32 curXP = m_session->GetPlayer()->GetUInt32Value(PLAYER_XP);
    uint32 nextLvlXP = m_session->GetPlayer()->GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
    uint32 givexp = nextLvlXP - curXP;

    uint32 points2 = m_session->GetPlayer()->GetUInt32Value(PLAYER_CHARACTER_POINTS2);
    m_session->GetPlayer()->SetUInt32Value(PLAYER_CHARACTER_POINTS2,points2+2);

    m_session->GetPlayer()->GiveXP(givexp,m_session->GetPlayer()->GetGUID());

    WorldPacket data;
    std::stringstream sstext;
    sstext << "You have been leveled Up" << '\0';
    FillSystemMessageData(&data, m_session, sstext.str().c_str());
    m_session->SendPacket( &data );
    return true;
}
Ejemplo n.º 6
0
bool ChatHandler::HandleModifyHPCommand(const char* args)
{
    WorldPacket data;

    //    char* pHp = strtok((char*)args, " ");
    //    if (!pHp)
    //        return false;

    //    char* pHpMax = strtok(NULL, " ");
    //    if (!pHpMax)
    //        return false;

    //    int32 hpm = atoi(pHpMax);
    //    int32 hp = atoi(pHp);

    int32 hp = atoi((char*)args);
    int32 hpm = atoi((char*)args);

    if (hp <= 0 || hpm <= 0 || hpm < hp)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    PSendSysMessage(LANG_YOU_CHANGE_HP, hp, hpm, chr->GetName());

    char buf[256];
    sprintf((char*)buf,LANG_YOURS_HP_CHANGED, m_session->GetPlayer()->GetName(), hp, hpm);
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    chr->SetMaxHealth( hpm );
    chr->SetHealth( hp );

    return true;
}
Ejemplo n.º 7
0
bool ChatHandler::HandleModifyASpeedCommand(const char* args)
{
    if (!*args)
        return false;

    float ASpeed = (float)atof((char*)args);

    if (ASpeed > 10 || ASpeed < 0.1)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    if(chr->isInFlight())
    {
        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
        return true;
    }

    PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName());

    WorldPacket data;
    char buf[256];
    sprintf((char*)buf,LANG_YOURS_ASPEED_CHANGED, m_session->GetPlayer()->GetName(), ASpeed);
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    chr->SetSpeed(MOVE_WALK,    ASpeed,true);
    chr->SetSpeed(MOVE_RUN,     ASpeed,true);
    chr->SetSpeed(MOVE_WALKBACK,ASpeed,true);
    chr->SetSpeed(MOVE_SWIM,    ASpeed,true);
    chr->SetSpeed(MOVE_SWIMBACK,ASpeed,true);
    //chr->SetSpeed(MOVE_TURN,    ASpeed,true);
    chr->SetSpeed(MOVE_FLY,     ASpeed,true);
    return true;
}
Ejemplo n.º 8
0
bool ChatHandler::HandleHelpCommand(const char* args)
{
    ChatCommand *table = getCommandTable();
    WorldPacket data;

    if(!*args)
        return false;

    char* cmd = strtok((char*)args, " ");
    if(!cmd)
        return false;

    if(!ShowHelpForCommand(getCommandTable(), cmd))
    {
        FillSystemMessageData(&data, m_session, "There is no such command");
        m_session->SendPacket( &data );
    }

    return true;
}
Ejemplo n.º 9
0
bool ChatHandler::HandleModifySpeedCommand(const char* args)
{
    WorldPacket data;

    if (!*args)
        return false;

    float Speed = (float)atof((char*)args);

    if (Speed > 50 || Speed <= 0)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName());

    char buf[256];
    sprintf((char*)buf,LANG_YOURS_SPEED_CHANGED, m_session->GetPlayer()->GetName(), Speed);
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    data.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE );
    data << uint8(0xFF);
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID );       //4
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID + 1 );   //4
    data << uint32(0x0);
    data << (float)Speed;                                   //4

    chr->SendMessageToSet( &data, true );

    return true;
}
Ejemplo n.º 10
0
bool ChatHandler::HandleModifySwimCommand(const char* args)
{
    if (!*args)
        return false;

    float Swim = (float)atof((char*)args);

    if (Swim > 10 || Swim < 0.01)
    {
        SendSysMessage(LANG_BAD_VALUE);
        return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    if(chr->isInFlight())
    {
        PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
        return true;
    }

    PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName());

    WorldPacket data;
    char buf[256];
    sprintf((char*)buf,LANG_YOURS_SWIM_SPEED_CHANGED, m_session->GetPlayer()->GetName(), Swim);
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    chr->SetSpeed(MOVE_SWIM,Swim,true);

    return true;
}
Ejemplo n.º 11
0
void ChatHandler::SendGlobalSysMessage(const char *str)
{
    WorldPacket data;
    FillSystemMessageData(&data, m_session, str);
    sWorld.SendGlobalMessage(&data);
}
Ejemplo n.º 12
0
bool ChatHandler::HandleMountCommand(const char* args)
{
    WorldPacket data;

    
    uint32 theLevel = m_session->GetPlayer( )->GetUInt32Value( UNIT_FIELD_LEVEL );
    uint16 mId=1147;
    float speed = (float)8;
    uint8 theRace = m_session->GetPlayer()->getRace();
    uint32 num=0;

    if (theLevel < 10 )
    {
    
        FillSystemMessageData(&data, m_session, "You have to be atleast level 10 to use this command.");
        m_session->SendPacket( &data );
        return true;
    }
    else
    {
        char* pMount = strtok((char*)args, " ");
        if( pMount )
        {
            num = atoi(pMount);
            switch(num)
            {
                case 1:                           
                    break;
                case 2:
                    if(theLevel<15) num=1;
                    break;
                case 3:
                    if(theLevel<20)
                        if(theLevel<15) num=1;
                    else
                        num=2;
                    break;
                default:
                    return true;
            }
        }
        else
        {
            if(theLevel>19)
                num=3;
            else
            if(theLevel>14)
                num=2;
            else
                num=1;
        }
        if (num > 2 )
        {
            switch(theRace)
            {
                case HUMAN:                       
                    mId=1147;
                    break;
                case ORC:                         
                    mId=295;
                    break;
                case DWARF:                       
                    mId=1147;
                    break;
                case NIGHTELF:                    
                    mId=479;
                    break;
                case UNDEAD_PLAYER:               
                    mId=1147;                     
                    break;
                case TAUREN:                      
                    mId=295;
                    break;
                case GNOME:                       
                    mId=1147;
                    break;
                case TROLL:                       
                    mId=479;
                    break;
            }
        }
        else if (num > 1 )
        {
            switch(theRace)
            {
                case HUMAN:                       
                    mId=1531;
                    break;
                case ORC:                         
                    mId=207;                      
                    break;
                case DWARF:                       
                    mId=2786;
                    break;
                case NIGHTELF:                    
                    mId=720;
                    break;
                case UNDEAD_PLAYER:               
                    mId=2346;
                    break;
                case TAUREN:                      
                    mId=180;
                    break;
                case GNOME:                       
                    mId=1147;                     
                    break;
                case TROLL:                       
                    mId=1340;
                    break;
            }
        }
        else
        {
            switch(theRace)
            {
                case HUMAN:                           
                    mId=236;
                    break;
                case ORC:                           
                    mId=207;
                    break;
                case DWARF:                       
                    mId=2186;
                    break;
                case NIGHTELF:                    
                    mId=632;
                    break;
                case UNDEAD_PLAYER:               
                    mId=5050;
                    break;
                case TAUREN:                      
                    mId=1220;
                    break;
                case GNOME:                       
                    mId=748;                      
                    break;
                case TROLL:                       
                    mId=2320;
                    break;
            }
        }
    }

    m_session->GetPlayer( )->SetUInt32Value( UNIT_FIELD_MOUNTDISPLAYID , mId);
    m_session->GetPlayer( )->SetUInt32Value( UNIT_FIELD_FLAGS , 0x002000 );

    if(theLevel>25)
        speed = (float)theLevel;
    else
        speed = (float)theLevel-1;

    if(speed > 35)
        speed = 35;

    data.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE );
    data << m_session->GetPlayer( )->GetUInt32Value( OBJECT_FIELD_GUID );
    data << m_session->GetPlayer( )->GetUInt32Value( OBJECT_FIELD_GUID + 1 );
    data << speed;
    WPAssert(data.size() == 12);
    m_session->GetPlayer( )->SendMessageToSet(&data, true);

    char cmount[256];
    sprintf(cmount, "You have a level %i mount at %i speed.", num, (int)speed);
    FillSystemMessageData(&data, m_session, cmount);
    m_session->SendPacket( &data );               

    return true;
}
Ejemplo n.º 13
0
bool ChatHandler::HandleModifyMountCommand(const char* args)
{
    WorldPacket data;

    if(!*args)
        return false;

    uint16 mId = 1147;
    float speed = (float)15;
    uint32 num = 0;

    num = atoi((char*)args);
    switch(num)
    {
        case 1:
            mId=14340;
            break;
        case 2:
            mId=4806;
            break;
        case 3:
            mId=6471;
            break;
        case 4:
            mId=12345;
            break;
        case 5:
            mId=6472;
            break;
        case 6:
            mId=6473;
            break;
        case 7:
            mId=10670;
            break;
        case 8:
            mId=10719;
            break;
        case 9:
            mId=10671;
            break;
        case 10:
            mId=10672;
            break;
        case 11:
            mId=10720;
            break;
        case 12:
            mId=14349;
            break;
        case 13:
            mId=11641;
            break;
        case 14:
            mId=12244;
            break;
        case 15:
            mId=12242;
            break;
        case 16:
            mId=14578;
            break;
        case 17:
            mId=14579;
            break;
        case 18:
            mId=14349;
            break;
        case 19:
            mId=12245;
            break;
        case 20:
            mId=14335;
            break;
        case 21:
            mId=207;
            break;
        case 22:
            mId=2328;
            break;
        case 23:
            mId=2327;
            break;
        case 24:
            mId=2326;
            break;
        case 25:
            mId=14573;
            break;
        case 26:
            mId=14574;
            break;
        case 27:
            mId=14575;
            break;
        case 28:
            mId=604;
            break;
        case 29:
            mId=1166;
            break;
        case 30:
            mId=2402;
            break;
        case 31:
            mId=2410;
            break;
        case 32:
            mId=2409;
            break;
        case 33:
            mId=2408;
            break;
        case 34:
            mId=2405;
            break;
        case 35:
            mId=14337;
            break;
        case 36:
            mId=6569;
            break;
        case 37:
            mId=10661;
            break;
        case 38:
            mId=10666;
            break;
        case 39:
            mId=9473;
            break;
        case 40:
            mId=9476;
            break;
        case 41:
            mId=9474;
            break;
        case 42:
            mId=14374;
            break;
        case 43:
            mId=14376;
            break;
        case 44:
            mId=14377;
            break;
        case 45:
            mId=2404;
            break;
        case 46:
            mId=2784;
            break;
        case 47:
            mId=2787;
            break;
        case 48:
            mId=2785;
            break;
        case 49:
            mId=2736;
            break;
        case 50:
            mId=2786;
            break;
        case 51:
            mId=14347;
            break;
        case 52:
            mId=14346;
            break;
        case 53:
            mId=14576;
            break;
        case 54:
            mId=9695;
            break;
        case 55:
            mId=9991;
            break;
        case 56:
            mId=6448;
            break;
        case 57:
            mId=6444;
            break;
        case 58:
            mId=6080;
            break;
        case 59:
            mId=6447;
            break;
        case 60:
            mId=4805;
            break;
        case 61:
            mId=9714;
            break;
        case 62:
            mId=6448;
            break;
        case 63:
            mId=6442;
            break;
        case 64:
            mId=14632;
            break;
        case 65:
            mId=14332;
            break;
        case 66:
            mId=14331;
            break;
        case 67:
            mId=8469;
            break;
        case 68:
            mId=2830;
            break;
        case 69:
            mId=2346;
            break;
        default:
            SendSysMessage(LANG_NO_MOUNT);
            return true;
    }

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName());

    char buf[256];
    sprintf((char*)buf,LANG_MOUNT_GIVED, m_session->GetPlayer()->GetName());
    FillSystemMessageData(&data, m_session, buf);

    chr->GetSession()->SendPacket(&data);

    chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );
    chr->Mount(mId);

    data.Initialize( SMSG_FORCE_RUN_SPEED_CHANGE );
    data << uint8(0xFF);
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID );
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID + 1 );
    data << (uint32)0;
    data << float(speed);
    chr->SendMessageToSet( &data, true );

    data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE );
    data << uint8(0xFF);
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID );
    data << chr->GetUInt32Value( OBJECT_FIELD_GUID + 1 );
    data << (uint32)0;
    data << float(speed);
    chr->SendMessageToSet( &data, true );

    return true;
}
Ejemplo n.º 14
0
bool ChatHandler::HandleNamegoCommand(const char* args)
{
    if(m_session->GetPlayer()->isInFlight())
    {
        SendSysMessage(LANG_YOU_IN_FLIGHT);
        return true;
    }

    if(!*args)
        return false;

    std::string name = args;
    normalizePlayerName(name);
    //sDatabase.escape_string(name);                          // prevent SQL injection - normal name don't must changed by this call

    Player *chr = objmgr.GetPlayer(name.c_str());
    if (chr)
    {

        if(chr->IsBeingTeleported()==true)
        {
            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
            return true;
        }

        if(chr->isInFlight())
        {
            PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
            return true;
        }

        if (MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer())->Instanceable())
        {
            if ( (MapManager::Instance().GetMap(chr->GetMapId(), chr)->Instanceable()) &&
                (MapManager::Instance().GetMap(chr->GetMapId(), chr)->GetInstanceId() !=
                MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(), m_session->GetPlayer())->GetInstanceId()) )
            {
                // cannot summon from instance to instance
                PSendSysMessage(LANG_CANNOT_INST_INST);
                return true;
            }

            // we are in instance, and can summon only player in our group with us as lead
            if ( !m_session->GetPlayer()->groupInfo.group || !chr->groupInfo.group ||
                (chr->groupInfo.group->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
                (m_session->GetPlayer()->groupInfo.group->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
                // the last check is a bit excessive, but let it be, just in case
            {
                PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
                return true;
            }
        }

        PSendSysMessage(LANG_SUMMONING, chr->GetName(),"");

        if (m_session->GetPlayer()->isVisibleFor(chr))
        {
            char buf0[256];
            snprintf((char*)buf0,256,LANG_SUMMONED_BY, m_session->GetPlayer()->GetName());

            WorldPacket data;
            FillSystemMessageData(&data, m_session, buf0);
            chr->GetSession()->SendPacket( &data );
        }

        chr->SetRecallPosition(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());

        // before GM
        float x,y,z;
        m_session->GetPlayer()->GetClosePoint(NULL,x,y,z,chr->GetObjectSize());
        chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
    }
    else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
    {
        PSendSysMessage(LANG_SUMMONING, name.c_str()," (offline)");

        // in point where GM stay
        Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
            m_session->GetPlayer()->GetPositionX(),
            m_session->GetPlayer()->GetPositionY(),
            m_session->GetPlayer()->GetPositionZ(),m_session->GetPlayer()->GetOrientation(),guid);
    }
    else
        PSendSysMessage(LANG_NO_PLAYER, args);

    return true;
}
Ejemplo n.º 15
0
void ChatHandler::SendSysMessage(WorldSession* session, const char *str)
{
    WorldPacket data;
    FillSystemMessageData(&data, session, str);
    session->SendPacket(&data);
}
Ejemplo n.º 16
0
bool ChatHandler::HandleAddWeaponCommand(const char* args)
{
    if (!*args)
        return false;

    WorldPacket data;

    uint64 guid = m_session->GetPlayer()->GetSelection();
    if (guid == 0)
    {
        FillSystemMessageData(&data, m_session, "No selection.");
        m_session->SendPacket( &data );
        return true;
    }

    Creature *pCreature = ObjectAccessor::Instance().GetCreature(*m_session->GetPlayer(), guid);

    if(!pCreature)
    {
        FillSystemMessageData(&data, m_session, "You should select a creature.");
        m_session->SendPacket( &data );
        return true;
    }

    char* pSlotID = strtok((char*)args, " ");
    if (!pSlotID)
        return false;

    char* pItemID = strtok(NULL, " ");
    if (!pItemID)
        return false;

    uint32 ItemID = atoi(pItemID);
    uint32 SlotID = atoi(pSlotID);

    ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID);

    bool added = false;
    std::stringstream sstext;
    if(tmpItem)
    {
        switch(SlotID)
        {
            case 1:
                pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID);
                added = true;
                break;
            case 2:
                pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID);
                added = true;
                break;
            case 3:
                pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID);
                added = true;
                break;
            default:
                sstext << "Item Slot '" << SlotID << "' doesn't exist." << '\0';
                added = false;
                break;
        }
        if(added)
        {
            sstext << "Item '" << ItemID << "' '" << tmpItem->Name1 << "' Added to Slot " << SlotID << '\0';
        }
    }
    else
    {
        sstext << "Item '" << ItemID << "' Not Found in Database." << '\0';
        return true;
    }
    FillSystemMessageData(&data, m_session, sstext.str().c_str());
    m_session->SendPacket( &data );
    return true;
}
Ejemplo n.º 17
0
bool ChatHandler::HandleNamegoCommand(const char* args)
{
    WorldPacket data;

    if(m_session->GetPlayer()->isInFlight())
    {
        SendSysMessage(LANG_YOU_IN_FLIGHT);
        return true;
    }

    if(!*args)
        return false;

    std::string name = args;
    normalizePlayerName(name);
    sDatabase.escape_string(name);                          // prevent SQL injection - normal name don't must changed by this call

    Player *chr = objmgr.GetPlayer(name.c_str());
    if (chr)
    {

        if(chr->IsBeingTeleported()==true)
        {
            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
            return true;
        }

        if(chr->isInFlight())
        {
            PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
            return true;
        }

        PSendSysMessage(LANG_SUMMONING, chr->GetName(),"");

        if (m_session->GetPlayer()->isVisibleFor(chr,false))
        {
            char buf0[256];
            snprintf((char*)buf0,256,LANG_SUMMONED_BY, m_session->GetPlayer()->GetName());
            FillSystemMessageData(&data, m_session, buf0);
            chr->GetSession()->SendPacket( &data );
        }

        chr->TeleportTo(m_session->GetPlayer()->GetMapId(),
            m_session->GetPlayer()->GetPositionX(),
            m_session->GetPlayer()->GetPositionY(),
            m_session->GetPlayer()->GetPositionZ(),
            chr->GetOrientation());
    }
    else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()))
    {
        PSendSysMessage(LANG_SUMMONING, name.c_str()," (offline)");

        Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
            m_session->GetPlayer()->GetPositionX(),
            m_session->GetPlayer()->GetPositionY(),
            m_session->GetPlayer()->GetPositionZ(),m_session->GetPlayer()->GetOrientation(),guid);
    }
    else
        PSendSysMessage(LANG_NO_PLAYER, args);

    return true;
}
Ejemplo n.º 18
0
bool ChatHandler::HandleGonameCommand(const char* args)
{
    Player* _player = m_session->GetPlayer();

    if(_player->isInFlight())
    {
        SendSysMessage(LANG_YOU_IN_FLIGHT);
        return true;
    }

    if(!*args)
        return false;

    std::string name = args;
    normalizePlayerName(name);
    //sDatabase.escape_string(name);                          // prevent SQL injection - normal name don't must changed by this call

    Player *chr = objmgr.GetPlayer(name.c_str());
    if (chr)
    {
        if (MapManager::Instance().GetMap(chr->GetMapId(), chr)->Instanceable())
        {
            if ( (MapManager::Instance().GetMap(_player->GetMapId(), _player)->Instanceable()) &&
                (MapManager::Instance().GetMap(chr->GetMapId(), chr)->GetInstanceId() !=
                MapManager::Instance().GetMap(_player->GetMapId(), _player)->GetInstanceId()) )
            {
                // cannot go from instance to instance
                PSendSysMessage(LANG_CANNOT_INST_INST);
                return true;
            }

            // we have to go to instance, and can go to player only if:
            //   1) we are in his group (either as leader or as member)
            //   2) we are not bound to any group and have GM mode on
            if (_player->groupInfo.group)
            {
                // we are in group, we can go only if we are in the player group
                if (_player->groupInfo.group != chr->groupInfo.group)
                {
                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName());
                    return true;
                }
            }
            else
            {
                // we are not in group, let's verify our GM mode
                if (!_player->isGameMaster())
                {
                    PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName());
                    return true;
                }
            }

            // bind us to the players instance
            BoundInstancesMap::iterator i = chr->m_BoundInstances.find(chr->GetMapId());
                                                            // error, the player has no instance bound!!!
            if (i == chr->m_BoundInstances.end()) return true;
            _player->m_BoundInstances[chr->GetMapId()] = std::pair < uint32, uint32 >(i->second.first, i->second.second);
            _player->SetInstanceId(chr->GetInstanceId());
        }

        PSendSysMessage(LANG_APPEARING_AT, chr->GetName());

        if (_player->isVisibleFor(chr))
        {
            char buf0[256];
            sprintf((char*)buf0,LANG_APPEARING_TO, _player->GetName());

            WorldPacket data;
            FillSystemMessageData(&data, m_session, buf0);
            chr->GetSession()->SendPacket(&data);
        }

        _player->SetRecallPosition(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());

        // to point to see at target with same orientation
        float x,y,z;
        chr->GetContactPoint(m_session->GetPlayer(),x,y,z);

        _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), true, true, true);
        return true;
    }

    if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
    {
        PSendSysMessage(LANG_APPEARING_AT, name.c_str());

        // to point where player stay (if loaded)
        float x,y,z,o;
        uint32 map;
        if(Player::LoadPositionFromDB(map,x,y,z,o,guid))
        {
            _player->SetRecallPosition(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
            _player->TeleportTo(map, x, y, z,_player->GetOrientation());
            return true;
        }
    }

    PSendSysMessage(LANG_NO_PLAYER, args);

    return true;
}
Ejemplo n.º 19
0
bool ChatHandler::HandleModifyGoldCommand(const char* args)
{
    WorldPacket data;

    if (!*args)
        return false;

    int32 gold = atoi((char*)args);

    Player *chr = getSelectedPlayer();
    if (chr == NULL)
    {
        SendSysMessage(LANG_NO_CHAR_SELECTED);
        return true;
    }

    uint32 moneyuser = m_session->GetPlayer()->GetMoney();

    if(gold < 0)
    {
        int32 newmoney = moneyuser + gold;

        sLog.outDetail(LANG_CURRENT_MONEY, moneyuser, gold, newmoney);
        if(newmoney < 0 )
        {

            PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName());

            char buf[256];
            sprintf((char*)buf,LANG_YOURS_ALL_MONEY_GONE, m_session->GetPlayer()->GetName());
            FillSystemMessageData(&data, m_session, buf);
            chr->GetSession()->SendPacket(&data);

            chr->SetMoney(0);
        }
        else
        {

            PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(gold), chr->GetName());

            char buf[256];
            sprintf((char*)buf,LANG_YOURS_MONEY_TAKEN, m_session->GetPlayer()->GetName(), abs(gold));
            FillSystemMessageData(&data, m_session, buf);
            chr->GetSession()->SendPacket(&data);

            chr->SetMoney( newmoney );
        }
    }
    else
    {

        PSendSysMessage(LANG_YOU_GIVE_MONEY, gold, chr->GetName());

        char buf[256];
        sprintf((char*)buf,LANG_YOURS_MONEY_GIVEN, m_session->GetPlayer()->GetName(), gold);
        FillSystemMessageData(&data, m_session, buf);
        chr->GetSession()->SendPacket(&data);

        chr->ModifyMoney( gold );
    }

    sLog.outDetail(LANG_NEW_MONEY, moneyuser, gold, chr->GetMoney() );

    return true;
}
Ejemplo n.º 20
0
bool ChatHandler::HandleNameTeleCommand(const char * args)
{
    char* pName = strtok((char*)args, " ");
    char* loc = strtok(NULL, "");

    if(!pName || !loc)
        return false;

    std::string name = pName;
    std::string location = loc;

    normalizePlayerName(name);
    sDatabase.escape_string(name);

    QueryResult *result = sDatabase.PQuery("SELECT `position_x`,`position_y`,`position_z`,`orientation`,`map` FROM `game_tele` WHERE `name` = '%s'",location.c_str());
    if (!result)
    {
        SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
        return true;
    }

    Field *fields = result->Fetch();
    float x = fields[0].GetFloat();
    float y = fields[1].GetFloat();
    float z = fields[2].GetFloat();
    float ort = fields[3].GetFloat();
    int mapid = fields[4].GetUInt16();
    delete result;

    if(!MapManager::IsValidMapCoord(mapid,x,y))
    {
        PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
        return true;
    }

    Player *chr = objmgr.GetPlayer(name.c_str());
    if (chr)
    {

        if(chr->IsBeingTeleported()==true)
        {
            PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
            return true;
        }

        if(chr->isInFlight())
        {
            PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
            return true;
        }

        PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", location.c_str());

        if (m_session->GetPlayer()->isVisibleFor(chr))
        {
            WorldPacket data;
            char buf0[256];
            snprintf((char*)buf0,256,LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName());
            FillSystemMessageData(&data, m_session, buf0);
            chr->GetSession()->SendPacket( &data );
        }

        chr->SetRecallPosition(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());

        chr->TeleportTo(mapid,x,y,z,chr->GetOrientation());
    }
    else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()))
    {
        PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), LANG_OFFLINE, location.c_str());
        Player::SavePositionInDB(mapid,x,y,z,ort,guid);
    }
    else
        PSendSysMessage(LANG_NO_PLAYER, name.c_str());

    return true;
}