Пример #1
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;
	}
}
Пример #2
0
bool ChatHandler::HandleSummonCommand(const char* args, WorldSession *m_session)
{
    if (!*args)
        return false;

    sGMLog.writefromsession(m_session, "summoned %s on map %u, %f %f %f", args, m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ());

    Player *chr = objmgr.GetPlayer(args, false);
    if (chr)
    {
        // send message to user
        char buf[256];
        char buf0[256];
        if (chr->IsBeingTeleported() == true)
        {
            snprintf((char*)buf, 256, "%s is already being teleported.", chr->GetName());
            SystemMessage(m_session, buf);
            return true;
        }
        snprintf((char*)buf, 256, "You are summoning %s.", chr->GetName());
        SystemMessage(m_session, buf);

        if (!m_session->GetPlayer()->m_isGmInvisible)
        {
            // send message to player
            snprintf((char*)buf0, 256, "You are being summoned by %s.", m_session->GetPlayer()->GetName());
            SystemMessageToPlr(chr, buf0);
        }

        Player * plr = m_session->GetPlayer();

        if (plr->GetMapMgr() == chr->GetMapMgr())
            chr->_Relocate(plr->GetMapId(), plr->GetPosition(), false, false, plr->GetInstanceID());
        else
        {
            sEventMgr.AddEvent(chr, &Player::EventPortToGM, plr, 0, 1, 1, 0);
        }
    }
    else
    {
        PlayerInfo * pinfo = objmgr.GetPlayerInfoByName(args);
        if (!pinfo)
        {
            char buf[256];
            snprintf((char*)buf, 256, "Player (%s) does not exist.", args);
            SystemMessage(m_session, buf);
        }
        else
        {
            Player * pPlayer = m_session->GetPlayer();
            char query[512];
            snprintf((char*)&query, 512, "UPDATE characters SET mapId = %u, positionX = %f, positionY = %f, positionZ = %f, zoneId = %u WHERE guid = %u;", pPlayer->GetMapId(), pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetZoneId(), pinfo->guid);
            CharacterDatabase.Execute(query);
            char buf[256];
            snprintf((char*)buf, 256, "(Offline) %s has been summoned.", pinfo->name);
            SystemMessage(m_session, buf);
        }
    }
    return true;
}
Пример #3
0
bool ChatHandler::HandleAddInvItemCommand(const char *args, WorldSession *m_session)
{
	uint32 itemid, count=1;
	int32 randomprop=0;

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

	if(sscanf(args, "%u %u %d", &itemid, &count, &randomprop) < 1)
		return false;

	Player * chr = getSelectedChar( m_session, false );
	if ( chr == NULL )
		chr = m_session->GetPlayer();
	
	ItemPrototype* it = ItemPrototypeStorage.LookupEntry(itemid);
	if(it)
	{
		sGMLog.writefromsession(m_session, "used add item command, item id %u [%s] to %s", it->ItemId, it->Name1, chr->GetName());
		Item *item;
		item = objmgr.CreateItem( itemid, chr);
		item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, ((count > it->MaxCount) ? it->MaxCount : count));
		if(it->Bonding==ITEM_BIND_ON_PICKUP)
			item->SoulBind();
		if(randomprop!=0)
		{
			if(randomprop<0)
				item->SetRandomSuffix(abs(int(randomprop)));
			else
				item->SetRandomProperty(randomprop);

			item->ApplyRandomProperties(false);
		}
	  
		if(!chr->GetItemInterface()->AddItemToFreeSlot(item))
		{
			m_session->SendNotification("No free slots were found in your inventory!");
			item->DeleteMe();
			return true;
		}

		char messagetext[512];
		snprintf(messagetext, 512, "Adding item %s (id: %d) to %s's inventory.", GetItemLinkByProto(it, m_session->language).c_str(), (unsigned int)it->ItemId, 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 to your inventory.", m_session->GetPlayer()->GetName(), GetItemLinkByProto(it, chr->GetSession()->language).c_str());
		
		SystemMessageToPlr(chr,  messagetext);

		SlotResult *lr = chr->GetItemInterface()->LastSearchResult();
		chr->GetSession()->SendItemPushResult(item,false,true,false,true,lr->ContainerSlot,lr->Slot,count);

		return true;
	} else {
		RedSystemMessage(m_session, "Item %d is not a valid item!", itemid);
		return true;
	}
}
Пример #4
0
bool ChatHandler::HandleAppearCommand(const char* args, WorldSession *m_session)
{
	if(!*args)
		return false;

	Player *slf = m_session->GetPlayer();
	if(!slf) return true;
	Player *chr = objmgr.GetPlayer(args, false);
	if (chr && ( chr->m_isGmInvisible != INVIS_ADMIN || slf->RS_getAccess() == RS_ADMIN ) )
	{
		char buf[256];
		if( chr->IsBeingTeleported() ) 
		{
			snprintf((char*)buf,256, "%s is already being teleported.", chr->GetName());
			SystemMessage(m_session, buf);
			return true;
		}
		MapInfo * pMI = chr->GetMapMgr()->GetMapInfo();
		if(pMI && pMI->required_access > slf->RS_getAccess())
		{
			snprintf((char*)buf,256, "You do not have the required access level to go to this location.");
			SystemMessage(m_session, buf);
			return true;
		}
		if(chr->m_isGmInvisible && !slf->m_isGmInvisible)
		{
			SystemMessage(m_session, "Target unit is using GM Invis,");
			SystemMessage(m_session, "You need to turn on GM Invis to port to this player");
			return true;
		}

		snprintf((char*)buf,256, "Appearing at %s's location.", chr->GetName());	// -- europa
		SystemMessage(m_session, buf);
		if( slf->m_isGmInvisible == INVIS_NONE )
		{
			char buf0[256];
			snprintf((char*)buf0,256, "%s is appearing to your location.", slf->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 ( slf->GetMapId() == chr->GetMapId() && m_session->GetPlayer()->GetInstanceID() == chr->GetInstanceID() )
			slf->SafeTeleport(chr->GetMapId(),chr->GetInstanceID(),chr->GetPosition());
		else
			slf->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;
}
Пример #5
0
bool ChatHandler::HandleKickCommand(const char* args, WorldSession *m_session)
{

	if(!*args)
	return false;
	char *pname = strtok((char*)args, " ");
	if(!pname)
	{
		RedSystemMessage(m_session, "No name specified.");
		return true;
	}
	Player *chr = objmgr.GetPlayer((const char*)pname, false);
	if (chr)
	{
		char *reason = strtok(NULL, "\n");
		std::string kickreason = "No reason";
		if(reason)
			kickreason = reason;

		BlueSystemMessage(m_session, "Attempting to kick %s from the server for \"%s\".", chr->GetName(), kickreason.c_str());
		sGMLog.writefromsession(m_session, "Kicked player %s from the server for %s", chr->GetName(), kickreason.c_str());
		if(!m_session->CanUseCommand('z') && chr->GetSession()->CanUseCommand('z'))
		{
			RedSystemMessage(m_session, "You cannot kick %s, as they are a higher level gm than you.", chr->GetName());
			return true;
		}
		/*if(m_session->GetSecurity() < chr->GetSession()->GetSecurity())
		{
			SystemMessage(m_session, "You cannot kick %s, as he is a higher GM level than you.", chr->GetName());
			return true;
		}*/ // we might have to re-work this

		char msg[200];
		snprintf(msg, 200, "%sGM: %s was kicked from the server by %s. Reason: %s", MSG_COLOR_RED, chr->GetName(), m_session->GetPlayer()->GetName(), kickreason.c_str());
		sWorld.SendWorldText(msg, NULL);
		//sWorld.SendIRCMessage(msg);
		SystemMessageToPlr(chr, "You are being kicked from the server by %s. Reason: %s", m_session->GetPlayer()->GetName(), kickreason.c_str());
		
		WorldPacket data;
		data.Initialize(SMSG_FORCE_MOVE_ROOT);
		data << chr->GetNewGUID();
		data << uint32(1);
		chr->SendMessageToSet(&data, true);

		chr->Kick(6000);
		
		return true;
	} 
	else 
	{
		RedSystemMessage(m_session, "Player is not online at the moment.");
		return true;
	}
	return true;
}
Пример #6
0
bool ChatHandler::HandleGMTicketDeletePermanentCommand(const char* args, WorldSession* m_session)
{
	uint64 ticketGuid = (args ? atoi(args) : 0);
	if(!ticketGuid)
	{
		RedSystemMessage(m_session, "You must specify a ticket id.");
		return true;
	}

	Player* cplr = m_session->GetPlayer();
	Channel* chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), cplr);
	if(!chn)
		return false;

	GM_Ticket* ticket = objmgr.GetGMTicket(ticketGuid);
	if(ticket == NULL)
	{
		chn->Say(cplr, "GmTicket:0:Ticket not found.", cplr, true);
		return true;
	}

	Player* plr = NULL;

	if(!ticket->deleted)
	{
		plr = objmgr.GetPlayer((uint32)ticket->playerGuid);

		std::stringstream ss;
		ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_REMOVED;
		ss << ":" << ticket->guid;
		chn->Say(cplr, ss.str().c_str(), NULL, true);

		objmgr.RemoveGMTicket(ticket->guid);
	}

	objmgr.DeleteGMTicketPermanently(ticket->guid);
	ticket = NULL;
	if(plr != NULL && plr->IsInWorld())
	{
		// Notify player about removing ticket
		WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
		data << uint32(9);
		plr->GetSession()->SendPacket(&data);

		// Response - Send GM Survey
		WorldPacket datab(SMSG_GM_TICKET_STATUS_UPDATE, 1);
		datab << uint32(3);
		plr->GetSession()->SendPacket(&datab);
		//plr->GetSession()->GetPlayer()->OutPacketToSet( SMSG_GM_TICKET_STATUS_UPDATE, 1, SENDSURVEY,true);
		SystemMessageToPlr(plr, "You have been selected to fill out a GM Performance Survey. Please respond truthfully to the questions that you are asked and include the Game Masters name to your comment.");
	}

	return true;
}
Пример #7
0
bool ChatHandler::HandleRemoveSkillCommand(const char *args, WorldSession *m_session)
{
	uint32 skill = 0;
	char *pSkill = strtok((char*)args, " ");
	if(!pSkill)
		return false;
	else 
		skill = atol(pSkill);
	BlueSystemMessage(m_session, "Removing skill line %d", skill);

	Player *plr = getSelectedChar(m_session, true);
	if(!plr) return true;
	sGMLog.writefromsession(m_session, "used remove skill of %u on %s", skill, plr->GetName());
	plr->_RemoveSkillLine(skill);
	SystemMessageToPlr(plr, "%s removed skill line %d from you. ", m_session->GetPlayer()->GetName(), skill);
	return true;
}
Пример #8
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;
}
Пример #9
0
bool ChatHandler::HandleGMTicketAssignToCommand(const char* args, WorldSession* m_session)
{
	uint64 ticketGuid;
	char guidString[100], name[100];
	int argc = sscanf(args, "%s %s", guidString, name);
	if(argc < 1 || argc > 2)
		return false;

	ticketGuid = atoi(guidString);
	if(!ticketGuid)
	{
		RedSystemMessage(m_session, "You must specify a ticket id.");
		return true;
	}

	Player* cplr = m_session->GetPlayer();
	Channel* chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), cplr);
	if(!chn)
		return false;

	GM_Ticket* ticket = objmgr.GetGMTicket(ticketGuid);

	if(ticket == NULL || ticket->deleted)
	{
		chn->Say(cplr, "GmTicket:0:Ticket not found.", cplr, true);
		return true;
	}

	Player* mplr = objmgr.GetPlayer((uint32)ticket->playerGuid);
	Player* plr = (argc == 1 ? cplr : objmgr.GetPlayer(name, false));
	if(plr == NULL)
	{
		chn->Say(cplr, "GmTicket:0:Player not found.", cplr, true);
		return true;
	}

	if(!plr->IsInWorld())
	{
		chn->Say(cplr, "GmTicket:0:Player isn't online.", cplr, true);
		return true;
	}

	if(plr->GetSession()->GetPermissionCount() == 0)
	{
		chn->Say(cplr, "GmTicket:0:Player is not a GM.", cplr, true);
		return true;
	}

	if(ticket->assignedToPlayer == plr->GetGUID())
	{
		chn->Say(cplr, "GmTicket:0:Ticket already assigned to this GM.", cplr, true);
		return true;
	}

	if(ticket->assignedToPlayer != 0 && ticket->assignedToPlayer != cplr->GetGUID())
	{
		Player* aplr = objmgr.GetPlayer((uint32)ticket->assignedToPlayer);
		if(aplr != NULL && aplr->IsInWorld() && !cplr->GetSession()->CanUseCommand('z'))
		{
			chn->Say(cplr, "GmTicket:0:Ticket already assigned to another GM.", cplr, true);
			return true;
		}
	}

	ticket->assignedToPlayer = plr->GetGUID();
	objmgr.UpdateGMTicket(ticket);

	std::stringstream ss;
	ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_ASSIGNED;
	ss << ":" << ticket->guid;
	ss << ":" << plr->GetName();
	chn->Say(cplr, ss.str().c_str(), NULL, true);
	//Send Response Packet to update Ticket
	//WorldPacket data(SMSG_GMTICKET_GETTICKET, 400);
	//data << uint32(6); // Packet Status
	//data << uint8(0x7);//static Category
	//data << ticket->message.c_str();//ticketDescription
	//data << float(0.0);//ticketAge - days //update time =  last time ticket was modified?
	//data << float(0.0);//oldestTicketTime - days
	//data << float(0.0);//updateTime - days | How recent is the data for oldest ticket time, measured in days.  If this number 1 hour, we have bad data.
	//data << unit64(2);//assignedToGM |0 - ticket is not currently assigned to a gm | 1 - ticket is assigned to a normal gm |	2 - ticket is in the escalation queue
	//data << uint64(1);//openedByGM | 0 - ticket has never been opened by a gm | 1 - ticket has been opened by a gm
	//mplr->GetSession()->SendPacket( &data );
	SystemMessageToPlr(mplr, "SYSTEM: Your ticket has been escalated. A Senior Game Master will be with you shortly!");
	return true;
}
Пример #10
0
bool ChatHandler::HandleAppearCommand(const char* args, WorldSession* m_session)
{
	if(!*args)
		return false;

	// Appear Blocking
	if(!stricmp(args, "on"))
	{
		if(m_session->GetPlayer()->IsAppearDisabled())
		{
			BlueSystemMessage(m_session, "Appear blocking is already enabled");
		}
		else
		{
			m_session->GetPlayer()->DisableAppear(true);
			GreenSystemMessage(m_session, "Appear blocking is now enabled");
		}
		return true;
	}
	else if(!stricmp(args, "off"))
	{
		if(m_session->GetPlayer()->IsAppearDisabled())
		{
			m_session->GetPlayer()->DisableAppear(false);
			GreenSystemMessage(m_session, "Appear blocking is now disabled");
		}
		else
		{
			BlueSystemMessage(m_session, "Appear blocking is already disabled");
		}
		return true;
	}

	Player* chr = objmgr.GetPlayer(args, false);
	if(chr)
	{
		char buf[256];

		if(!m_session->CanUseCommand('z') && chr->IsAppearDisabled())
		{
			snprintf((char*)buf, 256, "%s has blocked other GMs from appearing to them.", chr->GetName());
			SystemMessage(m_session, buf);
			return true;
		}

		if(chr->GetMapMgr() == NULL)
		{
			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;
}
Пример #11
0
bool ChatHandler::HandleSummonCommand(const char* args, WorldSession* m_session)
{
	if(!*args)
		return false;

	// Summon Blocking
	if(!stricmp(args, "on"))
	{
		if(m_session->GetPlayer()->IsSummonDisabled())
		{
			BlueSystemMessage(m_session, "Summon blocking is already enabled");
		}
		else
		{
			m_session->GetPlayer()->DisableSummon(true);
			GreenSystemMessage(m_session, "Summon blocking is now enabled");
		}
		return true;
	}
	else if(!stricmp(args, "off"))
	{
		if(m_session->GetPlayer()->IsSummonDisabled())
		{
			m_session->GetPlayer()->DisableSummon(false);
			GreenSystemMessage(m_session, "Summon blocking is now disabled");
		}
		else
		{
			BlueSystemMessage(m_session, "Summon blocking is already disabled");
		}
		return true;
	}

	Player* chr = objmgr.GetPlayer(args, false);
	if(chr)
	{
		// send message to user
		char buf[256];
		char buf0[256];

		if(!m_session->CanUseCommand('z') && chr->IsSummonDisabled())
		{
			snprintf((char*)buf, 256, "%s has blocked other GMs from summoning them.", chr->GetName());
			SystemMessage(m_session, buf);
			return true;
		}

		if(chr->GetMapMgr() == NULL)
		{
			snprintf((char*)buf, 256, "%s is already being teleported.", chr->GetName());
			SystemMessage(m_session, buf);
			return true;
		}
		snprintf((char*)buf, 256, "You are summoning %s.", chr->GetName());
		SystemMessage(m_session, buf);

		// Don't summon the dead, lol, I see dead people. :P
		// If you do, we better bring them back to life
		if(chr->getDeathState() == 1)  // Just died
			chr->RemoteRevive();
		if(chr->getDeathState() != 0)  // Not alive
			chr->ResurrectPlayer();

		if(!m_session->GetPlayer()->m_isGmInvisible)
		{
			// send message to player
			snprintf((char*)buf0, 256, "You are being summoned by %s.", m_session->GetPlayer()->GetName());
			SystemMessageToPlr(chr, buf0);
		}

		Player* plr = m_session->GetPlayer();

		if(plr->GetMapMgr() == chr->GetMapMgr())
			chr->_Relocate(plr->GetMapId(), plr->GetPosition(), false, false, plr->GetInstanceID());
		else
		{
			sEventMgr.AddEvent(chr, &Player::EventPortToGM, plr, 0, 1, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
		}
	}
	else
	{
		PlayerInfo* pinfo = objmgr.GetPlayerInfoByName(args);
		if(!pinfo)
		{
			char buf[256];
			snprintf((char*)buf, 256, "Player (%s) does not exist.", args);
			SystemMessage(m_session, buf);
			return true;
		}
		else
		{
			Player* pPlayer = m_session->GetPlayer();
			char query[512];
			snprintf((char*) &query, 512, "UPDATE characters SET mapId = %u, positionX = %f, positionY = %f, positionZ = %f, zoneId = %u WHERE guid = %u;",	pPlayer->GetMapId(), pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetZoneId(), pinfo->guid);
			CharacterDatabase.Execute(query);
			char buf[256];
			snprintf((char*)buf, 256, "(Offline) %s has been summoned.", pinfo->name);
			SystemMessage(m_session, buf);
			return true;
		}
	}

	sGMLog.writefromsession(m_session, "summoned %s on map %u, %f %f %f", args, m_session->GetPlayer()->GetMapId(), m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ());
	return true;
}
Пример #12
0
bool ChatHandler::HandleSummonCommand(const char* args, WorldSession *m_session)
{
	if(!*args)
		return false;

	sGMLog.writefromsession(m_session, "summoned %s on map %u, %f %f %f", args, m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()->GetPositionX(),m_session->GetPlayer()->GetPositionY(),m_session->GetPlayer()->GetPositionZ());

	Player * plr = m_session->GetPlayer();
	Player *chr = objmgr.GetPlayer(args, false);
	if( chr && chr->m_isGmInvisible < 2 )
	{
		// send message to user
		char buf[256];
		char buf0[256];
		if( chr->IsBeingTeleported() == true )
		{
			snprintf((char*)buf,256, "%s is already being teleported.", chr->GetName());
			SystemMessage(m_session, buf);
			return true;
		}
		if(!chr->RemoveTransporterStatus())
		{
			char buff[256];
			snprintf((char*)buf,256, "%s already being teleported.", chr->GetName());
			SystemMessage(m_session, buff);
			return true;
		}
		if( plr->RS_getAccess() < chr->RS_getAccess() || chr->m_isGmInvisible > INVIS_NONE )
		{
			snprintf((char*)buf,256, "%s is attempting to summon you!", plr->GetName());
			SystemMessageToPlr(chr, buf);
			chr->SummonRequest(plr->GetLowGUID(), plr->GetZoneId(), plr->GetMapId(), plr->GetInstanceID(), plr->GetPosition());
			snprintf((char*)buf0,256, "Summon request sent.", chr->GetName());
			SystemMessage(m_session, buf0);
			return true;
		}
		snprintf((char*)buf,256, "You are summoning %s.", chr->GetName());
		SystemMessage(m_session, buf);

		if(!(plr->m_isGmInvisible && chr->RS_getAccess() >= RS_SCRIPTER))
		{
			// send message to player
			snprintf((char*)buf0,256, "You are being summoned by %s.", m_session->GetPlayer()->GetName());
			SystemMessageToPlr(chr, buf0);
		}

		if(chr->GetTaxiState())
		{
			sEventMgr.RemoveEvents(chr, EVENT_PLAYER_TAXI_DISMOUNT);
			sEventMgr.RemoveEvents(chr, EVENT_PLAYER_TAXI_INTERPOLATE);
			chr->SetTaxiState(false);
			chr->SetTaxiPath(NULL);
			chr->UnSetTaxiPos();
			chr->m_taxi_ride_time = 0;
			chr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID , 0);
			chr->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNTED_TAXI);
			chr->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOCK_PLAYER);
			chr->SetPlayerSpeed(RUN, chr->m_runSpeed);
		}
		if(chr->m_TransporterGUID)
		{
			Transporter * pTrans = objmgr.GetTransporter(GUID_LOPART(chr->m_TransporterGUID));
			if(pTrans)
			{
				if(chr->m_lockTransportVariables == true)
				{
					char buff[256];
					snprintf((char*)buf,256, "%s is already being teleported.", chr->GetName());
					SystemMessage(m_session, buff);
					return true;
				}
				pTrans->RemovePlayer(chr);
				chr->m_CurrentTransporter = NULL;
				chr->m_TransporterGUID = 0;
			}
		}

		if( plr->GetMapMgr() == chr->GetMapMgr() )
		{
			chr->_Relocate(plr->GetMapId(),plr->GetPosition(),false,false,plr->GetInstanceID());
		}
		else
		{
			sEventMgr.AddEvent(chr,&Player::EventPortToGM,plr,0,1,1,0);
		}
	}
	else
	{
		PlayerInfo * pinfo = objmgr.GetPlayerInfoByName(args);
		if(!pinfo)
		{
			char buf[256];
			snprintf((char*)buf,256,"Player (%s) does not exist.", args);
			SystemMessage(m_session, buf);
		}
		else
		{
			Player * pPlayer = m_session->GetPlayer();
			char query[512];
			snprintf((char*) &query,512, "UPDATE characters SET mapId = %u, positionX = %f, positionY = %f, positionZ = %f, zoneId = %u WHERE guid = %u;",	pPlayer->GetMapId(), pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), pPlayer->GetZoneId(), pinfo->guid);
			CharacterDatabase.Execute(query);
			char buf[256];
			snprintf((char*)buf,256,"(Offline) %s has been summoned.", pinfo->name);
			SystemMessage(m_session, buf);
		}
	}
	return true;
}