Example #1
0
bool ChatHandler::HandleWPDeleteCommand(const char* args, WorldSession *m_session)
{
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
	{
		SystemMessage(m_session, "You should select a Waypoint.");
		return true;
	}

	Player* pPlayer = m_session->GetPlayer();
	AIInterface* ai = pPlayer->waypointunit;
	if(!ai || !ai->GetUnit())
	{
		SystemMessage(m_session, "Invalid Creature, please select another one.");
		return true;
	}
	std::stringstream ss;

	uint32 wpid = GUID_LOPART(guid);
	if(wpid)
	{
		//Refresh client
		//Hide all
		bool show = ai->m_WayPointsShowing;
		if(show == true)
			ai->hideWayPoints(pPlayer);

		ai->deleteWayPoint(wpid);
		//Show All again after delete
		if(show == true)
			ai->showWayPoints(pPlayer,ai->m_WayPointsShowBackwards);

		SystemMessage(m_session, "Waypoint %u deleted.", wpid);
	}
	else
	{
		SystemMessage(m_session, "Invalid Waypoint.");
		return true;
	}
	return true;
}
Example #2
0
bool ChatHandler::HandleWPMoveTypeCommand(const char* args, WorldSession *m_session)
{
	if(!*args)
		return false;

	uint32 option = atoi((char*)args);

	if (option != 0 && option != 1 && option != 2)
	{
		std::stringstream ss;
		ss << "Incorrect value." << endl;
		ss << "0 is Move from WP 1 ->  10 then 10 -> 1." << endl;
		ss << "1 is Move from WP to a random WP." << endl;
		ss << "2 is Move from WP 1 -> 10 then 1 -> 10." << endl;
		SendMultilineMessage(m_session, ss.str().c_str());
		return true;
	}

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

	Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!pCreature)
	{
		SystemMessage(m_session, "You should select a creature.");
		return true;
	}

	if( pCreature->m_spawn == NULL )
	{
		SystemMessage(m_session, "You cannot add waypoints to a creature that is not saved.");
		return true;
	}

	char sql[512];
	snprintf(sql, 512, "UPDATE creature_spawns SET movetype = '%u' WHERE id = '%u'", (unsigned int)option, (unsigned int)pCreature-> GetSQL_id());
	WorldDatabase.Execute( sql );

	pCreature->GetAIInterface()->setMoveType(option);

	SystemMessage(m_session, "Value saved to database.");
	return true;
}
Example #3
0
void WorldSession::HandleArenaTeamPromoteOpcode(WorldPacket & recv_data) 
{
	uint32 teamId;
	uint8 slot;
	string name;
	ArenaTeam * team;
	PlayerInfo * inf;
	recv_data >> teamId >> name;

	team = objmgr.GetArenaTeamById(teamId);
	if(!team)
	{
		GetPlayer()->SoftDisconnect();
		return;
	}

	slot = team->m_type;

	if( slot >= NUM_ARENA_TEAM_TYPES )
		return;

	if( (team = _player->m_playerInfo->arenaTeam[slot]) == NULL )
	{
		SystemMessage("You are not in an arena team of this type.");
		return;
	}

	if(team->m_leader != _player->GetLowGUID())
	{
		SystemMessage("You aren't the captain of this team.");
		return;
	}

	if( (inf = objmgr.GetPlayerInfoByName(name.c_str())) == NULL )
	{
		SystemMessage("That player cannot be found.");
		return;
	}

	if(!team->HasMember(inf->guid))
	{
		SystemMessage("That player is not a member of your arena team.");
		return;
	}

	team->SetLeader(inf);
}
Example #4
0
bool ChatHandler::HandleWaypointBackwardTextCommand(const char* args, WorldSession *m_session)
{
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
	{
		SystemMessage(m_session, "You should select a Waypoint.");
		return true;
	}

	Player* pPlayer = m_session->GetPlayer();
	AIInterface* ai = pPlayer->waypointunit;
	if(!ai || !ai->GetUnit())
	{
		SystemMessage(m_session, "Invalid Creature, please select another one.");
		return true;
	}
	std::stringstream ss;

	uint32 wpid = GUID_LOPART(guid);
	if(wpid)
	{
		WayPoint* wp = ai->getWayPoint(wpid);
		if(wp)
		{
			char pAnnounce[1024];
			snprintf(pAnnounce, 1024, "%s", args);

			wp->backwardSayText = string(pAnnounce);
			ss << "Backward SayText for Waypoint " << wpid << " is now " << string(pAnnounce);
			//save wp
			ai->saveWayPoints();
		}

		SystemMessage(m_session,  ss.str().c_str());
	}	else
	{
		SystemMessage(m_session, "Invalid Waypoint.");
		return true;
	}
	return true;
}
Example #5
0
void WorldSession::HandleArenaTeamInviteAcceptOpcode(WorldPacket & recv_data)
{
	CHECK_INWORLD_RETURN

	ArenaTeam* team;

	if(_player->m_arenateaminviteguid == 0)
	{
		SystemMessage("You have not been invited into another arena team.");
		return;
	}

	team = objmgr.GetArenaTeamById(_player->m_arenateaminviteguid);
	_player->m_arenateaminviteguid = 0;
	if(team == 0)
	{
		SystemMessage("That arena team no longer exists.");
		return;
	}

	if(team->m_memberCount >= team->m_slots)
	{
		SystemMessage("That team is now full.");
		return;
	}

	if(_player->m_arenaTeams[team->m_type] != NULL)		/* shouldn't happen */
	{
		SystemMessage("You have already been in an arena team of that size.");
		return;
	}

	if(team->AddMember(_player->m_playerInfo))
	{
		char buffer[1024];
		WorldPacket* data;
		snprintf(buffer, 1024, "%s joined the arena team, '%s'.", _player->GetName(), team->m_name.c_str());
		data = sChatHandler.FillSystemMessageData(buffer);
		team->SendPacket(data);
		delete data;
	}
	else
	{
		SendNotification("Internal error.");
	}
}
Example #6
0
bool ChatHandler::HandleItemRemoveCommand(const char* args, WorldSession *m_session)
{
    if (!args)
        return false;

    Creature* pCreature = getSelectedCreature(m_session, false);
    if(!pCreature || !(pCreature->HasNpcFlag(UNIT_NPC_FLAG_VENDOR) || pCreature->HasNpcFlag(UNIT_NPC_FLAG_ARMORER)))
    {
        SystemMessage(m_session, "You should select a vendor.");
        return true;
    }

    uint32 itemguid = 0;
    if(sscanf(args, "%u", &itemguid) < 1)
    {
        // check for item link
        GetItemIDFromLink(args, &itemguid);
        if(itemguid == 0)
            return false;
    }
    if(itemguid == 0)
        return false;

    std::stringstream sstext;
    int slot = pCreature->GetSlotByItemId(itemguid);
    if(slot != -1)
    {
        std::stringstream ss;
        ss << "DELETE FROM vendors WHERE entry = '" << pCreature->GetEntry() << "' AND vendormask = '" << pCreature->VendorMask << "' AND item = " << itemguid << " LIMIT 1;";
        WorldDatabase.Execute( ss.str().c_str() );

        pCreature->RemoveVendorItem(itemguid);
        ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(itemguid);
        if(tmpItem)
            sstext << "Item '" << itemguid << "' '" << tmpItem->Name1 << "' Deleted from list" << '\0';
        else
            sstext << "Item '" << itemguid << "' Deleted from list" << '\0';
    }
    else
    {
        sstext << "Item '" << itemguid << "' Not Found in List." << '\0';
    }

    SystemMessage(m_session, sstext.str().c_str());
    return true;
}
Example #7
0
bool ChatHandler::HandleItemCommand(const char* args, WorldSession *m_session)
{
    if(strlen(args) < 1)
        return false;

    Creature* pCreature = getSelectedCreature(m_session, false);
    if(!pCreature || !pCreature->m_spawn || !(pCreature->HasNpcFlag(UNIT_NPC_FLAG_VENDOR) || pCreature->HasNpcFlag(UNIT_NPC_FLAG_ARMORER)))
    {
        SystemMessage(m_session, "You should select a vendor.");
        return true;
    }

    int amount = 1;
    uint32 item = 0, extendedcost = 0, vendormask = 0;
    if(sscanf(args, "%u %u %u %u", &item, &amount, &extendedcost, &vendormask) < 1)
    {
        // check for item link
        GetItemIDFromLink(args, &item);
        if(item == 0)
            return false;
    }
    if(item == 0)
        return false;

    if(vendormask == 0)
        vendormask = pCreature->m_spawn->vendormask;

    ItemPrototype* tmpItem = ItemPrototypeStorage.LookupEntry(item);
    std::stringstream sstext;
    if(tmpItem)
    {
        std::stringstream ss;
        ss << "INSERT INTO vendors(entry, item, amount, extendedcost, vendormask) VALUES ('" << pCreature->GetEntry() << "', '" << item << "', '" << amount << "', " << extendedcost << ", " << vendormask << " );";
        WorldDatabase.Execute( ss.str().c_str() );

        pCreature->AddVendorItem(item, amount, vendormask, extendedcost);

        sstext << "Item '" << item << "' '" << tmpItem->Name1 << "' Added to list" << '\0';
    }
    else
        sstext << "Item '" << item << "' Not Found in Database." << '\0';

    sWorld.LogGM(m_session, "added item %u to vendor %u", item, pCreature->GetEntry());
    SystemMessage(m_session,  sstext.str().c_str());
    return true;
}
Example #8
0
bool ChatHandler::HandleVendorClearCommand(const char* args, WorldSession *m_session)
{
    uint64 guid = m_session->GetPlayer()->GetSelection();
    if(guid == 0)
    {
        SystemMessage(m_session, "No selection.");
        return true;
    }

    Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
    if(!pCreature)
    {
        SystemMessage(m_session, "You should select a creature.");
        return true;
    }

    if(!pCreature->m_spawn)
    {
        SystemMessage(m_session, "You should select a saved creature.");
        return true;
    }

    bool first = true;
    QueryBuffer* qb = new QueryBuffer();
    std::map<uint32, CreatureItem>::iterator itr, itr2, begin = pCreature->GetSellItemBegin(), end = pCreature->GetSellItemEnd();
    for(itr = begin; itr != end;)
    {
        itr2 = itr++;
        if(itr2->second.vendormask < 0 || pCreature->VendorMask < 0 || itr2->second.vendormask == pCreature->VendorMask)
        {
            first = false;
            qb->AddQuery("DELETE FROM vendors WHERE entry = '%u' AND vendormask = '%i' AND item = '%u';", pCreature->GetEntry(), pCreature->VendorMask, itr2->second.itemid);
            pCreature->RemoveSellItem(itr2);
        }
    }

    if(!first)
    {
        WorldDatabase.AddQueryBuffer(qb);
        SystemMessage(m_session, "removed all items with vendor mask %u", pCreature->VendorMask);
        sWorld.LogGM(m_session, "removed all items with vendor mask %u from vendor %u", pCreature->VendorMask, pCreature->GetEntry());
    }
    else
        RedSystemMessage(m_session, "No items found");
    return true;
}
bool ChatHandler::HandleWaypointSetOrientationCommand(const char* args, WorldSession *m_session)
{
    uint64 guid = m_session->GetPlayer()->GetSelection();
    if (guid == 0)
    {
        SystemMessage(m_session, "No selection.");
        return true;
    }

    if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
    {
        SystemMessage(m_session, "You should select a Waypoint.");
        return true;
    }

    Player* pPlayer = m_session->GetPlayer();
    AIInterface* ai = pPlayer->waypointunit;
    if(!ai || !ai->GetUnit())
    {
        SystemMessage(m_session, "Invalid Creature, please select another one.");
        return true;
    }

    bool showing = ai->WayPointsShowing();
    uint32 wpid = GUID_LOPART(guid);
    if(wpid)
    {
        WayPoint* wp = ai->getWayPoint(wpid);
        if(wp)
        {
            if(showing)
                ai->hideWayPoints(pPlayer);

            wp->orientation = pPlayer->GetOrientation();
            //save wp
            ai->saveWayPoints();
        }
        else return false;
    }
    else return false;

    if(showing)
        ai->showWayPoints(pPlayer, ai->WayPointsShowingBackwards());
    return true;
}
Example #10
0
void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recv_data)
{
	CHECK_INWORLD_RETURN

	ArenaTeam* team;
	uint32 teamId;
	recv_data >> teamId;

	team = objmgr.GetArenaTeamById(teamId);

	if(!team)
	{
		GetPlayer()->SoftDisconnect();
		return;
	}

	if((team = _player->m_arenaTeams[team->m_type]) == NULL)
	{
		SystemMessage("You are not in an arena team of this type.");
		return;
	}

	if(team->m_leader == _player->GetLowGUID() && team->m_memberCount == 1)
	{
		team->Destroy();
		return;
	}

	if(team->m_leader == _player->GetLowGUID())
	{
		SystemMessage("You cannot leave the team yet, promote someone else to captain first.");
		return;
	}

	if(team->RemoveMember(_player->m_playerInfo))
	{
		char buffer[1024];
		WorldPacket* data;
		snprintf(buffer, 1024, "%s left the arena team, '%s'.", _player->GetName(), team->m_name.c_str());
		data = sChatHandler.FillSystemMessageData(buffer);
		team->SendPacket(data);
		delete data;
		SystemMessage("You have left the arena team, '%s'.", team->m_name.c_str());
	}
}
Example #11
0
bool ChatHandler::HandleWaypointGettextCommand(const char* args, WorldSession *m_session)
{ 
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	if(GET_TYPE_FROM_GUID(guid) != HIGHGUID_TYPE_WAYPOINT)
	{
		SystemMessage(m_session, "You should select a Waypoint.");
		return true;
	}

	Player* pPlayer = m_session->GetPlayer();
	AIInterface* ai = pPlayer->waypointunit;
	if(!ai || !ai->GetUnit())
	{
		SystemMessage(m_session, "Invalid Creature, please select another one.");
		return true;
	}
	std::stringstream ss;

	uint32 wpid = GUID_LOPART(guid);
	if((wpid > 0) && (wpid <= ai->GetWayPointsCount()))
	{
		WayPoint* wp = ai->getWayPoint(wpid);
		if(wp)
		{
			ss << "Waypoint Number " << wp->id << ":\n";
			ss << "Backward:\n";
			ss << wp->backwardSayText << "\n";
			ss << "Forward:\n";
			ss << wp->forwardSayText << "\n";
			SendMultilineMessage(m_session, ss.str().c_str());
		}
	}
	else
	{
	   SystemMessage(m_session,  "Invalid Waypoint.");
		return true;
	}
	return true;
}
Example #12
0
bool ChatHandler::HandleWPHideCommand(const char* args, WorldSession *m_session)
{
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!pCreature)
	{
		SystemMessage(m_session, "You should select a Creature.");
		return true;
	}

	if( pCreature->m_spawn == NULL )
	{
		SystemMessage(m_session, "You cannot add waypoints to a creature that is not saved.");
		return true;
	}

	AIInterface* ai = pCreature->GetAIInterface();
	Player* pPlayer = m_session->GetPlayer();


	if(pPlayer->waypointunit == ai)
	{
		if(ai->m_WayPointsShowing == true)
			pPlayer->waypointunit->hideWayPoints(pPlayer);
			
		pPlayer->waypointunit = NULL;
	}
	else
	{
		SystemMessage(m_session, "Waypoints for that Unit are not Visible.");
		return true;
	}

	std::stringstream ss;
	ss << "Hiding Waypoints for " << pCreature->GetSQL_id();
	SystemMessage(m_session, ss.str().c_str());

	return true;
}
Example #13
0
void ChatHandler::SystemMessageToPlr(Player *plr, const char* message, ...)
{
	if( !message || !plr->GetSession() ) return;
	va_list ap;
	va_start(ap, message);
	char msg1[1024];
	vsnprintf(msg1,1024,message,ap);
	SystemMessage(plr->GetSession(), msg1);
}
Example #14
0
bool ChatHandler::HandleAddInvItemCommand(const char* args, WorldSession* m_session)
{
	uint32 itemid, count = 1;
	int32 randomprop = 0;
	int32 numadded = 0;

	if(strlen(args) < 1)
		return false;

	if(sscanf(args, "%u %u %d", &itemid, &count, &randomprop) < 1)
	{
		// check for item link
		uint16 ofs = GetItemIDFromLink(args, &itemid);
		if(!itemid)
			return false;

		sscanf(args + ofs, "%u %d", &count, &randomprop); // these may be empty
	}

	Player* chr = getSelectedChar(m_session, false);
	if(!chr)
		chr = m_session->GetPlayer();

	ItemPrototype* it = ItemPrototypeStorage.LookupEntry(itemid);
	if(it)
	{
		numadded -= chr->GetItemInterface()->GetItemCount(itemid);
		bool result = false;
		result = chr->GetItemInterface()->AddItemById(itemid, count, randomprop);
		numadded += chr->GetItemInterface()->GetItemCount(itemid);
		if(result == true)
		{
			if(count == 0)
				sGMLog.writefromsession(m_session, "used add item command, item id %u [%s], quantity %u, to %s", it->ItemId, it->Name1, numadded, chr->GetName());
			else
				sGMLog.writefromsession(m_session, "used add item command, item id %u [%s], quantity %u (only %lu added due to full inventory), to %s", it->ItemId, it->Name1, numadded, numadded, chr->GetName());

			char messagetext[512];

			snprintf(messagetext, 512, "Added item %s (id: %d), quantity %u, to %s's inventory.", GetItemLinkByProto(it, m_session->language).c_str(), (unsigned int)it->ItemId, numadded, chr->GetName());
			SystemMessage(m_session, messagetext);
			//snprintf(messagetext, 128, "%s added item %d (%s) to your inventory.", m_session->GetPlayer()->GetName(), (unsigned int)itemid, it->Name1);
			snprintf(messagetext, 512, "%s added item %s, quantity %u, to your inventory.", m_session->GetPlayer()->GetName(), GetItemLinkByProto(it, chr->GetSession()->language).c_str(), numadded);

			SystemMessageToPlr(chr,  messagetext);
		}
		else
			SystemMessageToPlr(chr, "Failed to add item.");

		return true;
	}
	else
	{
		RedSystemMessage(m_session, "Item %d is not a valid item!", itemid);
		return false;
	}
}
Example #15
0
bool ChatHandler::HandleWPShowCommand(const char* args, WorldSession *m_session)
{
	uint64 guid = m_session->GetPlayer()->GetSelection();
	if (guid == 0)
	{
		SystemMessage(m_session, "No selection.");
		return true;
	}

	Creature* pCreature = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
	if(!pCreature)
	{
		SystemMessage(m_session, "You should select a Creature.");
		return true;
	}

	if( pCreature->m_spawn == NULL )
	{
		SystemMessage(m_session, "You cannot add waypoints to a creature that is not saved.");
		return true;
	}

	char* pBackwards = strtok((char*)args, " ");
	bool Backwards = (pBackwards)? ((atoi(pBackwards)>0)?true:false) : false;

	AIInterface* ai = pCreature->GetAIInterface();
	Player* pPlayer = m_session->GetPlayer();


	if(pPlayer->waypointunit != ai)
	{
		if(ai->m_WayPointsShowing == true) 
		{
			SystemMessage(m_session, "Some one else is also Viewing this Creatures WayPoints.");
			SystemMessage(m_session, "Viewing WayPoints at the same time as some one else can cause undesireble results.");
			return true;
		}

		if(pPlayer->waypointunit != NULL)
		{
			pPlayer->waypointunit->hideWayPoints(pPlayer);
		}
		pPlayer->waypointunit = ai;
		ai->showWayPoints(pPlayer,Backwards);
		ai->m_WayPointsShowBackwards = Backwards;
	}
	else
	{
		if(ai->m_WayPointsShowing == true) 
		{
			SystemMessage(m_session, "Waypoints Already Showing.");
		}
		else
			ai->showWayPoints(m_session->GetPlayer(),Backwards);
	}

	SystemMessage(m_session, "Showing waypoints for creature %u", pCreature->GetSQL_id());
	return true;
}
Example #16
0
//.event list
bool ChatHandler::HandleEventListEvents(const char* /*args*/, WorldSession* m_session)
{
    SystemMessage(m_session, "--- Current Active Events ---");
    auto eventList = sGameEventMgr.mGameEvents;
    for (auto gameEventPair : eventList)
    {
        auto gameEvent = gameEventPair.second;
        if (gameEvent->GetState() == GAMEEVENT_ACTIVE)
        {
            SystemMessage(m_session, "%u - %s", gameEvent->event_id, gameEvent->description.c_str());
        }
        else if (gameEvent->GetState() == GAMEEVENT_ACTIVE_FORCED)
        {
            SystemMessage(m_session, "[Force Activated] %u - %s", gameEvent->event_id, gameEvent->description.c_str());
        }
    }
    SystemMessage(m_session, "--- End List ---");
    return true;
}
/*---------------------------------------------------------------------------*\
 * NAME: HandleDefaultLaunchOption                                           *
 * --------------------------------------------------------------------------*
 * DESCRIPTION: 
\*---------------------------------------------------------------------------*/
void Error (
    LPTSTR tszErrorMessage,
    DWORD dwErrorCode
    )
{
    TCHAR tszMessageBuffer [SIZE_MSG_BUFFER] = {0};

    _tprintf (_T("%s\n%s"), tszErrorMessage, SystemMessage (tszMessageBuffer,  RTL_NUMBER_OF(tszMessageBuffer), dwErrorCode));
    exit (0);
}
Example #18
0
bool ChatHandler::HandleBattlegroundExitCommand(const char* args, WorldSession* m_session)
{
	if(!m_session->GetPlayer()->m_bg)
	{
		SystemMessage(m_session,"You're not in a battleground!");
		return true;
	}
	m_session->GetPlayer()->m_bg->Close();
	return true;
}
Example #19
0
bool ChatHandler::HandlePlaySoundCommand(const char* args, WorldSession *m_session)
{
	if(!m_session->GetPlayer()->m_bg)
	{
		SystemMessage(m_session,"You're not in a battleground!");
		return true;
	}
	m_session->GetPlayer()->m_bg->PlaySoundToAll(atoi(args));
	return true;
}
Example #20
0
bool ChatHandler::CreateGuildCommand(const char* args, WorldSession *m_session)
{
    if(!*args)
        return false;

    Player* ptarget = getSelectedChar(m_session);
    if(ptarget == NULL)
        return true;

    if(strlen((char*)args)>75)
    {
        // send message to user
        char buf[256];
        snprintf((char*)buf,256,"The name was too long by %i", (unsigned int)strlen((char*)args)-75);
        SystemMessage(m_session, buf);
        return true;
    }

    for (uint32 i = 0; i < strlen(args); i++)
    {
        if(!isalpha(args[i]) && args[i]!=' ')
        {
            SystemMessage(m_session, "Error, name can only contain chars A-Z and a-z.");
            return true;
        }
    }

    GuildInfo* pGuild = guildmgr.GetGuildByGuildName(string(args));
    if(pGuild)
    {
        RedSystemMessage(m_session, "Guild name is already taken.");
        return true;
    }

    Charter tempCharter(0, ptarget->GetLowGUID(), CHARTER_TYPE_GUILD);
    tempCharter.SignatureCount = 0;
    tempCharter.GuildName = string(args);

    guildmgr.CreateGuildFromCharter(&tempCharter);
    SystemMessage(m_session, "Guild created");
    return true;
}
Example #21
0
bool ChatHandler::HandleAppearCommand(const char* args, WorldSession *m_session)
{
    if (!*args)
        return false;

    Player *chr = objmgr.GetPlayer(args, false);
    if (chr)
    {
        char buf[256];
        if (chr->IsBeingTeleported())
        {
            snprintf((char*)buf, 256, "%s is already being teleported.", chr->GetName());
            SystemMessage(m_session, buf);
            return true;
        }
        snprintf((char*)buf, 256, "Appearing at %s's location.", chr->GetName());  // -- europa
        SystemMessage(m_session, buf);

        if (!m_session->GetPlayer()->m_isGmInvisible)
        {
            char buf0[256];
            snprintf((char*)buf0, 256, "%s is appearing to your location.", m_session->GetPlayer()->GetName());
            SystemMessageToPlr(chr, buf0);
        }

        //m_session->GetPlayer()->SafeTeleport(chr->GetMapId(), chr->GetInstanceID(), chr->GetPosition());
        //If the GM is on the same map as the player, use the normal safeteleport method
        if (m_session->GetPlayer()->GetMapId() == chr->GetMapId() && m_session->GetPlayer()->GetInstanceID() == chr->GetInstanceID())
            m_session->GetPlayer()->SafeTeleport(chr->GetMapId(), chr->GetInstanceID(), chr->GetPosition());
        else
            m_session->GetPlayer()->SafeTeleport(chr->GetMapMgr(), chr->GetPosition());
        //The player and GM are not on the same map. We use this method so we can port to BG's (Above method doesn't support them)
    }
    else
    {
        char buf[256];
        snprintf((char*)buf, 256, "Player (%s) does not exist or is not logged in.", args);
        SystemMessage(m_session, buf);
    }

    return true;
}
Example #22
0
//.gm list
bool ChatHandler::HandleGMListCommand(const char* /*args*/, WorldSession* m_session)
{
    bool print_headline = true;

    bool is_gamemaster = m_session->GetPermissionCount() != 0;

    objmgr._playerslock.AcquireReadLock();
    for (PlayerStorageMap::const_iterator itr = objmgr._players.begin(); itr != objmgr._players.end(); ++itr)
    {
        if (itr->second->GetSession()->GetPermissionCount())
        {
            if (!worldConfig.gm.listOnlyActiveGms)
            {
                if (print_headline)
                    GreenSystemMessage(m_session, "The following GMs are on this server:");

                if (worldConfig.gm.hidePermissions && !is_gamemaster)
                    SystemMessage(m_session, " - %s", itr->second->GetName());
                else
                    SystemMessage(m_session, " - %s [%s]", itr->second->GetName(), itr->second->GetSession()->GetPermissions());

                print_headline = false;
            }
            else if (worldConfig.gm.listOnlyActiveGms && itr->second->isGMFlagSet())
            {
                if (itr->second->isGMFlagSet())
                {
                    if (print_headline)
                        GreenSystemMessage(m_session, "The following GMs are active on this server:");

                    if (worldConfig.gm.hidePermissions && !is_gamemaster)
                        SystemMessage(m_session, " - %s", itr->second->GetName());
                    else
                        SystemMessage(m_session, " - %s [%s]", itr->second->GetName(), itr->second->GetSession()->GetPermissions());

                    print_headline = false;
                }
                else
                {
                    SystemMessage(m_session, "No GMs are currently logged in on this server.");
                    print_headline = false;
                }
            }
        }
    }
    objmgr._playerslock.ReleaseReadLock();

    if (print_headline)
    {
        if (!worldConfig.gm.listOnlyActiveGms)
            SystemMessage(m_session, "No GMs are currently logged in on this server.");
        else
            SystemMessage(m_session, "No GMs are currently active on this server.");
    }

    return true;
}
Example #23
0
bool ChatHandler::HandleGenderChanger(const char* args, WorldSession* m_session)
{
	uint8 gender;
	Player* target = objmgr.GetPlayer((uint32)m_session->GetPlayer()->GetSelection());
	if(!target)
	{
		SystemMessage(m_session, "Select a player first.");
		return false;
	}
	uint32 displayId = target->GetNativeDisplayId();
	if(!*args)
		gender = target->getGender() == 1 ? 0 : 1;
	else
	{
		gender = (uint8)atoi((char*)args);
		if(gender > 1)
			gender = 1;
	}

	if(gender == target->getGender())
	{
		SystemMessage(m_session, "%s's gender is already set to %s(%u).", target->GetName(), gender ? "Female" : "Male", gender);
		return false;
	}

	target->setGender(gender);

	if(!target->getGender())
	{
		target->SetDisplayId((target->getRace() == RACE_BLOODELF) ? ++displayId : --displayId);
		target->SetNativeDisplayId(displayId);
	}
	else
	{
		target->SetDisplayId((target->getRace() == RACE_BLOODELF) ? --displayId : ++displayId);
		target->SetNativeDisplayId(displayId);
	}

	target->EventModelChange();
	SystemMessage(m_session, "Set %s's gender to %s(%u).", target->GetName(), gender ? "Female" : "Male", gender);
	return true;
}
Example #24
0
bool ChatHandler::HandleAuraUpdateRemove(const char* args, WorldSession* m_session)
{
    if (!args)
        return false;

    char* pArgs = strtok((char*)args, " ");
    if (!pArgs)
        return false;
    uint8 VisualSlot = (uint8)atoi(pArgs);
    Player* Pl = m_session->GetPlayer();
    Aura* AuraPtr = Pl->FindAura(Pl->m_auravisuals[VisualSlot]);
    if (!AuraPtr)
    {
        SystemMessage(m_session, "No auraid found in slot %u", VisualSlot);
        return true;
    }
    SystemMessage(m_session, "SMSG_AURA_UPDATE (remove): VisualSlot %u - SpellID 0", VisualSlot);
    AuraPtr->Remove();
    return true;
}
Example #25
0
void
Error (
    LPTSTR ErrorMessage,
    DWORD ErrorCode
    )
{
    TCHAR messageBuffer [255];

    _tprintf (TEXT("%s\n%s"), ErrorMessage, SystemMessage (messageBuffer, ErrorCode));
    exit (0);
}
Example #26
0
void WorldSession::HandleArenaTeamRemoveMemberOpcode(WorldPacket & recv_data)
{
	ArenaTeam * team;
	uint8 slot;
	uint32 teamId;
	string name;
	PlayerInfo * inf;
	recv_data >> teamId >> name;

	team = objmgr.GetArenaTeamById(teamId);
	if(!team)
	{
		SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM);
		return;
	}

	slot = team->m_type;

	if( (team = _player->m_playerInfo->arenaTeam[slot]) == NULL )
	{
		SendNotInArenaTeamPacket(uint8(team->GetPlayersPerTeam()));
		return;
	}

	if(team->m_leader != _player->GetLowGUID())
	{
		SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PERMISSIONS);
		return;
	}

	if( (inf = objmgr.GetPlayerInfoByName(name.c_str())) == NULL )
	{
		SendArenaTeamCommandResult(ERR_ARENA_TEAM_INVITE_SS, "", name.c_str(), ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S);
		return;
	}

	if( inf->guid == team->m_leader )
	{
		SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_LEADER_LEAVE);
		return;
	}

	if(!team->HasMember(inf->guid))
	{
		SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, inf->name, team->m_name, ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM_SS);
		return;
	}

	if(team->RemoveMember(inf))
	{
		team->SendArenaTeamEventPacket(ERR_ARENA_TEAM_REMOVE, 3, inf->name, team->m_name, _player->GetName());
		SystemMessage("Removed %s from the arena team '%s'.", inf->name, team->m_name.c_str());
	}
}
Example #27
0
bool ChatHandler::HandleNPCFlagCommand(const char* args, WorldSession *m_session)
{
    if (!*args)
        return false;

    Creature* pCreature = getSelectedCreature(m_session, false);
    if(!pCreature)
    {
        SystemMessage(m_session, "You should select a creature.");
        return true;
    }

    uint32 npcFlags = (uint32) atoi((char*)args);
    pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags);
    pCreature->SaveToDB();
    WorldDatabase.Execute("UPDATE creature_proto SET npcflags = %u WHERE entry = %u", npcFlags, pCreature->GetEntry());

    SystemMessage(m_session, "Value saved, you may need to rejoin or clean your client cache.");
    return true;
}
Example #28
0
bool ChatHandler::HandleDeleteWaypoints(const char* args, WorldSession * m_session)
{
	Creature* cr = 
		m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection()));
	if(!cr)return false;
	if(!cr->GetSQL_id())
		return false;

	if(cr->GetAIInterface()->m_WayPointsShowing)
	{
		SystemMessage(m_session, "Waypoints are showing, hide them first.");
		return true;
	}
	
	WorldDatabase.Execute("DELETE FROM creature_waypoints WHERE spawnid=%u",cr->GetSQL_id());

	cr->GetAIInterface()->deleteWaypoints();
	SystemMessage(m_session, "Deleted waypoints for %u", cr->GetSQL_id());
	return true;
}
Example #29
0
bool ChatHandler::HandleStartBGCommand(const char *args, WorldSession *m_session)
{
	if(!m_session->GetPlayer()->m_bg)
	{
		SystemMessage(m_session,"You're not in a battleground!");
		return true;
	}
	m_session->GetPlayer()->m_bg->SendChatMessage( CHAT_MSG_BG_EVENT_NEUTRAL, 0, "The battle for %s has begun!", m_session->GetPlayer()->m_bg->GetName() );
	sEventMgr.RemoveEvents(m_session->GetPlayer()->m_bg, EVENT_BATTLEGROUND_COUNTDOWN);
	m_session->GetPlayer()->m_bg->Start();
	return true;
}
Example #30
0
DWORD CVfdShExt::DoVfdOpen(
	HWND			hParent)
{
	DWORD ret = VfdGuiOpen(hParent, m_nDevice);

	if (ret != ERROR_SUCCESS && ret != ERROR_CANCELLED) {
		MessageBox(hParent, SystemMessage(ret),
			VFD_MSGBOX_TITLE, MB_ICONSTOP);
	}

	return ret;
}