这个是一个脚本的代码。主要是给大家一个函数参考。和脚本的制作模版
功能:给GM玩家获得一些物品
脚本的类型是NPC的脚本,适用于Trinity端的脚本
#include "ScriptPCH.h"
//Enums here you can define certain numercial numbers as well as other things that you plan to use alot in your script or just for quicker acess.
enum items {
GM_HOOD = 12064,
GM_ROBE = 2586,
GM_SLIPPERS = 11508
};
/* Enums can also be achieved by typing it this way.
#define GM_HOOD 12064
#define GM_ROBE 2586
#define GM_SLIPPERS 11508
But i personally prefer enums.*/
class TestGmGear : public CreatureScript
{
public:
TestGmGear() : CreatureScript(/*TheScriptNameWhichYouWillAddToYourNpc*/"TestGmGear") { }
bool OnGossipHello(Player* player, Creature* creature)
{
player->ADD_GOSSIP_ITEM(/*IconId*/0, /*NameOfTheGossipMenu*/"I want gamemaster gear!", GOSSIP_SENDER_MAIN, /*NameOfTheCase*/1);
player->SEND_GOSSIP_MENU(1, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
if (sender == GOSSIP_SENDER_MAIN)
{
player->PlayerTalkClass->ClearMenus();
switch(action)
{
case 1:
player->/*ThisFunctionWillAddTheDefinedItemToThePlayer*/AddItem(/*TheItemYouWantGiven*/GM_HOOD, /*TheAmmountYouWantGiven*/1);
player->AddItem(GM_ROBE, 1);
player->AddItem(GM_SLIPPERS, 1);
player->/*ThisWillCloseTheGossipMenu*/PlayerTalkClass->SendCloseGossip();
break;
}
}
return true;
}
};
void AddSC_TestGmGear()
{
new TestGmGear();
}
|