1、先看看代码吧
#include "ScriptPCH.h"#include "Chat.h"
uint32 auras[] = { 48162, 48074, 48170, 43223, 36880, 467, 48469 }; //定义都有些什么BUFF可以加的
class buffcommand : public CommandScript
{
public:
buffcommand() : CommandScript("buffcommand") { }
ChatCommand* GetCommands() const
{
static ChatCommand IngameCommandTable[] =
{
{ "buff", rbac::RBAC_PERM_COMMAND_BUFF, true, &HandleBuffCommand, "", NULL }, //定义命令的名字为buff。你就可以在游戏里输入.buff 使用了
{ NULL, 0, false, NULL, "", NULL }
};
return IngameCommandTable;
}
static bool HandleBuffCommand(ChatHandler * handler, const char * args)
{
Player * pl = handler->GetSession()->GetPlayer();
if(pl->InArena())
{
pl->GetSession()->SendNotification("You can't use that item in an arena match!");
return false;
}
pl->RemoveAurasByType(SPELL_AURA_MOUNTED);
for(int i = 0; i < 7; i++)
pl->AddAura(auras, pl);
handler->PSendSysMessage("|cffB400B4You have been buffed, enjoy!");
return true;
}
};
void AddSC_buffcommand()
{
new buffcommand();
}
如何增加此脚本到代码中?
1、•把代码放到你的脚本代码目录里面。例如TrinityCore\src\server\scripts\Custom
2、•增加该脚本代码到cmake 的文件里面:
3、•增加到 script loader: (src\server\game\Scripting\ScriptLoader.cpp)这个文件中
void AddSC_buffcommand();
AddSC_buffcommand();
4、•增加下面的行到 rbac.h 行 683:
Code:
RBAC_PERM_COMMAND_BUFF = 1008,
数据库内容增加:
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES
(1008, 'Command: buff');
INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
(195, 1008);
完整代码这里
|