吾爱尚玩资源基地

标题: 一个GM工具代码的函数参考 [打印本页]

作者: admin    时间: 2016-4-24 18:04
标题: 一个GM工具代码的函数参考
这个是一个脚本的代码。主要是给大家一个函数参考。和脚本的制作模版

功能:给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();
}







欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/) Powered by Discuz! X3.4