mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[2008_11_09_01_mangos_command.sql] Create new command .senditems and remove from moderator level command .sendmail possibility send items.
This commit is contained in:
parent
397d855569
commit
ad59efb6d9
7 changed files with 171 additions and 78 deletions
|
|
@ -22,7 +22,7 @@
|
|||
DROP TABLE IF EXISTS `db_version`;
|
||||
CREATE TABLE `db_version` (
|
||||
`version` varchar(120) default NULL,
|
||||
`required_2008_11_01_02_mangos_command` bit(1) default NULL
|
||||
`required_2008_11_09_01_mangos_command` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
@ -394,7 +394,8 @@ INSERT INTO `command` VALUES
|
|||
('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'),
|
||||
('save',0,'Syntax: .save\r\n\r\nSaves your character.'),
|
||||
('saveall',1,'Syntax: .saveall\r\n\r\nSave all characters in game.'),
|
||||
('sendmail',1,'Syntax: .sendmail #playername "#subject" "#text" itemid1[:count1] itemid2[:count2] ... itemidN[:countN]\r\n\r\nSend a mail to a player. Subject and mail text must be in "". If for itemid not provided related count values then expected 1, if count > max items in stack then items will be send in required amount stacks. All stacks amount in mail limited to 12.'),
|
||||
('senditems',3,'Syntax: .senditems #playername "#subject" "#text" itemid1[:count1] itemid2[:count2] ... itemidN[:countN]\r\n\r\nSend a mail to a player. Subject and mail text must be in "". If for itemid not provided related count values then expected 1, if count > max items in stack then items will be send in required amount stacks. All stacks amount in mail limited to 12.'),
|
||||
('sendmail',1,'Syntax: .sendmail #playername "#subject" "#text"\r\n\r\nSend a mail to a player. Subject and mail text must be in "".'),
|
||||
('sendmessage',3,'Syntax: .sendmessage $playername $message\r\n\r\nSend screen message to player from ADMINISTRATOR.'),
|
||||
('server corpses',2,'Syntax: .server corpses\r\n\r\nTriggering corpses expire check in world.'),
|
||||
('server exit',4,'Syntax: .server exit\r\n\r\nTerminate mangosd NOW.'),
|
||||
|
|
|
|||
6
sql/updates/2008_11_09_01_mangos_command.sql
Normal file
6
sql/updates/2008_11_09_01_mangos_command.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_2008_11_01_02_mangos_command required_2008_11_09_01_mangos_command bit;
|
||||
|
||||
delete from `command` where `name` IN ('senditems','sendmail');
|
||||
insert into `command` (`name`, `security`, `help`) values
|
||||
('senditems',3,'Syntax: .senditems #playername "#subject" "#text" itemid1[:count1] itemid2[:count2] ... itemidN[:countN]\r\n\r\nSend a mail to a player. Subject and mail text must be in "". If for itemid not provided related count values then expected 1, if count > max items in stack then items will be send in required amount stacks. All stacks amount in mail limited to 12.'),
|
||||
('sendmail',1,'Syntax: .sendmail #playername "#subject" "#text"\r\n\r\nSend a mail to a player. Subject and mail text must be in "".');
|
||||
|
|
@ -127,6 +127,7 @@ pkgdata_DATA = \
|
|||
2008_11_07_02_realmd_realmd_db_version.sql \
|
||||
2008_11_07_03_characters_guild_bank_tab.sql \
|
||||
2008_11_07_04_realmd_account.sql \
|
||||
2008_11_09_01_mangos_command.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -235,4 +236,5 @@ EXTRA_DIST = \
|
|||
2008_11_07_02_realmd_realmd_db_version.sql \
|
||||
2008_11_07_03_characters_guild_bank_tab.sql \
|
||||
2008_11_07_04_realmd_account.sql \
|
||||
2008_11_09_01_mangos_command.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -520,7 +520,8 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "password", SEC_PLAYER, false, &ChatHandler::HandlePasswordCommand, "", NULL },
|
||||
{ "lockaccount", SEC_PLAYER, false, &ChatHandler::HandleLockAccountCommand, "", NULL },
|
||||
{ "respawn", SEC_ADMINISTRATOR, false, &ChatHandler::HandleRespawnCommand, "", NULL },
|
||||
{ "sendmail", SEC_MODERATOR, false, &ChatHandler::HandleSendMailCommand, "", NULL },
|
||||
{ "senditems", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendItemsCommand, "", NULL },
|
||||
{ "sendmail", SEC_MODERATOR, true, &ChatHandler::HandleSendMailCommand, "", NULL },
|
||||
{ "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleRenameCommand, "", NULL },
|
||||
{ "loadscripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLoadScriptsCommand, "", NULL },
|
||||
{ "mute", SEC_GAMEMASTER, true, &ChatHandler::HandleMuteCommand, "", NULL },
|
||||
|
|
|
|||
|
|
@ -114,10 +114,11 @@ class ChatHandler
|
|||
bool HandleGPSCommand(const char* args);
|
||||
bool HandleTaxiCheatCommand(const char* args);
|
||||
bool HandleWhispersCommand(const char* args);
|
||||
bool HandleSendMailCommand(const char* args);
|
||||
bool HandleNameTeleCommand(const char* args);
|
||||
bool HandleGroupTeleCommand(const char* args);
|
||||
bool HandleDrunkCommand(const char* args);
|
||||
bool HandleSendItemsCommand(const char* args);
|
||||
bool HandleSendMailCommand(const char* args);
|
||||
|
||||
bool HandleEventActiveListCommand(const char* args);
|
||||
bool HandleEventStartCommand(const char* args);
|
||||
|
|
@ -413,6 +414,7 @@ class ChatHandler
|
|||
bool HandleSendMessageCommand(const char * args);
|
||||
bool HandleRepairitemsCommand(const char* args);
|
||||
bool HandleWaterwalkCommand(const char* args);
|
||||
bool HandleSendMoneyCommand(const char* args);
|
||||
|
||||
//! Development Commands
|
||||
bool HandleSetValue(const char* args);
|
||||
|
|
|
|||
|
|
@ -1814,7 +1814,7 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
|||
if(!*args)
|
||||
return false;
|
||||
|
||||
// format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
|
||||
// format: name "subject text" "mail text"
|
||||
|
||||
char* pName = strtok((char*)args, " ");
|
||||
if(!pName)
|
||||
|
|
@ -1861,60 +1861,6 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
|||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
// extract items
|
||||
typedef std::pair<uint32,uint32> ItemPair;
|
||||
typedef std::list< ItemPair > ItemPairs;
|
||||
ItemPairs items;
|
||||
|
||||
// get all tail string
|
||||
char* tail = strtok(NULL, "");
|
||||
|
||||
// get from tail next item str
|
||||
while(char* itemStr = strtok(tail, " "))
|
||||
{
|
||||
// and get new tail
|
||||
tail = strtok(NULL, "");
|
||||
|
||||
// parse item str
|
||||
char* itemIdStr = strtok(itemStr, ":");
|
||||
char* itemCountStr = strtok(NULL, " ");
|
||||
|
||||
uint32 item_id = atoi(itemIdStr);
|
||||
if(!item_id)
|
||||
return false;
|
||||
|
||||
ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id);
|
||||
if(!item_proto)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1;
|
||||
if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
while(item_count > item_proto->Stackable)
|
||||
{
|
||||
items.push_back(ItemPair(item_id,item_proto->Stackable));
|
||||
item_count -= item_proto->Stackable;
|
||||
}
|
||||
|
||||
items.push_back(ItemPair(item_id,item_count));
|
||||
|
||||
if(items.size() > MAX_MAIL_ITEMS)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
|
|
@ -1930,30 +1876,16 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint32 sender_guidlo = m_session->GetPlayer()->GetGUIDLow();
|
||||
// from console show not existed sender
|
||||
uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0;
|
||||
|
||||
uint32 messagetype = MAIL_NORMAL;
|
||||
uint32 stationery = MAIL_STATIONERY_GM;
|
||||
uint32 itemTextId = 0;
|
||||
if (!text.empty())
|
||||
{
|
||||
itemTextId = objmgr.CreateItemText( text );
|
||||
}
|
||||
uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0;
|
||||
|
||||
Player *receiver = objmgr.GetPlayer(receiver_guid);
|
||||
|
||||
// fill mail
|
||||
MailItemsInfo mi; // item list preparing
|
||||
|
||||
for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
|
||||
{
|
||||
if(Item* item = Item::CreateItem(itr->first,itr->second,m_session->GetPlayer()))
|
||||
{
|
||||
item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
|
||||
}
|
||||
}
|
||||
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
PSendSysMessage(LANG_MAIL_SENT, name.c_str());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -6125,6 +6125,155 @@ bool ChatHandler::HandleAccountSetAddonCommand(const char* args)
|
|||
return true;
|
||||
}
|
||||
|
||||
//Send items by mail
|
||||
bool ChatHandler::HandleSendItemsCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
// format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
|
||||
|
||||
char* pName = strtok((char*)args, " ");
|
||||
if(!pName)
|
||||
return false;
|
||||
|
||||
char* tail1 = strtok(NULL, "");
|
||||
if(!tail1)
|
||||
return false;
|
||||
|
||||
char* msgSubject;
|
||||
if(*tail1=='"')
|
||||
msgSubject = strtok(tail1+1, "\"");
|
||||
else
|
||||
{
|
||||
char* space = strtok(tail1, "\"");
|
||||
if(!space)
|
||||
return false;
|
||||
msgSubject = strtok(NULL, "\"");
|
||||
}
|
||||
|
||||
if (!msgSubject)
|
||||
return false;
|
||||
|
||||
char* tail2 = strtok(NULL, "");
|
||||
if(!tail2)
|
||||
return false;
|
||||
|
||||
char* msgText;
|
||||
if(*tail2=='"')
|
||||
msgText = strtok(tail2+1, "\"");
|
||||
else
|
||||
{
|
||||
char* space = strtok(tail2, "\"");
|
||||
if(!space)
|
||||
return false;
|
||||
msgText = strtok(NULL, "\"");
|
||||
}
|
||||
|
||||
if (!msgText)
|
||||
return false;
|
||||
|
||||
// pName, msgSubject, msgText isn't NUL after prev. check
|
||||
std::string name = pName;
|
||||
std::string subject = msgSubject;
|
||||
std::string text = msgText;
|
||||
|
||||
// extract items
|
||||
typedef std::pair<uint32,uint32> ItemPair;
|
||||
typedef std::list< ItemPair > ItemPairs;
|
||||
ItemPairs items;
|
||||
|
||||
// get all tail string
|
||||
char* tail = strtok(NULL, "");
|
||||
|
||||
// get from tail next item str
|
||||
while(char* itemStr = strtok(tail, " "))
|
||||
{
|
||||
// and get new tail
|
||||
tail = strtok(NULL, "");
|
||||
|
||||
// parse item str
|
||||
char* itemIdStr = strtok(itemStr, ":");
|
||||
char* itemCountStr = strtok(NULL, " ");
|
||||
|
||||
uint32 item_id = atoi(itemIdStr);
|
||||
if(!item_id)
|
||||
return false;
|
||||
|
||||
ItemPrototype const* item_proto = objmgr.GetItemPrototype(item_id);
|
||||
if(!item_proto)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 item_count = itemCountStr ? atoi(itemCountStr) : 1;
|
||||
if(item_count < 1 || item_proto->MaxCount && item_count > item_proto->MaxCount)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, item_count,item_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
while(item_count > item_proto->Stackable)
|
||||
{
|
||||
items.push_back(ItemPair(item_id,item_proto->Stackable));
|
||||
item_count -= item_proto->Stackable;
|
||||
}
|
||||
|
||||
items.push_back(ItemPair(item_id,item_count));
|
||||
|
||||
if(items.size() > MAX_MAIL_ITEMS)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!normalizePlayerName(name))
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
|
||||
if(!receiver_guid)
|
||||
{
|
||||
SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// from console show not existed sender
|
||||
uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0;
|
||||
|
||||
uint32 messagetype = MAIL_NORMAL;
|
||||
uint32 stationery = MAIL_STATIONERY_GM;
|
||||
uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0;
|
||||
|
||||
Player *receiver = objmgr.GetPlayer(receiver_guid);
|
||||
|
||||
// fill mail
|
||||
MailItemsInfo mi; // item list preparing
|
||||
|
||||
for(ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
|
||||
{
|
||||
if(Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0))
|
||||
{
|
||||
item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
|
||||
mi.AddItem(item->GetGUIDLow(), item->GetEntry(), item);
|
||||
}
|
||||
}
|
||||
|
||||
WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, &mi, 0, 0, MAIL_CHECK_MASK_NONE);
|
||||
|
||||
PSendSysMessage(LANG_MAIL_SENT, name.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Send a message to a player in game
|
||||
bool ChatHandler::HandleSendMessageCommand(const char* args)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue