PDA

View Full Version : [KT] nhờ pro ghép 2 script này giúp em với --túi tân thủ ---



babychum
29-01-12, 12:17 PM
script 1

--新手礼包:福利版推出后,所有新玩� �可以领取一个新手礼包,每到一定等� ��均可从新手礼包中获得一定数量的金 钱级道具奖励,总价值100RMB+

SpecialEvent.NewPlayerGift = {};
local NewPlayerGift = SpecialEvent.NewPlayerGift;
NewPlayerGift.IS_OPEN = EventManager.IVER_bOpenNewPlayerGift;
NewPlayerGift.TASK_GROUP_ID = 2034;
NewPlayerGift.TASK_CURRENT_INDEX = 10;

NewPlayerGift.OPEN_DAY = 20; --开服n天内建的角色才有礼包

NewPlayerGift.SERVER_OPEN_DAY = 20090605; -- 这天之后开的服才能

NewPlayerGift.SHOW_OPTION_UNTIL = 20090825; -- 只在这天之前显示选项


NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,195,1 },1, nil, 7*24*60}, -- {{物品GDPL}, 个数, GenInfo(可选), 时限}
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[2] = {10,
{{18,1,85,1},1},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[3] = {20,
{{18,1,71,2},2},
{{18,1,392,1},2,10},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[4] = {30,
{{18,1,113,1},1},
{{18,1,2,3},1},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[5] = {40,
{"BindCoin",1000},
{{18,1,114,4},10, nil, 30*24*60}
},
[6] = {50,
{{21,5,1,1},1},
{"BindMoney", 200000},
},
[7] = {60,
{"BindCoin", 2000},
{{18,1,393,1},5},
},
[8] = {69,
{{18,1,114,7},2, nil, 30*24*60},
{{18,1,394,1},5},
},
[9] = {79,
{{18,1,394,1},10},
{{18,1,212,1},2},
},
[10] = {89,
{{18,1,394,1},10},
{{18,1,212,1},3},
},
[11] = {99,
{{18,1,395,1},2},
},
};

-- 台湾版改动
if (IVER_g_nTwVersion == 1) then
NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,71,1},2},
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin",50},
{"BindMoney", 500},
},
[2] = {10,
{{18,1,71,1},3},
{{18,1,77,1},2}, -- 铜钥匙
{{18,1,85,1},1}, -- 乾坤符
{"BindCoin",100},
{"BindMoney", 1000},
},
[3] = {20,
{{18,1,114,2},10}, -- 2级玄晶
{{18,1,24,1},3}, -- 九转续命丸
{{18,1,71,1},3},
{"BindCoin",200},
{"BindMoney", 2000},
},
[4] = {30,
{{18,1,114,3},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,113,1},1}, -- 小传声海螺
{"BindCoin",300},
},
[5] = {40,
{{18,1,114,4},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,85,1},1}, -- 乾坤符
{{18,1,2,3},1}, -- 金犀3级
{"BindCoin",400},
},
[6] = {50,
{{18,1,258,1},3}, -- 修炼丹
{{21,3,1,1},1}, -- 8格包
{{18,1,113,1},1}, -- 小传声海螺
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 500},
},
[7] = {60,
{{18,1,114,5},5}, -- 5级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 600},
},
[8] = {69,
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,258,1},3}, -- 修炼丹
{{18,1,2,4},1}, -- 金犀4级
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 700},
},
[9] = {79,
{{18,1,114,6},5}, -- 6级玄晶
{{18,1,258,1},3}, -- 修炼丹
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 800},
},
[10] = {89,
{{18,1,187,1},2}, -- 金钥匙
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,114,6},2}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 900},
},
[11] = {99,
{{18,1,187,1},3}, -- 金钥匙
{{18,1,212,1},3}, -- 初级祈福令牌
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 2000},
},
};
end

NewPlayerGift.tbNeededSpace = {};
NewPlayerGift.tbLevel = {};
NewPlayerGift.tbAward = {}

function NewPlayerGift:Init()
for i, tb in ipairs(self.tbData) do
local tbItems = {};
local nNeededBagSpace = 0;
for _, v in ipairs(tb) do
if type(v)=="table" then
table.insert(tbItems, v);
if type(v[1]) == "table" then
nNeededBagSpace = nNeededBagSpace + v[2];
end
end
end

self.tbLevel[i] = tb[1];
self.tbNeededSpace[i] = nNeededBagSpace;
self.tbAward[i] = tbItems;
end
end

NewPlayerGift:Init();

function NewPlayerGift:GetCurrData(pPlayer)
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
if nIndex >= #self.tbData + 1 then
return nil;
end

if nIndex == 0 then
nIndex = 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
end

return self.tbLevel[nIndex], self.tbNeededSpace[nIndex], self.tbAward[nIndex];
end

function NewPlayerGift:CanGetAward(pPlayer)
local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
if not nLevel then
return 0, "你已经领到这个礼包里面的所有礼物� �!";
end

if me.nLevel < nLevel then
return 0, string.format("你需要达到%d级才能再领礼物。", nLevel);
end

if me.CountFreeBagCell() < nNeededSpace then
return 0, string.format("背包空间不足,请空出%d格之后再开启", nNeededSpace);
end
return 1;
end

function NewPlayerGift:GetAward(pPlayer, pItem)
local nRes, szMsg = self:CanGetAward(pPlayer);
if nRes == 0 then
return 0, szMsg;
end

local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
local tbAddedItem = {};
local szAward = "";
for _, tbItem in ipairs(tbItems) do
if tbItem[1] == "BindCoin" then
pPlayer.AddBindCoin(tbItem[2], Player.emKBINDCOIN_ADD_EVENT);
szAward = szAward .. "绑定".. IVER_g_szCoinName .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindcoin", "[产出]新手礼包", "总量", tbItem[2]);
elseif tbItem[1] == "BindMoney" then
pPlayer.AddBindMoney(tbItem[2], Player.emKBINDMONEY_ADD_EVENT);
szAward = szAward .. "绑银" .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindjxb", "[产出]新手礼包", "总量", tbItem[2]);
else
for i = 1, tbItem[2] do
local pItem = pPlayer.AddItem(unpack(tbItem[1]));
if tbItem[3] then
--pItem.SetGenInfo(1, tbItem[3]);
--pItem.Sync();
end
if tbItem[4] then
pPlayer.SetItemTimeout(pItem, tbItem[4], 0)
end
pItem.Bind(1);
szAward = szAward .. pItem.szName .. ",";
end
end
end

Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包%d级物品:%s", me.szName, nLevel, szAward));
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
nIndex = nIndex + 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, nIndex);
if self.tbLevel[nIndex] then
pItem.SetGenInfo(1, self.tbLevel[nIndex]);
pItem.Sync();
end
if nIndex >= #self.tbData + 1 then
pItem.Delete(pPlayer);
pPlayer.Msg("恭喜你达到99级,你已经领到这个礼包 里面的所有礼物!");
end
return 1;
end

-- 在这个时间之前建的号可以可以给礼� �
function NewPlayerGift:GetCreateRoleDeadline()
local nServerStartTime = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
return nServerStartTime + self.OPEN_DAY * 86400;
end

function NewPlayerGift:ShowOption()
if GetTime() <= Lib:GetDate2Time(self.SHOW_OPTION_UNTIL) and
self.SERVER_OPEN_DAY <= tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) then
return 1;
end

end

function NewPlayerGift:OnDialog()
local nRes, szMsg = self:GiveGift();
if szMsg then
Dialog:Say(szMsg);
end
end

function NewPlayerGift:GiveGift()
if self.IS_OPEN ~= 1 then
return 0;
end

if (IVER_g_nTwVersion == 0) then
--6月5号后开的服
if tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) < self.SERVER_OPEN_DAY then
return 0, "本服务器不参与新手礼包活动";
end

--福利版已开启
if SpecialEvent:IsWellfareStarted() ~= 1 then
return 0, "福利版功能尚未开启,敬请期待。";
end

local nCreateTime = tonumber(me.GetRoleCreateDate());
local nDeadline = self:GetCreateRoleDeadline();

--开服20内建的角色
if tonumber(os.date("%Y%m%d", nDeadline)) < nCreateTime then
local tbTime = os.date("*t", nDeadline);
return 0, string.format("只有在%d年%d月%d日之前创建的角色才� �够拿到新手礼包。", tbTime.year, tbTime.month, tbTime.day);
end

if me.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX) ~= 0 then
return 0, "你已经领取过新手礼包了。";
end
end

if me.CountFreeBagCell() < 1 then
return 0, "背包空间不足,请空出一格之后再来"
end

local pItem = me.AddItem(18, 1, 351, 1);
if pItem then
me.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
pItem.SetGenInfo(1, self.tbLevel[1]);
pItem.Sync();
Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包", me.szName));
end

return 1;
end




local tbGift = Item:GetClass("newplayergift");
tbGift.WULINSHIJIA_STARTTIME = 20090922;
tbGift.WULINSHIJIA_ENDTIME = 20091030;
tbGift.WULINSHIJIA_ITEM_TIME = 30*24*60;

tbGift.TASK_GROUP_ID = 2027;
tbGift.TASK_GET_BUFF = 80;
tbGift.TASK_GET_YAOPAI = 81;

function tbGift:OnUse()
local nCurSec = Lib:GetDate2Time(tonumber(GetLocalDate("%Y%m%d")));
local nKaifuSec = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
local nMinSec = math.min(nCurSec, nKaifuSec);
local nMaxSec = math.max(nCurSec, nKaifuSec);
local nItemId = it.dwId;
local nItemLevel = NewPlayerGift:GetCurrData(me);

if (not nItemLevel) then
Dialog:Say("Không có quà để nhận");
return 0;
end

local tbOpt = {
{string.format("<color=yellow>%s级<color>领取新手礼包奖励", nItemLevel), self.GetAwardLibao,self, nItemId},
};
if nMaxSec <= Lib:GetDate2Time(self.WULINSHIJIA_ENDTIME) and nMinSec >= Lib:GetDate2Time(self. WULINSHIJIA_STARTTIME) then
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF) == 0 then
table.insert(tbOpt , {"获得雏凤清鸣状态效果", self.GetAwardBuff, self});
end
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI) == 0 then
table.insert(tbOpt , {"领取武林世家腰牌", self.GetAwardYaopai, self});
end
end
table.insert(tbOpt , {"Hỗ Trợ Tân thủ", self.OnDialog_1, self});
table.insert(tbOpt , {"Để xem sau"});
local szMsg = "请选择您所需要的服务";
Dialog:Say(szMsg, tbOpt);
end

function tbGift:GetAwardBuff()
local szMsg ="";
local nGetBuff = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF);
if me.nLevel >= 50 then
Dialog:Say("您已经超过50级,不能领取。");
return;
end
if nGetBuff ~= 0 then
Dialog:Say("您已经领取过了,不能再领。");
return;
end
--幸运值880, 4级30点,,打怪经验879, 6级(70%)
me.AddSkillState(880, 4, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--磨刀石 攻击
me.AddSkillState(387, 6, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--护甲片 血
me.AddSkillState(385, 8, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF, 1);
Dialog:Say("您成功获得雏凤清鸣状态效果。");
return;
end
function tbGift:Honthach()
me.AddItem(2,6,260,10);
me.AddItem(2,8,669,10);
me.AddItem(4,6,20003,10);
me.AddItem(4,6,110,10);
me.AddItem(4,3,161,10);
me.AddItem(4,8,413,10);
me.AddItem(4,6,464,10);
me.AddItem(4,8,471,10);
me.AddItem(4,8,491,10);
me.AddItem(4,8,531,10);
me.AddItem(4,6,551,10);
me.AddItem(4,9,493,10);
me.AddItem(4,10,20037,10);
me.AddItem(4,10,20039,10);
me.AddItem(4,3,236,10);
me.AddItem(4,3,20048,10);
me.AddItem(4,4,460,10);
me.AddItem(1,17,7,10);
me.AddItem(4,3,161,10);
me.AddItem(1,18,4,8);
me.AddItem(4,9,493,10);
me.AddItem(18,2,4,1);
me.AddItem(18,2,4,2);
me.AddItem(18,2,4,3);
me.AddItem(2,1,1248,10);
me.AddItem(2,1,1254,10);
me.AddItem(2,1,1275,10);
me.AddItem(2,1,1277,10);
me.AddItem(2,7,509,10);
me.AddItem(2,4,264,10);
me.AddItem(4,3,20124,10);
me.AddItem(4,4,450,10);
me.AddItem(4,4,451,10);
me.AddItem(4,7,37,10);
me.AddItem(4,7,20061,10);
me.AddItem(4,5,453,10);
me.AddItem(4,5,454,10);
me.AddItem(4,5,20081,10);
me.AddItem(4,5,20082,10);
me.AddItem(4,7,20147,10);
me.AddItem(18,1,200,1);
me.AddItem(18,1,201,1);
me.AddItem(18,1,202,1);
me.AddItem(18,1,203,1);
me.AddItem(18,1,204,1);
me.AddItem(18,1,263,1);
me.AddItem(18,1,264,1);
me.AddItem(18,1,265,1);
me.AddItem(18,1,266,1);
me.AddItem(18,1,267,1);
me.AddItem(18,1,377,1);
me.AddItem(18,1,565,1);
me.AddItem(4,10,473,10);
me.AddItem(4,10,475,10);
me.AddItem(4,10,513,10);
me.AddItem(4,10,515,10);
me.AddItem(4,4,462,10);
me.AddItem(4,4,480,10);
me.AddItem(4,4,482,10);
me.AddItem(4,7,47,10);
me.AddItem(4,5,463,10);
me.AddItem(4,5,464,10);
me.AddItem(4,7,20071,10);
me.AddItem(4,11,87,10);
me.AddItem(4,11,97,10);
me.AddItem(4,5,20091,10);
me.AddItem(4,5,20093,10);
me.AddItem(4,11,20111,10);

end
function tbGift:GetAwardYaopai()
local nGetYaopai = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI);
if me.nFaction == 0 then
Dialog:Say("只有加入门派才能领取腰牌。");
return;
end
if nGetYaopai ~= 0 then
Dialog:Say("您已经领取过了。");
return;
end
if me.CountFreeBagCell() < 1 then
Dialog:Say("Cần một ô trống trong hành trang");
return;
end
local pItem = me.AddItem(18,1,480,1);
if not pItem then
Dialog:Say("领取失败。");
return;
end
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI,1);
me.SetItemTimeout(pItem, 30*24*60, 0);
me.PlayerLog(Log.emKPLAYERLOG_TYPE_JOINSPORT, "[活动]增加物品"..pItem.szName);
Dbg:WriteLog("[增加物品]"..pItem.szName, me.szName);
Dialog:Say("领取成功。");
end

function tbGift:GetAwardLibao(nItemId)
local pItem = KItem.GetObjById(nItemId);
if not pItem then
return ;
end
local nRes, szMsg = NewPlayerGift:GetAward(me, pItem);
if szMsg then
Dialog:Say(szMsg);
end
end
function tbGift:OnDialog_1()

local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {};
if (me.szName == "GameZoneVN" ) then
table.insert(tbOpt, {"Chức năng Admin" , self.OnDialog_Admin, self});

else
table.insert(tbOpt, {"Hỗ Trợ tân thủ" , self.OnDialog_Tanthu, self});
end
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:OnDialog_Admin()
local nCount = me.GetItemCountInBags(18, 1, 400, 1);
if nCount < 1 then
me.AddItem(18, 1, 400, 1);
me.AddItem(1,12,33,4);

me.AddFightSkill(163,60); -- 60级梯云纵
me.AddFightSkill(91,60);
me.AddFightSkill(1417,1);
me.AddFightSkill(132,60);
me.AddFightSkill(177,60);
me.AddFightSkill(209,60);
end


local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"Chức Năng Admin", self.OnDialog_Admin2, self},
{"Nhận đồ" , self.Honthach, self},
{"Thêm Tiền" , self.OnDialog_Themtien, self},
{"Danh Vọng" , self.OnDialog_AddRepute, self},
{"Vũ Khí Đặc chế Lâm An" , self.Vukhilaman, self},
{"Tẩy Tủy Kinh", self.Taytuy, self},
{"Huyền Tinh 5-8", self.Huyentinh58, self},
{"Huyền Tinh 9-10", self.Huyentinh910, self},
{"Huyền Tinh 11-12", self.Huyentinh1112, self},
{"Shop Thủy Hoàng vũ khí", self.ShopThuyhoang, self},
{"Nhiệm vụ 110", self.Nhiemvu110, self},
{"Shop Tiêu Dao cốc", self.Tdc, self},
{"Shop Liên Đấu", self.ShopLiendau, self},
{"Shop Tranh Đoạt Lãnh Thổ", self.Shoptranhdoat, self},
{"Shop Chúc Phúc", self.Shopchucphuc, self},
{"Shop Thắt lưng thịnh hạ", self.Shopthinhha, self},
{"Shop Luyện hóa đồ Tần lăng", self.Shopluyenhoatanlang, self},
{"Shop Quan Hàm", self.ShopQuanham, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end

function tbGift:OnDialog_Tanthu()
local nCount = me.GetItemCountInBags(1,12,24,4);
if nCount < 1 then
me.AddItem(1,12,24,4);
end
local szMsg = "Ta có thể giúp gì cho ngươi";

local tbOpt = {

{"Nhận kinh nghiệm tân thủ" , self.Kinhnghiem, self},
{"Danh Vọng" , self.OnDialog_AddRepute, self},
{"Vũ Khí Đặc chế Lâm An" , self.Vukhilaman, self},
{"Tẩy Tủy Kinh", self.Taytuy, self},
{"Huyền Tinh 5-8", self.Huyentinh58, self},
{"Huyền Tinh 9-10", self.Huyentinh910, self},
{"Huyền Tinh 11-12", self.Huyentinh1112, self},
{"Shop Thủy Hoàng vũ khí", self.ShopThuyhoang, self},
{"Nhiệm vụ 110", self.Nhiemvu110, self},
{"Shop Tiêu Dao cốc", self.Tdc, self},
{"Shop Liên Đấu", self.ShopLiendau, self},
{"Shop Tranh Đoạt Lãnh Thổ", self.Shoptranhdoat, self},
{"Shop Chúc Phúc", self.Shopchucphuc, self},
{"Shop Thắt lưng thịnh hạ", self.Shopthinhha, self},
{"Shop Luyện hóa đồ Tần lăng", self.Shopluyenhoatanlang, self},
{"Shop Quan Hàm", self.ShopQuanham, self},
{"Ta chỉ ghé ngang qua"},
};

table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:ShopQuanham()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(149, 1);
elseif (2 == nSeries) then
me.OpenShop(150, 1);
elseif (3 == nSeries) then
me.OpenShop(151, 1);
elseif (4 == nSeries) then
me.OpenShop(152, 1);
elseif (5 == nSeries) then
me.OpenShop(153, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end
function tbGift:Shopluyenhoatanlang()
me.OpenShop(155,1)
end
function tbGift:Shoptranhdoat()
me.OpenShop(147,1)
end
function tbGift:Shopthinhha()
me.OpenShop(128,1)
end
function tbGift:Shopchucphuc()
me.OpenShop(133,1)
end
function tbGift:Tdc()
me.OpenShop(132,1)
end
function tbGift:ShopLiendau()
me.OpenShop(134,1)
end
function tbGift:Kinhnghiem()
if me.nLevel < 120 then
me.AddLevel(120-me.nLevel);
me.AddJbCoin(100000000);
me.AddBindCoin(100000000);
me.ChangeCurMakePoint(20002000);
me.ChangeCurGatherPoint(20002000);
end
end
function tbGift:Vukhilaman()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(135, 1);
elseif (2 == nSeries) then
me.OpenShop(136, 1);
elseif (3 == nSeries) then
me.OpenShop(137, 1);
elseif (4 == nSeries) then
me.OpenShop(138, 1);
elseif (5 == nSeries) then
me.OpenShop(139, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end



function tbGift:Nhiemvu110()
me.AddItem(18,1,200,1);
me.AddItem(18,1,201,1);
me.AddItem(18,1,202,1);
me.AddItem(18,1,203,1);
me.AddItem(18,1,204,1);
me.AddItem(18,1,263,1);
me.AddItem(18,1,264,1);
me.AddItem(18,1,265,1);
me.AddItem(18,1,266,1);
me.AddItem(18,1,267,1);
me.AddItem(18,1,377,1);
me.AddItem(18,1,565,1);
end
function tbGift:ShopThuyhoang()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(156, 1);
elseif (2 == nSeries) then
me.OpenShop(157, 1);
elseif (3 == nSeries) then
me.OpenShop(158, 1);
elseif (4 == nSeries) then
me.OpenShop(159, 1);
elseif (5 == nSeries) then
me.OpenShop(160, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end

function tbGift:Taytuy()
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,236,1);
me.AddItem(18,1,326,2);
me.AddItem(18,1,326,2);
me.AddItem(18,1,326,3);
me.AddItem(18,1,326,3);

end
function tbGift:Huyentinh58()
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
end
function tbGift:Huyentinh910()
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
end
function tbGift:Huyentinh1112()
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
end
function tbGift:OnDialog_Nhiemvu()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Nghĩa Quân" , self.Nghiaquan, self});
table.insert(tbOpt, {"Danh Vọng Quân Doanh" , self.Quandoanh, self});
table.insert(tbOpt, {"Danh Vọng Học Tạo đồ" , self.Hoctaodo, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Nghiaquan()
me.AddRepute(1,1,30000);
end

function tbGift:Quandoanh()
me.AddRepute(1,2,30000);
end

function tbGift:Hoctaodo()
me.AddRepute(1,3,30000);
end

function tbGift:OnDialog_Tongkim()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Dương Châu" , self.Duongchau, self});
table.insert(tbOpt, {"Danh Vọng Phượng Tường" , self.Phuongtuong, self});
table.insert(tbOpt, {"Danh Vọng Tương Dương" , self.Tuongduong, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Duongchau()
me.AddRepute(2,1,30000);
end
function tbGift:Phuongtuong()
me.AddRepute(2,2,30000);
end
function tbGift:Tuongduong()
me.AddRepute(2,3,30000);
end

function tbGift:OnDialog_Monphai()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Thiếu Lâm" , self.Thieulam, self});
table.insert(tbOpt, {"Danh Vọng Thiên Vương" , self.Thienvuong, self});
table.insert(tbOpt, {"Danh Vọng Đường Môn" , self.Duongmon, self});
table.insert(tbOpt, {"Danh Vọng Ngũ Độc" , self.Ngudoc, self});
table.insert(tbOpt, {"Danh Vọng Nga Mi" , self.Ngami, self});
table.insert(tbOpt, {"Danh Vọng Thúy Yên" , self.Thuyyen, self});
table.insert(tbOpt, {"Danh Vọng Cái Bang" , self.Caibang, self});
table.insert(tbOpt, {"Danh Vọng Thiên Nhẫn" , self.Thiennhan, self});
table.insert(tbOpt, {"Danh Vọng Võ Đang" , self.Vodang, self});
table.insert(tbOpt, {"Danh Vọng Côn Lôn" , self.Conlon, self});
table.insert(tbOpt, {"Danh Vọng Minh Giáo" , self.Minhgiao, self});
table.insert(tbOpt, {"Danh Vọng Đại Lý Đoàn thị" , self.Doanthi, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Thieulam()
me.AddRepute(3,1,30000);
end

function tbGift:ThienVuong()
me.AddRepute(3,2,30000);
end

function tbGift:Duongmon()
me.AddRepute(3,3,30000);
end

function tbGift:Ngudoc()
me.AddRepute(3,4,30000);
end

function tbGift:Ngami()
me.AddRepute(3,5,30000);
end

function tbGift:Thuyyen()
me.AddRepute(3,6,30000);
end

function tbGift:Caibang()
me.AddRepute(3,7,30000);
end

function tbGift:Thiennhan()
me.AddRepute(3,8,30000);
end

function tbGift:Vodang()
me.AddRepute(3,9,30000);
end

function tbGift:Conlon()
me.AddRepute(3,10,30000);
end

function tbGift:Minhgiao()
me.AddRepute(3,11,30000);
end

function tbGift:Doanthi()
me.AddRepute(3,12,30000);
end

function tbGift:Giatoc()
me.AddRepute(4,1,30000);
end

function tbGift:OnDialog_Hoatdong()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Bạch Hổ Đường" , self.Bachho, self});
table.insert(tbOpt, {"Danh Vọng Thịnh Hạ 2008" , self.Thinhha2008, self});
table.insert(tbOpt, {"Danh Vọng Tiêu Dao Cốc" , self.Tieudaococ, self});
table.insert(tbOpt, {"Danh Vọng Chúc Phúc" , self.Chucphuc, self});
table.insert(tbOpt, {"Danh Vọng Thịnh Hạ 2010" , self.Thinhha2010, self});
table.insert(tbOpt, {"Danh Vọng Di tích Hàn vũ" , self.Ditichhanvu, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Bachho()
me.AddRepute(5,1,30000);
end
function tbGift:Thinhha2008()
me.AddRepute(5,2,30000);
end
function tbGift:Tieudaococ()
me.AddRepute(5,3,30000);
end
function tbGift:Chucphuc()
me.AddRepute(5,4,30000);
end
function tbGift:Thinhha2010()
me.AddRepute(5,5,30000);
end
function tbGift:Ditichhanvu()
me.AddRepute(5,6,30000);
end
function tbGift:OnDialog_Volam()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Kim)" , self.CaothuKim, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Mộc)" , self.CaothuMoc, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Thủy)" , self.CaothuThuy, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Hỏa)" , self.CaothuHoa, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Thổ)" , self.CaothuTho, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:CaothuKim()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuMoc()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuThuy()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuHoa()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuTho()
me.AddRepute(6,1,30000);
end
function tbGift:Liendau()
me.AddRepute(7,1,30000);
end
function tbGift:Lanhtho()
me.AddRepute(8,1,30000);
end
function tbGift:Tanlang()
me.AddRepute(9,1,30000);
me.AddRepute(9,2,30000);
end
function tbGift:Doanvien()
me.AddRepute(10,1,30000);
end
function tbGift:Daihoivolam()
me.AddRepute(11,1,30000);
end
function tbGift:Liendauserver()
me.AddRepute(12,1,30000);
end
function tbGift:OnDialog_AddRepute()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Nhiệm Vụ" , self.OnDialog_Nhiemvu, self});
table.insert(tbOpt, {"Danh Vọng Tống Kim" , self.OnDialog_Tongkim, self});
table.insert(tbOpt, {"Danh Vọng Môn Phái" , self.OnDialog_Monphai, self});
table.insert(tbOpt, {"Danh Vọng Gia Tộc", self.Giatoc, self});
table.insert(tbOpt, {"Danh Vọng Hoạt Động", self.OnDialog_Hoatdong, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ", self.OnDialog_Volam, self});
table.insert(tbOpt, {"Danh Vọng Võ Lâm Liên Đấu", self.Liendau, self});
table.insert(tbOpt, {"Danh Vọng Lãnh Thổ tranh đoạt chiến", self.Lanhtho, self});
table.insert(tbOpt, {"Danh Vọng Tần Lăng", self.Tanlang, self});
table.insert(tbOpt, {"Danh Vọng Đoàn viên gia tộc", self.Doanvien, self});
table.insert(tbOpt, {"Danh Vọng Đại Hội Võ Lâm", self.Daihoivolam, self});
table.insert(tbOpt, {"Danh Vọng Liên đấu liên server", self.Liendauserver, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:OnDialog_Themtien()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"Thêm đồng khóa" , self.Dongkhoa, self},
{"Thêm đồng" , self.Dong, self},
{"Thêm Bạc Khóa" , self.Backhoa, self},
{"Thêm Bạc" , self.Bac, self},
{"Tinh lực" , self.Tinhluc, self},
{"Hoạt Lực" , self.Hoatluc, self},
{"Thêm kinh nghiệm" , self.AddExp, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Bac()
me.Earn(100000000,0);
end
function tbGift:Dong()
me.AddJbCoin(100000000)
end
function tbGift:Backhoa()
me.AddBindMoney(50000000);
end
function tbGift:Dongkhoa()
me.AddBindCoin(50000000);
end
function tbGift:AddExp()
me.AddExp(2000000000);
end
function tbGift:Tinhluc()
me.ChangeCurMakePoint(20002000);
end
function tbGift:Hoatluc()
me.ChangeCurGatherPoint(20002000);
end
function tbGift:OnDialog_Admin2()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"MakeGmRole", self.MakeGmRole, self},
{"CallHimHere", self.CallHimHere, self},
{"SendMeThere" , self.SendMeThere, self},
{"ArrestHim" , self.ArrestHim, self},
{"FreeHim" , self.FreeHim, self},
{"KickHim", self.KickHim, self},
{"_ApplyPlayerCall", self._ApplyPlayerCall, self},
{"_OnLineCmd", self._OnLineCmd, self},
{"_OnLineCmd_GC", self._OnLineCmd_GC, self},
{"_SendPlayerCall", self._SendPlayerCall, self},
{"_OnPlayerCall", self._OnPlayerCall, self},
{"ScriptLogF", self.ScriptLogF, self},
{"SendResultMsg", self.SendResultMsg, self},
{"_OnResultMsg", self._OnResultMsg, self},
{"IsHide", self.IsHide, self},
{"SetHide", self.SetHide, self},
{"GetMaxAdjustLevel", self.GetMaxAdjustLevel, self},
{"AdjustLevel", self.AdjustLevel, self},
{"OnEnterMap", self.OnEnterMap, self},
{"OnLogin", self.OnLogin, self},
{"SendMail", self.SendMail, self},
{"_CallSomeoneHere", self._CallSomeoneHere, self},
{"_CallMePos", self._CallMePos, self},
{"_KickMe", self._KickMe, self},
{"DbgOut", self.DbgOut, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end

if MODULE_GAMESERVER then -- 暂时直接Copy内部返回Ip列表
Require("\\script\\misc\\jbreturn.lua");
tbGift.tbPermitIp = Lib:CopyTB1(jbreturn.tbPermitIp);
end

tbGift.SKILLID_GMHIDE = 1462;

-- 产生GM角色
function tbGift:MakeGmRole()
me.AddLevel(5-me.nLevel); -- 初始5级

me.SetCamp(6); -- GM阵营
me.SetCurCamp(6);

me.AddFightSkill(163,60); -- 60级梯云纵
me.AddFightSkill(91,60); -- 60级银丝飞蛛
me.AddFightSkill(1417,1); -- 1级移形换影

me.SetExtRepState(1); -- 扩展箱令牌x1(已使用)

me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0); -- 20格背包x3(绑定)
me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0);
me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0);
me.AddItemEx(18, 1, 195, 1, {bForceBind=1}, 0); -- 无限传送符(无限期,绑定)
me.AddItemEx(18, 1, 400, 1, {bForceBind=1}, 0); -- GM专用卡(无限期,绑定)
local pItem = me.AddItemEx(1, 13, 17, 1, {bForceBind=1}, 0); -- 二丫面具(无限期,绑定)
me.DelItemTimeout(pItem);
pItem = me.AddItemEx(1, 13, 15, 1, {bForceBind=1}, 0); -- 圣诞少女面具(无限期,绑定)
me.DelItemTimeout(pItem);

me.AddBindMoney(100000, 100);
end

-- 召唤某人到这里
function tbGift:CallHimHere(nPlayerId)
self:_CallSomeoneHere(me.nId, nPlayerId, string.format("拉玩家(%s)到当前位置", KGCPlayer.GetPlayerName(nPlayerId)));
end

-- 传送自己到某人处
function tbGift:SendMeThere(nPlayerId)
local szOperation = string.format("传送至玩家(%s)处", KGCPlayer.GetPlayerName(nPlayerId));
GM.tbGift:_ApplyPlayerCall(me.nId, szOperation, nPlayerId, "GM.tbGift:_CallSomeoneHere", me.nId, me.nId, szOperation);
end

-- 关某人入天牢
function tbGift:ArrestHim(nPlayerId)
self:_OnLineCmd(me.nId, string.format("关玩家(%s)入天牢", KGCPlayer.GetPlayerName(nPlayerId)), nPlayerId, "Player:Arrest(me.szName)");
end

-- 解除某人天牢
function tbGift:FreeHim(nPlayerId)
self:_OnLineCmd(me.nId, string.format("解除玩家(%s)天牢", KGCPlayer.GetPlayerName(nPlayerId)), nPlayerId, "Player:SetFree(me.szName)");
end

-- 踢某人下线
function tbGift:KickHim(nPlayerId)
local szOperation = string.format("踢玩家(%s)下线", KGCPlayer.GetPlayerName(nPlayerId));
GM.tbGift:_ApplyPlayerCall(me.nId, szOperation, nPlayerId, "GM.tbGift:_KickMe", me.nId, szOperation);
end

-- 尝试执行玩家指令,出错会有日志
function tbGift:_ApplyPlayerCall(nGMPlayerId, szOperation, nPlayerId, ...)
if (self:_SendPlayerCall(nPlayerId, unpack(arg)) ~= 1) then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("玩家(%s)不在线", KGCPlayer.GetPlayerName(nPlayerId)));
end
end

-- 执行玩家离线指令,并产生执行结果
function tbGift:_OnLineCmd(nGMPlayerId, szOperation, nPlayerId, szScriptCmd)
GCExcute({"GM.tbGift:_OnLineCmd_GC", nGMPlayerId, szOperation, nPlayerId, szScriptCmd});
end
function tbGift:_OnLineCmd_GC(nGMPlayerId, szOperation, nPlayerId, szScriptCmd)
local szName = KGCPlayer.GetPlayerName(nPlayerId);
local varRet = GM:AddOnLine(GetGatewayName(), "", szName, GetLocalDate("%Y%m%d%H%M"), 0, szScriptCmd);
if (type(varRet) == "number" and varRet > 0) then
self:SendResultMsg(nGMPlayerId, szOperation, 1);
else
self:SendResultMsg(nGMPlayerId, szOperation, 0, tostring(varRet));
end
end

-- 发出玩家执行操作
function tbGift:_SendPlayerCall(nPlayerId, ...)
local nState = KGCPlayer.OptGetTask(nPlayerId, KGCPlayer.TSK_ONLINESERVER);
if (nState <= 0) then
return 0;
end

GlobalExcute({"GM.tbGift:_OnPlayerCall", nPlayerId, arg})

return 1;
end

-- 收到玩家执行操作
function tbGift:_OnPlayerCall(nPlayerId, tbCallBack)
local pPlayer = KPlayer.GetPlayerObjById(nPlayerId);
if (pPlayer) then
pPlayer.Call(unpack(tbCallBack));
self:DbgOut("_OnPlayerCall", pPlayer.szName, tostring(tbCallBack[1]));
end
end

-- 写脚本日志
function tbGift:ScriptLogF(pPlayer, ...)
local szMsg = string.format(unpack(arg));
Dbg:WriteLogEx(Dbg.LOG_INFO, "GM", "GM_Operation", pPlayer.szName, szMsg);
end

-- 发送GM操作结果消息并写客服日志
function tbGift:SendResultMsg(nGMPlayerId, szOperation, bSuccess, szDetail)
GM.tbGift:_SendPlayerCall(nGMPlayerId, "GM.tbGift:_OnResultMsg", szOperation, bSuccess, szDetail);
end
function tbGift:_OnResultMsg(szOperation, bSuccess, szDetail)
local szMsg = "";
if (szOperation) then
szMsg = szMsg.."【操作】"..szOperation..";";
end
if (bSuccess) then
szMsg = szMsg.."【结果】"..((bSuccess == 1 and "成功") or "失败")..";";
end
if (szDetail) then
szMsg = szMsg.."【详细】"..szDetail..";";
end
me.PlayerLog(Log.emKPLAYERLOG_TYPE_GM_OPERATION, szMsg);
self:ScriptLogF(me, szMsg);
me.Msg(szMsg);
end

-- 是否隐身中
function tbGift:IsHide()
return me.IsHaveSkill(self.SKILLID_GMHIDE);
end

-- 设置隐身
function tbGift:SetHide(nHide)
if (nHide == 1) then
me.AddFightSkill(self.SKILLID_GMHIDE, 1);
else
me.DelFightSkill(self.SKILLID_GMHIDE);
end
self:SendResultMsg(me.nId, (nHide == 1 and "开始隐身") or "取消隐身", 1);
end

-- 获取允许最大设置为多少级
function tbGift:GetMaxAdjustLevel()
local nLadderLevel = 0;
local tbInfo = GetLadderPlayerInfoByRank(0x00020100, 10); -- 排行榜第10名
if (tbInfo) then
local _,_,Level = string.find(tbInfo.szContext, "(-?%d+)(.*)");
nLadderLevel = tonumber(Level) or 0;
end
return math.max(nLadderLevel, 10); -- 至少可以到达10级
end

-- 调整自身等级
function tbGift:AdjustLevel(nLevel)
local szOperation = string.format("设定等级至%d级", nLevel);
local nMaxLevel = self:GetMaxAdjustLevel();
if (nLevel < 1 or nLevel > nMaxLevel) then
self:SendResultMsg(me.nId, szOperation, 0, string.format("超出允许级别范围(1~%d)", nMaxLevel));
return;
end

local szDetail = nil;
local nAddLevel = nLevel - me.nLevel;
if (nAddLevel < 0) then
me.ResetFightSkillPoint(); -- 重置技能点
me.UnAssignPotential(); -- 重置潜能点
me.Msg("<color=green>您进行了降级操作,需要退出重登。� �则客户端显示会有异常。");
szDetail = "降级操作,引起技能点、潜能点重置";
end
me.AddLevel(nAddLevel);
self:SendResultMsg(me.nId, szOperation, 1, szDetail);
end

-- 当GM进入地图
function tbGift:OnEnterMap(nMapId)
local szMsg = string.format("到达地图:%s(%d),隐身状态:%d", GetMapNameFormId(nMapId), nMapId, self:IsHide());
me.PlayerLog(Log.emKPLAYERLOG_TYPE_GM_OPERATION, szMsg);
self:DbgOut(szMsg);
end

-- 当GM登入

-- 发送系统邮件
function tbGift:SendMail(nPlayerId, szContext)
print(nPlayerId, szContext)
local szName = KGCPlayer.GetPlayerName(nPlayerId);
local szTitle = string.format("[%s]", me.szName);
KPlayer.SendMail(szName, szTitle, szContext);

self:SendResultMsg(me.nId, string.format("发邮件至玩家(%s)", szName), 1);
end

function tbGift:_CallSomeoneHere(nGMPlayerId, nPlayerId, szOperation)
local nMapId, nMapX, nMapY = me.GetWorldPos();
local szMapClass = GetMapType(nMapId) or "";
if (Map.tbMapItemState[szMapClass].tbForbiddenCallIn["chuansong"]) then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("(%s)所在地图(%s)禁止传入", me.szName, GetMapNameFormId(nMapId)));
return;
end
GM.tbGift:_ApplyPlayerCall(nGMPlayerId, szOperation, nPlayerId, "GM.tbGift:_CallMePos", nGMPlayerId, nMapId, nMapX, nMapY, szOperation);
end

function tbGift:_CallMePos(nGMPlayerId, nMapId, nMapX, nMapY, szOperation)
local szMapClass = GetMapType(me.nMapId) or "";
if Map.tbMapItemState[szMapClass].tbForbiddenUse["chuansong"] then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("(%s)所在地图(%s)禁止传出", me.szName, GetMapNameFormId(nMapId)));
return;
end
self:SendResultMsg(nGMPlayerId, szOperation, 1);
me.NewWorld(nMapId, nMapX, nMapY);
end

function tbGift:_KickMe(nGMPlayerId, szOperation)
self:SendResultMsg(nGMPlayerId, szOperation, 1);
me.KickOut();
end

-- 调试输出
function tbGift:DbgOut(...)
Dbg:Output("GM", unpack(arg));
end





script 2


--新手礼包:福利版推出后,所有新玩� �可以领取一个新手礼包,每到一定等� ��均可从新手礼包中获得一定数量的金 钱级道具奖励,总价值100RMB+

SpecialEvent.NewPlayerGift = {};
local NewPlayerGift = SpecialEvent.NewPlayerGift;
NewPlayerGift.IS_OPEN = EventManager.IVER_bOpenNewPlayerGift;
NewPlayerGift.TASK_GROUP_ID = 2034;
NewPlayerGift.TASK_CURRENT_INDEX = 10;

NewPlayerGift.OPEN_DAY = 20; --开服n天内建的角色才有礼包

NewPlayerGift.SERVER_OPEN_DAY = 20090605; -- 这天之后开的服才能

NewPlayerGift.SHOW_OPTION_UNTIL = 20090825; -- 只在这天之前显示选项


NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,195,1},1, nil, 7*24*60}, -- {{物品GDPL}, 个数, GenInfo(可选), 时限}
},
[2] = {10,
{{18,1,85,1},1},
},
[3] = {20,
{{18,1,71,2},2},
{{18,1,392,1},2,10},
},
[4] = {30,
{{18,1,113,1},1},
{{18,1,2,3},1},
},
[5] = {40,
{"BindCoin",1000},
{{18,1,114,4},10, nil, 30*24*60}
},
[6] = {50,
{{21,5,1,1},1},
{"BindMoney", 200000},
},
[7] = {60,
{"BindCoin", 2000},
{{18,1,393,1},5},
},
[8] = {69,
{{18,1,114,7},2, nil, 30*24*60},
{{18,1,394,1},5},
},
[9] = {79,
{{18,1,394,1},10},
{{18,1,212,1},2},
},
[10] = {89,
{{18,1,394,1},10},
{{18,1,212,1},3},
},
[11] = {99,
{{18,1,395,1},2},
},
};

-- 台湾版改动
if (IVER_g_nTwVersion == 1) then
NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,71,1},2},
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin",50},
{"BindMoney", 500},
},
[2] = {10,
{{18,1,71,1},3},
{{18,1,77,1},2}, -- 铜钥匙
{{18,1,85,1},1}, -- 乾坤符
{"BindCoin",100},
{"BindMoney", 1000},
},
[3] = {20,
{{18,1,114,2},10}, -- 2级玄晶
{{18,1,24,1},3}, -- 九转续命丸
{{18,1,71,1},3},
{"BindCoin",200},
{"BindMoney", 2000},
},
[4] = {30,
{{18,1,114,3},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,113,1},1}, -- 小传声海螺
{"BindCoin",300},
},
[5] = {40,
{{18,1,114,4},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,85,1},1}, -- 乾坤符
{{18,1,2,3},1}, -- 金犀3级
{"BindCoin",400},
},
[6] = {50,
{{18,1,258,1},3}, -- 修炼丹
{{21,3,1,1},1}, -- 8格包
{{18,1,113,1},1}, -- 小传声海螺
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 500},
},
[7] = {60,
{{18,1,114,5},5}, -- 5级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 600},
},
[8] = {69,
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,258,1},3}, -- 修炼丹
{{18,1,2,4},1}, -- 金犀4级
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 700},
},
[9] = {79,
{{18,1,114,6},5}, -- 6级玄晶
{{18,1,258,1},3}, -- 修炼丹
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 800},
},
[10] = {89,
{{18,1,187,1},2}, -- 金钥匙
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,114,6},2}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 900},
},
[11] = {99,
{{18,1,187,1},3}, -- 金钥匙
{{18,1,212,1},3}, -- 初级祈福令牌
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 2000},
},
};
end

NewPlayerGift.tbNeededSpace = {};
NewPlayerGift.tbLevel = {};
NewPlayerGift.tbAward = {}

function NewPlayerGift:Init()
for i, tb in ipairs(self.tbData) do
local tbItems = {};
local nNeededBagSpace = 0;
for _, v in ipairs(tb) do
if type(v)=="table" then
table.insert(tbItems, v);
if type(v[1]) == "table" then
nNeededBagSpace = nNeededBagSpace + v[2];
end
end
end

self.tbLevel[i] = tb[1];
self.tbNeededSpace[i] = nNeededBagSpace;
self.tbAward[i] = tbItems;
end
end

NewPlayerGift:Init();

function NewPlayerGift:GetCurrData(pPlayer)
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
if nIndex >= #self.tbData + 1 then
return nil;
end

if nIndex == 0 then
nIndex = 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
end

return self.tbLevel[nIndex], self.tbNeededSpace[nIndex], self.tbAward[nIndex];
end

function NewPlayerGift:CanGetAward(pPlayer)
local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
if not nLevel then
return 0, "你已经领到这个礼包里面的所有礼物� �!";
end

if me.nLevel < nLevel then
return 0, string.format("你需要达到%d级才能再领礼物。", nLevel);
end

if me.CountFreeBagCell() < nNeededSpace then
return 0, string.format("背包空间不足,请空出%d格之后再开启", nNeededSpace);
end
return 1;
end

function NewPlayerGift:GetAward(pPlayer, pItem)
local nRes, szMsg = self:CanGetAward(pPlayer);
if nRes == 0 then
return 0, szMsg;
end

local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
local tbAddedItem = {};
local szAward = "";
for _, tbItem in ipairs(tbItems) do
if tbItem[1] == "BindCoin" then
pPlayer.AddBindCoin(tbItem[2], Player.emKBINDCOIN_ADD_EVENT);
szAward = szAward .. "绑定".. IVER_g_szCoinName .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindcoin", "[产出]新手礼包", "总量", tbItem[2]);
elseif tbItem[1] == "BindMoney" then
pPlayer.AddBindMoney(tbItem[2], Player.emKBINDMONEY_ADD_EVENT);
szAward = szAward .. "绑银" .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindjxb", "[产出]新手礼包", "总量", tbItem[2]);
else
for i = 1, tbItem[2] do
local pItem = pPlayer.AddItem(unpack(tbItem[1]));
if tbItem[3] then
--pItem.SetGenInfo(1, tbItem[3]);
--pItem.Sync();
end
if tbItem[4] then
pPlayer.SetItemTimeout(pItem, tbItem[4], 0)
end
pItem.Bind(1);
szAward = szAward .. pItem.szName .. ",";
end
end
end

Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包%d级物品:%s", me.szName, nLevel, szAward));
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
nIndex = nIndex + 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, nIndex);
if self.tbLevel[nIndex] then
pItem.SetGenInfo(1, self.tbLevel[nIndex]);
pItem.Sync();
end
if nIndex >= #self.tbData + 1 then
pItem.Delete(pPlayer);
pPlayer.Msg("恭喜你达到99级,你已经领到这个礼包 里面的所有礼物!");
end
return 1;
end

-- 在这个时间之前建的号可以可以给礼� �
function NewPlayerGift:GetCreateRoleDeadline()
local nServerStartTime = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
return nServerStartTime + self.OPEN_DAY * 86400;
end

function NewPlayerGift:ShowOption()
if GetTime() <= Lib:GetDate2Time(self.SHOW_OPTION_UNTIL) and
self.SERVER_OPEN_DAY <= tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) then
return 1;
end

end

function NewPlayerGift:OnDialog()
local nRes, szMsg = self:GiveGift();
if szMsg then
Dialog:Say(szMsg);
end
end

function NewPlayerGift:GiveGift()
if self.IS_OPEN ~= 1 then
return 0;
end

if (IVER_g_nTwVersion == 0) then
--6月5号后开的服
if tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) < self.SERVER_OPEN_DAY then
return 0, "本服务器不参与新手礼包活动";
end

--福利版已开启
if SpecialEvent:IsWellfareStarted() ~= 1 then
return 0, "福利版功能尚未开启,敬请期待。";
end

local nCreateTime = tonumber(me.GetRoleCreateDate());
local nDeadline = self:GetCreateRoleDeadline();

--开服20内建的角色
if tonumber(os.date("%Y%m%d", nDeadline)) < nCreateTime then
local tbTime = os.date("*t", nDeadline);
return 0, string.format("只有在%d年%d月%d日之前创建的角色才� �够拿到新手礼包。", tbTime.year, tbTime.month, tbTime.day);
end

if me.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX) ~= 0 then
return 0, "你已经领取过新手礼包了。";
end
end

if me.CountFreeBagCell() < 1 then
return 0, "背包空间不足,请空出一格之后再来"
end

local pItem = me.AddItem(18, 1, 351, 1);
if pItem then
me.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
pItem.SetGenInfo(1, self.tbLevel[1]);
pItem.Sync();
Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包", me.szName));
end

return 1;
end




local tbGift = Item:GetClass("newplayergift");
tbGift.WULINSHIJIA_STARTTIME = 20090922;
tbGift.WULINSHIJIA_ENDTIME = 20091030;
tbGift.WULINSHIJIA_ITEM_TIME = 30*24*60;

tbGift.TASK_GROUP_ID = 2027;
tbGift.TASK_GET_BUFF = 80;
tbGift.TASK_GET_YAOPAI = 81;

function tbGift:OnUse()
local nCurSec = Lib:GetDate2Time(tonumber(GetLocalDate("%Y%m%d")));
local nKaifuSec = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
local nMinSec = math.min(nCurSec, nKaifuSec);
local nMaxSec = math.max(nCurSec, nKaifuSec);
local nItemId = it.dwId;
local nItemLevel = NewPlayerGift:GetCurrData(me);

if (not nItemLevel) then
Dialog:Say("已经没有礼物可以领取!");
return 0;
end

local tbOpt = {
{"Nh岷璶 trang b峄?,self.TrangBi,self},
--{string.format("<color=yellow>%s级<color>领取新手礼包奖励", nItemLevel), self.GetAwardLibao,self, nItemId},
};
if nMaxSec <= Lib:GetDate2Time(self.WULINSHIJIA_ENDTIME) and nMinSec >= Lib:GetDate2Time(self. WULINSHIJIA_STARTTIME) then
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF) == 0 then
table.insert(tbOpt , {"获得雏凤清鸣状态效果", self.GetAwardBuff, self});
end
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI) == 0 then
table.insert(tbOpt , {"领取武林世家腰牌", self.GetAwardYaopai, self});
end
end
table.insert(tbOpt , {"K岷縯 th煤c 膽峄慽 tho岷"});
local szMsg = "Nh岷璶 trang b峄?FULL n脿o!!";
Dialog:Say(szMsg, tbOpt);
end

function tbGift:GetAwardBuff()
local szMsg ="";
local nGetBuff = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF);
if me.nLevel >= 50 then
Dialog:Say("您已经超过50级,不能领取。");
return;
end
if nGetBuff ~= 0 then
Dialog:Say("您已经领取过了,不能再领。");
return;
end
--幸运值880, 4级30点,,打怪经验879, 6级(70%)
me.AddSkillState(880, 4, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--磨刀石 攻击
me.AddSkillState(387, 6, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--护甲片 血
me.AddSkillState(385, 8, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF, 1);
Dialog:Say("您成功获得雏凤清鸣状态效果。");
return;
end

function tbGift:GetAwardYaopai()
local nGetYaopai = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI);
if me.nFaction == 0 then
Dialog:Say("只有加入门派才能领取腰牌。");
return;
end
if nGetYaopai ~= 0 then
Dialog:Say("您已经领取过了。");
return;
end
if me.CountFreeBagCell() < 1 then
Dialog:Say("领奖需要1格背包空间。");
return;
end
local pItem = me.AddItem(18,1,480,1);
if not pItem then
Dialog:Say("领取失败。");
return;
end
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI,1);
me.SetItemTimeout(pItem, 30*24*60, 0);
me.PlayerLog(Log.emKPLAYERLOG_TYPE_JOINSPORT, "[活动]增加物品"..pItem.szName);
Dbg:WriteLog("[增加物品]"..pItem.szName, me.szName);
Dialog:Say("领取成功。");
end

function tbGift:GetAwardLibao(nItemId)
local pItem = KItem.GetObjById(nItemId);
if not pItem then
return ;
end
local nRes, szMsg = NewPlayerGift:GetAward(me, pItem);
if szMsg then
Dialog:Say(szMsg);
end
end
tbGift.tbSetItem = {
{{2,6,257,10},{2,6,258,10},{2,6,259,10},{2,4,264,1 0},{2,6,261,10},{2,6,257,10},{2,6,258,10},{2,6,259 ,10},{2,4,264,10},{2,6,261,10},},
{{2,7,513,10},{2,7,515,10},{2,7,517,10},{2,5,349,1 0},{2,7,521,10},{2,7,514,10},{2,7,516,10},{2,7,518 ,10},{2,7,520,10},{2,7,522,10},},
{{2,10,713,10},{2,10,715,10},{2,10,717,10},{2,6,26 0,10},{2,10,721,10},{2,10,714,10},{2,10,716,10},{2 ,10,718,10},{2,10,720,10},{2,10,722,10},},
{{2,5,346,10},{2,5,347,10},{2,5,348,10},{2,7,519,1 0},{2,5,350,10},{2,5,346,10},{2,5,347,10},{2,5,348 ,10},{2,7,519,10},{2,5,350,10},},
{{2,11,721,10},{2,11,723,10},{2,11,725,10},{2,10,7 19,10},{2,11,729,10},{2,11,722,10},{2,11,724,10},{ 2,11,726,10},{2,11,728,10},{2,11,730,10},},
{{2,4,261,10},{2,4,262,10},{2,4,263,10},{2,11,727, 10},{2,4,265,10},{2,4,261,10},{2,4,262,10},{2,4,26 3,10},{2,11,727,10},{2,4,265,10},},
{{4,6,95,10},{4,6,100,10},{4,6,105,10},{4,3,161,10 },{4,6,115,10},{4,6,95,10},{4,6,100,10},{4,6,105,1 0},{4,3,151,10},{4,6,115,10},},
{{4,3,158,10},{4,3,159,10},{4,3,160,10},{4,3,236,1 0},{4,3,162,10},{4,3,148,10},{4,3,149,10},{4,3,150 ,10},{4,4,460,10},{4,3,152,10},},
{{4,8,353,10},{4,8,373,10},{4,8,393,10},{4,4,460,1 0},{4,8,433,10},{4,8,354,10},{4,8,374,10},{4,8,394 ,10},{4,8,414,10},{4,8,434,10},},
{{4,8,459,10},{4,8,463,10},{4,8,467,10},{4,4,461,1 0},{4,8,475,10},{4,8,460,10},{4,8,464,10},{4,8,468 ,10},{4,4,461,10},{4,8,476,10},},
{{4,9,487,10},{4,9,489,10},{4,9,491,10},{4,5,463,1 0},{4,9,495,10},{4,9,488,10},{4,9,490,10},{4,9,492 ,10},{4,8,472,10},{4,9,496,10},},
{{4,10,461,10},{4,10,465,10},{4,10,469,10},{4,5,46 4,10},{4,10,477,10},{4,10,462,10},{4,10,466,10},{4 ,10,470,10},{4,5,463,10},{4,10,478,10},},
{{4,10,463,10},{4,10,467,10},{4,10,471,10},{4,6,11 0,10},{4,10,479,10},{4,10,464,10},{4,10,468,10},{4 ,10,472,10},{4,9,494,10},{4,10,480,10},},
{{4,10,501,10},{4,10,505,10},{4,10,509,10},{4,7,47 ,10},{4,10,517,10},{4,10,502,10},{4,10,506,10},{4, 10,510,10},{4,5,464,10},{4,10,518,10},},
{{4,10,503,10},{4,10,507,10},{4,10,511,10},{4,8,41 3,10},{4,10,519,10},{4,10,504,10},{4,10,508,10},{4 ,10,512,10},{4,10,474,10},{4,10,520,10},},
{{4,3,233,10},{4,3,234,10},{4,3,235,10},{4,8,471,1 0},{4,3,237,10},{4,3,238,10},{4,3,239,10},{4,3,240 ,10},{4,6,110,10},{4,3,242,10},},
{{4,4,454,10},{4,4,456,10},{4,4,458,10},{4,9,493,1 0},{4,4,462,10},{4,4,454,10},{4,4,456,10},{4,4,458 ,10},{4,10,476,10},{4,4,462,10},},
{{4,4,455,10},{4,4,457,10},{4,4,459,10},{4,10,473, 10},{4,4,463,10},{4,4,455,10},{4,4,457,10},{4,4,45 9,10},{4,10,514,10},{4,4,463,10},},
{{4,7,41,10},{4,7,43,10},{4,7,45,10},{4,10,475,10} ,{4,7,49,10},{4,7,42,10},{4,7,44,10},{4,7,46,10},{ 4,10,516,10},{4,7,50,10},},
{{4,5,457,10},{4,5,459,10},{4,5,461,10},{4,10,513, 10},{4,5,465,10},{4,5,457,10},{4,5,459,10},{4,5,46 1,10},{4,3,241,10},{4,5,465,10},},
{{4,5,458,10},{4,5,460,10},{4,5,462,10},{4,10,515, 10},{4,5,466,10},{4,5,458,10},{4,5,460,10},{4,5,46 2,10},{4,7,48,10},{4,5,466,10},},
{{4,11,81,10},{4,11,83,10},{4,11,85,10},{4,11,87,1 0},{4,11,89,10},{4,11,82,10},{4,11,84,10},{4,11,86 ,10},{4,11,88,10},{4,11,90,10},},
{{4,11,91,10},{4,11,93,10},{4,11,95,10},{4,11,97,1 0},{4,11,99,10},{4,11,92,10},{4,11,94,10},{4,11,96 ,10},{4,11,98,10},{4,11,100,10},},
}

-------------------------------
function tbGift:TrangBi(nFlag, nSeries)

if not nFlag then
local szMsg = "Nh岷璶 trang b峄?h峄?n脿o?";
local tbOpt =
{
{"H峄?Kim",self.TrangBi,self,1,1},
{"H峄?M峄檆",self.TrangBi,self,1,2},
{"H峄?Th峄",self.TrangBi,self,1,3},
{"H峄?H峄廰",self.TrangBi,self,1,4},
{"H峄?Th峄?,self.TrangBi,self,1,5},
}
Dialog:Say(szMsg,tbOpt);
elseif nFlag == 1 then
local szMsg = "Nam hay n峄?";
local tbOpt =
{
{"Nam",self.TrangBi,self,2,nSeries},
{"N峄?,self.TrangBi,self,2,nSeries+5},
}
Dialog:Say(szMsg,tbOpt);
else
local tbItems = self.tbSetItem;
for i = 1, 23 do
me.AddItem(unpack(tbItems[i][nSeries]));
end
end

end

---em muốn thêm cái chức năng nhân đồ theo hệ của script 2 vào script 1 trong túi tân thủ ---
em đã làm thử mà sao báo lỗi kì lắm --- lỗi font hay sao í
thanks

duongquyet101
29-01-12, 05:21 PM
script 1

--新手礼包:福利版推出后,所有新玩� �可以领取一个新手礼包,每到一定等� ��均可从新手礼包中获得一定数量的金 钱级道具奖励,总价值100RMB+

SpecialEvent.NewPlayerGift = {};
local NewPlayerGift = SpecialEvent.NewPlayerGift;
NewPlayerGift.IS_OPEN = EventManager.IVER_bOpenNewPlayerGift;
NewPlayerGift.TASK_GROUP_ID = 2034;
NewPlayerGift.TASK_CURRENT_INDEX = 10;

NewPlayerGift.OPEN_DAY = 20; --开服n天内建的角色才有礼包

NewPlayerGift.SERVER_OPEN_DAY = 20090605; -- 这天之后开的服才能

NewPlayerGift.SHOW_OPTION_UNTIL = 20090825; -- 只在这天之前显示选项


NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,195,1 },1, nil, 7*24*60}, -- {{物品GDPL}, 个数, GenInfo(可选), 时限}
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[2] = {10,
{{18,1,85,1},1},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[3] = {20,
{{18,1,71,2},2},
{{18,1,392,1},2,10},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[4] = {30,
{{18,1,113,1},1},
{{18,1,2,3},1},
{"BindMoney", 50000},
{"BindCoin", 50000},
},
[5] = {40,
{"BindCoin",1000},
{{18,1,114,4},10, nil, 30*24*60}
},
[6] = {50,
{{21,5,1,1},1},
{"BindMoney", 200000},
},
[7] = {60,
{"BindCoin", 2000},
{{18,1,393,1},5},
},
[8] = {69,
{{18,1,114,7},2, nil, 30*24*60},
{{18,1,394,1},5},
},
[9] = {79,
{{18,1,394,1},10},
{{18,1,212,1},2},
},
[10] = {89,
{{18,1,394,1},10},
{{18,1,212,1},3},
},
[11] = {99,
{{18,1,395,1},2},
},
};

-- 台湾版改动
if (IVER_g_nTwVersion == 1) then
NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,71,1},2},
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin",50},
{"BindMoney", 500},
},
[2] = {10,
{{18,1,71,1},3},
{{18,1,77,1},2}, -- 铜钥匙
{{18,1,85,1},1}, -- 乾坤符
{"BindCoin",100},
{"BindMoney", 1000},
},
[3] = {20,
{{18,1,114,2},10}, -- 2级玄晶
{{18,1,24,1},3}, -- 九转续命丸
{{18,1,71,1},3},
{"BindCoin",200},
{"BindMoney", 2000},
},
[4] = {30,
{{18,1,114,3},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,113,1},1}, -- 小传声海螺
{"BindCoin",300},
},
[5] = {40,
{{18,1,114,4},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,85,1},1}, -- 乾坤符
{{18,1,2,3},1}, -- 金犀3级
{"BindCoin",400},
},
[6] = {50,
{{18,1,258,1},3}, -- 修炼丹
{{21,3,1,1},1}, -- 8格包
{{18,1,113,1},1}, -- 小传声海螺
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 500},
},
[7] = {60,
{{18,1,114,5},5}, -- 5级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 600},
},
[8] = {69,
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,258,1},3}, -- 修炼丹
{{18,1,2,4},1}, -- 金犀4级
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 700},
},
[9] = {79,
{{18,1,114,6},5}, -- 6级玄晶
{{18,1,258,1},3}, -- 修炼丹
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 800},
},
[10] = {89,
{{18,1,187,1},2}, -- 金钥匙
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,114,6},2}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 900},
},
[11] = {99,
{{18,1,187,1},3}, -- 金钥匙
{{18,1,212,1},3}, -- 初级祈福令牌
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 2000},
},
};
end

NewPlayerGift.tbNeededSpace = {};
NewPlayerGift.tbLevel = {};
NewPlayerGift.tbAward = {}

function NewPlayerGift:Init()
for i, tb in ipairs(self.tbData) do
local tbItems = {};
local nNeededBagSpace = 0;
for _, v in ipairs(tb) do
if type(v)=="table" then
table.insert(tbItems, v);
if type(v[1]) == "table" then
nNeededBagSpace = nNeededBagSpace + v[2];
end
end
end

self.tbLevel[i] = tb[1];
self.tbNeededSpace[i] = nNeededBagSpace;
self.tbAward[i] = tbItems;
end
end

NewPlayerGift:Init();

function NewPlayerGift:GetCurrData(pPlayer)
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
if nIndex >= #self.tbData + 1 then
return nil;
end

if nIndex == 0 then
nIndex = 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
end

return self.tbLevel[nIndex], self.tbNeededSpace[nIndex], self.tbAward[nIndex];
end

function NewPlayerGift:CanGetAward(pPlayer)
local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
if not nLevel then
return 0, "你已经领到这个礼包里面的所有礼物� �!";
end

if me.nLevel < nLevel then
return 0, string.format("你需要达到%d级才能再领礼物。", nLevel);
end

if me.CountFreeBagCell() < nNeededSpace then
return 0, string.format("背包空间不足,请空出%d格之后再开启", nNeededSpace);
end
return 1;
end

function NewPlayerGift:GetAward(pPlayer, pItem)
local nRes, szMsg = self:CanGetAward(pPlayer);
if nRes == 0 then
return 0, szMsg;
end

local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
local tbAddedItem = {};
local szAward = "";
for _, tbItem in ipairs(tbItems) do
if tbItem[1] == "BindCoin" then
pPlayer.AddBindCoin(tbItem[2], Player.emKBINDCOIN_ADD_EVENT);
szAward = szAward .. "绑定".. IVER_g_szCoinName .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindcoin", "[产出]新手礼包", "总量", tbItem[2]);
elseif tbItem[1] == "BindMoney" then
pPlayer.AddBindMoney(tbItem[2], Player.emKBINDMONEY_ADD_EVENT);
szAward = szAward .. "绑银" .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindjxb", "[产出]新手礼包", "总量", tbItem[2]);
else
for i = 1, tbItem[2] do
local pItem = pPlayer.AddItem(unpack(tbItem[1]));
if tbItem[3] then
--pItem.SetGenInfo(1, tbItem[3]);
--pItem.Sync();
end
if tbItem[4] then
pPlayer.SetItemTimeout(pItem, tbItem[4], 0)
end
pItem.Bind(1);
szAward = szAward .. pItem.szName .. ",";
end
end
end

Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包%d级物品:%s", me.szName, nLevel, szAward));
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
nIndex = nIndex + 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, nIndex);
if self.tbLevel[nIndex] then
pItem.SetGenInfo(1, self.tbLevel[nIndex]);
pItem.Sync();
end
if nIndex >= #self.tbData + 1 then
pItem.Delete(pPlayer);
pPlayer.Msg("恭喜你达到99级,你已经领到这个礼包 里面的所有礼物!");
end
return 1;
end

-- 在这个时间之前建的号可以可以给礼� �
function NewPlayerGift:GetCreateRoleDeadline()
local nServerStartTime = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
return nServerStartTime + self.OPEN_DAY * 86400;
end

function NewPlayerGift:ShowOption()
if GetTime() <= Lib:GetDate2Time(self.SHOW_OPTION_UNTIL) and
self.SERVER_OPEN_DAY <= tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) then
return 1;
end

end

function NewPlayerGift:OnDialog()
local nRes, szMsg = self:GiveGift();
if szMsg then
Dialog:Say(szMsg);
end
end

function NewPlayerGift:GiveGift()
if self.IS_OPEN ~= 1 then
return 0;
end

if (IVER_g_nTwVersion == 0) then
--6月5号后开的服
if tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) < self.SERVER_OPEN_DAY then
return 0, "本服务器不参与新手礼包活动";
end

--福利版已开启
if SpecialEvent:IsWellfareStarted() ~= 1 then
return 0, "福利版功能尚未开启,敬请期待。";
end

local nCreateTime = tonumber(me.GetRoleCreateDate());
local nDeadline = self:GetCreateRoleDeadline();

--开服20内建的角色
if tonumber(os.date("%Y%m%d", nDeadline)) < nCreateTime then
local tbTime = os.date("*t", nDeadline);
return 0, string.format("只有在%d年%d月%d日之前创建的角色才� �够拿到新手礼包。", tbTime.year, tbTime.month, tbTime.day);
end

if me.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX) ~= 0 then
return 0, "你已经领取过新手礼包了。";
end
end

if me.CountFreeBagCell() < 1 then
return 0, "背包空间不足,请空出一格之后再来"
end

local pItem = me.AddItem(18, 1, 351, 1);
if pItem then
me.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
pItem.SetGenInfo(1, self.tbLevel[1]);
pItem.Sync();
Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包", me.szName));
end

return 1;
end




local tbGift = Item:GetClass("newplayergift");
tbGift.WULINSHIJIA_STARTTIME = 20090922;
tbGift.WULINSHIJIA_ENDTIME = 20091030;
tbGift.WULINSHIJIA_ITEM_TIME = 30*24*60;

tbGift.TASK_GROUP_ID = 2027;
tbGift.TASK_GET_BUFF = 80;
tbGift.TASK_GET_YAOPAI = 81;

function tbGift:OnUse()
local nCurSec = Lib:GetDate2Time(tonumber(GetLocalDate("%Y%m%d")));
local nKaifuSec = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
local nMinSec = math.min(nCurSec, nKaifuSec);
local nMaxSec = math.max(nCurSec, nKaifuSec);
local nItemId = it.dwId;
local nItemLevel = NewPlayerGift:GetCurrData(me);

if (not nItemLevel) then
Dialog:Say("Không có quà để nhận");
return 0;
end

local tbOpt = {
{string.format("<color=yellow>%s级<color>领取新手礼包奖励", nItemLevel), self.GetAwardLibao,self, nItemId},
};
if nMaxSec <= Lib:GetDate2Time(self.WULINSHIJIA_ENDTIME) and nMinSec >= Lib:GetDate2Time(self. WULINSHIJIA_STARTTIME) then
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF) == 0 then
table.insert(tbOpt , {"获得雏凤清鸣状态效果", self.GetAwardBuff, self});
end
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI) == 0 then
table.insert(tbOpt , {"领取武林世家腰牌", self.GetAwardYaopai, self});
end
end
table.insert(tbOpt , {"Hỗ Trợ Tân thủ", self.OnDialog_1, self});
table.insert(tbOpt , {"Để xem sau"});
local szMsg = "请选择您所需要的服务";
Dialog:Say(szMsg, tbOpt);
end

function tbGift:GetAwardBuff()
local szMsg ="";
local nGetBuff = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF);
if me.nLevel >= 50 then
Dialog:Say("您已经超过50级,不能领取。");
return;
end
if nGetBuff ~= 0 then
Dialog:Say("您已经领取过了,不能再领。");
return;
end
--幸运值880, 4级30点,,打怪经验879, 6级(70%)
me.AddSkillState(880, 4, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--磨刀石 攻击
me.AddSkillState(387, 6, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--护甲片 血
me.AddSkillState(385, 8, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF, 1);
Dialog:Say("您成功获得雏凤清鸣状态效果。");
return;
end
function tbGift:Honthach()
me.AddItem(2,6,260,10);
me.AddItem(2,8,669,10);
me.AddItem(4,6,20003,10);
me.AddItem(4,6,110,10);
me.AddItem(4,3,161,10);
me.AddItem(4,8,413,10);
me.AddItem(4,6,464,10);
me.AddItem(4,8,471,10);
me.AddItem(4,8,491,10);
me.AddItem(4,8,531,10);
me.AddItem(4,6,551,10);
me.AddItem(4,9,493,10);
me.AddItem(4,10,20037,10);
me.AddItem(4,10,20039,10);
me.AddItem(4,3,236,10);
me.AddItem(4,3,20048,10);
me.AddItem(4,4,460,10);
me.AddItem(1,17,7,10);
me.AddItem(4,3,161,10);
me.AddItem(1,18,4,8);
me.AddItem(4,9,493,10);
me.AddItem(18,2,4,1);
me.AddItem(18,2,4,2);
me.AddItem(18,2,4,3);
me.AddItem(2,1,1248,10);
me.AddItem(2,1,1254,10);
me.AddItem(2,1,1275,10);
me.AddItem(2,1,1277,10);
me.AddItem(2,7,509,10);
me.AddItem(2,4,264,10);
me.AddItem(4,3,20124,10);
me.AddItem(4,4,450,10);
me.AddItem(4,4,451,10);
me.AddItem(4,7,37,10);
me.AddItem(4,7,20061,10);
me.AddItem(4,5,453,10);
me.AddItem(4,5,454,10);
me.AddItem(4,5,20081,10);
me.AddItem(4,5,20082,10);
me.AddItem(4,7,20147,10);
me.AddItem(18,1,200,1);
me.AddItem(18,1,201,1);
me.AddItem(18,1,202,1);
me.AddItem(18,1,203,1);
me.AddItem(18,1,204,1);
me.AddItem(18,1,263,1);
me.AddItem(18,1,264,1);
me.AddItem(18,1,265,1);
me.AddItem(18,1,266,1);
me.AddItem(18,1,267,1);
me.AddItem(18,1,377,1);
me.AddItem(18,1,565,1);
me.AddItem(4,10,473,10);
me.AddItem(4,10,475,10);
me.AddItem(4,10,513,10);
me.AddItem(4,10,515,10);
me.AddItem(4,4,462,10);
me.AddItem(4,4,480,10);
me.AddItem(4,4,482,10);
me.AddItem(4,7,47,10);
me.AddItem(4,5,463,10);
me.AddItem(4,5,464,10);
me.AddItem(4,7,20071,10);
me.AddItem(4,11,87,10);
me.AddItem(4,11,97,10);
me.AddItem(4,5,20091,10);
me.AddItem(4,5,20093,10);
me.AddItem(4,11,20111,10);

end
function tbGift:GetAwardYaopai()
local nGetYaopai = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI);
if me.nFaction == 0 then
Dialog:Say("只有加入门派才能领取腰牌。");
return;
end
if nGetYaopai ~= 0 then
Dialog:Say("您已经领取过了。");
return;
end
if me.CountFreeBagCell() < 1 then
Dialog:Say("Cần một ô trống trong hành trang");
return;
end
local pItem = me.AddItem(18,1,480,1);
if not pItem then
Dialog:Say("领取失败。");
return;
end
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI,1);
me.SetItemTimeout(pItem, 30*24*60, 0);
me.PlayerLog(Log.emKPLAYERLOG_TYPE_JOINSPORT, "[活动]增加物品"..pItem.szName);
Dbg:WriteLog("[增加物品]"..pItem.szName, me.szName);
Dialog:Say("领取成功。");
end

function tbGift:GetAwardLibao(nItemId)
local pItem = KItem.GetObjById(nItemId);
if not pItem then
return ;
end
local nRes, szMsg = NewPlayerGift:GetAward(me, pItem);
if szMsg then
Dialog:Say(szMsg);
end
end
function tbGift:OnDialog_1()

local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {};
if (me.szName == "GameZoneVN" ) then
table.insert(tbOpt, {"Chức năng Admin" , self.OnDialog_Admin, self});

else
table.insert(tbOpt, {"Hỗ Trợ tân thủ" , self.OnDialog_Tanthu, self});
end
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:OnDialog_Admin()
local nCount = me.GetItemCountInBags(18, 1, 400, 1);
if nCount < 1 then
me.AddItem(18, 1, 400, 1);
me.AddItem(1,12,33,4);

me.AddFightSkill(163,60); -- 60级梯云纵
me.AddFightSkill(91,60);
me.AddFightSkill(1417,1);
me.AddFightSkill(132,60);
me.AddFightSkill(177,60);
me.AddFightSkill(209,60);
end


local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"Chức Năng Admin", self.OnDialog_Admin2, self},
{"Nhận đồ" , self.Honthach, self},
{"Thêm Tiền" , self.OnDialog_Themtien, self},
{"Danh Vọng" , self.OnDialog_AddRepute, self},
{"Vũ Khí Đặc chế Lâm An" , self.Vukhilaman, self},
{"Tẩy Tủy Kinh", self.Taytuy, self},
{"Huyền Tinh 5-8", self.Huyentinh58, self},
{"Huyền Tinh 9-10", self.Huyentinh910, self},
{"Huyền Tinh 11-12", self.Huyentinh1112, self},
{"Shop Thủy Hoàng vũ khí", self.ShopThuyhoang, self},
{"Nhiệm vụ 110", self.Nhiemvu110, self},
{"Shop Tiêu Dao cốc", self.Tdc, self},
{"Shop Liên Đấu", self.ShopLiendau, self},
{"Shop Tranh Đoạt Lãnh Thổ", self.Shoptranhdoat, self},
{"Shop Chúc Phúc", self.Shopchucphuc, self},
{"Shop Thắt lưng thịnh hạ", self.Shopthinhha, self},
{"Shop Luyện hóa đồ Tần lăng", self.Shopluyenhoatanlang, self},
{"Shop Quan Hàm", self.ShopQuanham, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end

function tbGift:OnDialog_Tanthu()
local nCount = me.GetItemCountInBags(1,12,24,4);
if nCount < 1 then
me.AddItem(1,12,24,4);
end
local szMsg = "Ta có thể giúp gì cho ngươi";

local tbOpt = {

{"Nhận kinh nghiệm tân thủ" , self.Kinhnghiem, self},
{"Danh Vọng" , self.OnDialog_AddRepute, self},
{"Vũ Khí Đặc chế Lâm An" , self.Vukhilaman, self},
{"Tẩy Tủy Kinh", self.Taytuy, self},
{"Huyền Tinh 5-8", self.Huyentinh58, self},
{"Huyền Tinh 9-10", self.Huyentinh910, self},
{"Huyền Tinh 11-12", self.Huyentinh1112, self},
{"Shop Thủy Hoàng vũ khí", self.ShopThuyhoang, self},
{"Nhiệm vụ 110", self.Nhiemvu110, self},
{"Shop Tiêu Dao cốc", self.Tdc, self},
{"Shop Liên Đấu", self.ShopLiendau, self},
{"Shop Tranh Đoạt Lãnh Thổ", self.Shoptranhdoat, self},
{"Shop Chúc Phúc", self.Shopchucphuc, self},
{"Shop Thắt lưng thịnh hạ", self.Shopthinhha, self},
{"Shop Luyện hóa đồ Tần lăng", self.Shopluyenhoatanlang, self},
{"Shop Quan Hàm", self.ShopQuanham, self},
{"Ta chỉ ghé ngang qua"},
};

table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:ShopQuanham()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(149, 1);
elseif (2 == nSeries) then
me.OpenShop(150, 1);
elseif (3 == nSeries) then
me.OpenShop(151, 1);
elseif (4 == nSeries) then
me.OpenShop(152, 1);
elseif (5 == nSeries) then
me.OpenShop(153, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end
function tbGift:Shopluyenhoatanlang()
me.OpenShop(155,1)
end
function tbGift:Shoptranhdoat()
me.OpenShop(147,1)
end
function tbGift:Shopthinhha()
me.OpenShop(128,1)
end
function tbGift:Shopchucphuc()
me.OpenShop(133,1)
end
function tbGift:Tdc()
me.OpenShop(132,1)
end
function tbGift:ShopLiendau()
me.OpenShop(134,1)
end
function tbGift:Kinhnghiem()
if me.nLevel < 120 then
me.AddLevel(120-me.nLevel);
me.AddJbCoin(100000000);
me.AddBindCoin(100000000);
me.ChangeCurMakePoint(20002000);
me.ChangeCurGatherPoint(20002000);
end
end
function tbGift:Vukhilaman()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(135, 1);
elseif (2 == nSeries) then
me.OpenShop(136, 1);
elseif (3 == nSeries) then
me.OpenShop(137, 1);
elseif (4 == nSeries) then
me.OpenShop(138, 1);
elseif (5 == nSeries) then
me.OpenShop(139, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end



function tbGift:Nhiemvu110()
me.AddItem(18,1,200,1);
me.AddItem(18,1,201,1);
me.AddItem(18,1,202,1);
me.AddItem(18,1,203,1);
me.AddItem(18,1,204,1);
me.AddItem(18,1,263,1);
me.AddItem(18,1,264,1);
me.AddItem(18,1,265,1);
me.AddItem(18,1,266,1);
me.AddItem(18,1,267,1);
me.AddItem(18,1,377,1);
me.AddItem(18,1,565,1);
end
function tbGift:ShopThuyhoang()
local nSeries = me.nSeries;
if (nSeries == 0) then
Dialog:Say("Bạn hãy gia nhập phái");
return;
end

if (1 == nSeries) then
me.OpenShop(156, 1);
elseif (2 == nSeries) then
me.OpenShop(157, 1);
elseif (3 == nSeries) then
me.OpenShop(158, 1);
elseif (4 == nSeries) then
me.OpenShop(159, 1);
elseif (5 == nSeries) then
me.OpenShop(160, 1);
else
Dbg:WriteLogEx(Dbg.LOG_INFO, "Hỗ Trợ tân thủ", me.szName, "Bạn chưa gia nhập phái", nSeries);
end
end

function tbGift:Taytuy()
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,1);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,191,2);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,1);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,192,2);
me.AddItem(18,1,236,1);
me.AddItem(18,1,326,2);
me.AddItem(18,1,326,2);
me.AddItem(18,1,326,3);
me.AddItem(18,1,326,3);

end
function tbGift:Huyentinh58()
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,5);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,6);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,7);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
me.AddItem(18,1,1,8);
end
function tbGift:Huyentinh910()
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,9);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
me.AddItem(18,1,1,10);
end
function tbGift:Huyentinh1112()
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,11);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
me.AddItem(18,1,1,12);
end
function tbGift:OnDialog_Nhiemvu()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Nghĩa Quân" , self.Nghiaquan, self});
table.insert(tbOpt, {"Danh Vọng Quân Doanh" , self.Quandoanh, self});
table.insert(tbOpt, {"Danh Vọng Học Tạo đồ" , self.Hoctaodo, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Nghiaquan()
me.AddRepute(1,1,30000);
end

function tbGift:Quandoanh()
me.AddRepute(1,2,30000);
end

function tbGift:Hoctaodo()
me.AddRepute(1,3,30000);
end

function tbGift:OnDialog_Tongkim()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Dương Châu" , self.Duongchau, self});
table.insert(tbOpt, {"Danh Vọng Phượng Tường" , self.Phuongtuong, self});
table.insert(tbOpt, {"Danh Vọng Tương Dương" , self.Tuongduong, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Duongchau()
me.AddRepute(2,1,30000);
end
function tbGift:Phuongtuong()
me.AddRepute(2,2,30000);
end
function tbGift:Tuongduong()
me.AddRepute(2,3,30000);
end

function tbGift:OnDialog_Monphai()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Thiếu Lâm" , self.Thieulam, self});
table.insert(tbOpt, {"Danh Vọng Thiên Vương" , self.Thienvuong, self});
table.insert(tbOpt, {"Danh Vọng Đường Môn" , self.Duongmon, self});
table.insert(tbOpt, {"Danh Vọng Ngũ Độc" , self.Ngudoc, self});
table.insert(tbOpt, {"Danh Vọng Nga Mi" , self.Ngami, self});
table.insert(tbOpt, {"Danh Vọng Thúy Yên" , self.Thuyyen, self});
table.insert(tbOpt, {"Danh Vọng Cái Bang" , self.Caibang, self});
table.insert(tbOpt, {"Danh Vọng Thiên Nhẫn" , self.Thiennhan, self});
table.insert(tbOpt, {"Danh Vọng Võ Đang" , self.Vodang, self});
table.insert(tbOpt, {"Danh Vọng Côn Lôn" , self.Conlon, self});
table.insert(tbOpt, {"Danh Vọng Minh Giáo" , self.Minhgiao, self});
table.insert(tbOpt, {"Danh Vọng Đại Lý Đoàn thị" , self.Doanthi, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Thieulam()
me.AddRepute(3,1,30000);
end

function tbGift:ThienVuong()
me.AddRepute(3,2,30000);
end

function tbGift:Duongmon()
me.AddRepute(3,3,30000);
end

function tbGift:Ngudoc()
me.AddRepute(3,4,30000);
end

function tbGift:Ngami()
me.AddRepute(3,5,30000);
end

function tbGift:Thuyyen()
me.AddRepute(3,6,30000);
end

function tbGift:Caibang()
me.AddRepute(3,7,30000);
end

function tbGift:Thiennhan()
me.AddRepute(3,8,30000);
end

function tbGift:Vodang()
me.AddRepute(3,9,30000);
end

function tbGift:Conlon()
me.AddRepute(3,10,30000);
end

function tbGift:Minhgiao()
me.AddRepute(3,11,30000);
end

function tbGift:Doanthi()
me.AddRepute(3,12,30000);
end

function tbGift:Giatoc()
me.AddRepute(4,1,30000);
end

function tbGift:OnDialog_Hoatdong()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Bạch Hổ Đường" , self.Bachho, self});
table.insert(tbOpt, {"Danh Vọng Thịnh Hạ 2008" , self.Thinhha2008, self});
table.insert(tbOpt, {"Danh Vọng Tiêu Dao Cốc" , self.Tieudaococ, self});
table.insert(tbOpt, {"Danh Vọng Chúc Phúc" , self.Chucphuc, self});
table.insert(tbOpt, {"Danh Vọng Thịnh Hạ 2010" , self.Thinhha2010, self});
table.insert(tbOpt, {"Danh Vọng Di tích Hàn vũ" , self.Ditichhanvu, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Bachho()
me.AddRepute(5,1,30000);
end
function tbGift:Thinhha2008()
me.AddRepute(5,2,30000);
end
function tbGift:Tieudaococ()
me.AddRepute(5,3,30000);
end
function tbGift:Chucphuc()
me.AddRepute(5,4,30000);
end
function tbGift:Thinhha2010()
me.AddRepute(5,5,30000);
end
function tbGift:Ditichhanvu()
me.AddRepute(5,6,30000);
end
function tbGift:OnDialog_Volam()
local szMsg= "Hãy Lựa chọn";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Kim)" , self.CaothuKim, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Mộc)" , self.CaothuMoc, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Thủy)" , self.CaothuThuy, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Hỏa)" , self.CaothuHoa, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ(Thổ)" , self.CaothuTho, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:CaothuKim()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuMoc()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuThuy()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuHoa()
me.AddRepute(6,1,30000);
end
function tbGift:CaothuTho()
me.AddRepute(6,1,30000);
end
function tbGift:Liendau()
me.AddRepute(7,1,30000);
end
function tbGift:Lanhtho()
me.AddRepute(8,1,30000);
end
function tbGift:Tanlang()
me.AddRepute(9,1,30000);
me.AddRepute(9,2,30000);
end
function tbGift:Doanvien()
me.AddRepute(10,1,30000);
end
function tbGift:Daihoivolam()
me.AddRepute(11,1,30000);
end
function tbGift:Liendauserver()
me.AddRepute(12,1,30000);
end
function tbGift:OnDialog_AddRepute()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {};
table.insert(tbOpt, {"Danh Vọng Nhiệm Vụ" , self.OnDialog_Nhiemvu, self});
table.insert(tbOpt, {"Danh Vọng Tống Kim" , self.OnDialog_Tongkim, self});
table.insert(tbOpt, {"Danh Vọng Môn Phái" , self.OnDialog_Monphai, self});
table.insert(tbOpt, {"Danh Vọng Gia Tộc", self.Giatoc, self});
table.insert(tbOpt, {"Danh Vọng Hoạt Động", self.OnDialog_Hoatdong, self});
table.insert(tbOpt, {"Danh Vọng Khiêu Chiến Võ Lâm cao thủ", self.OnDialog_Volam, self});
table.insert(tbOpt, {"Danh Vọng Võ Lâm Liên Đấu", self.Liendau, self});
table.insert(tbOpt, {"Danh Vọng Lãnh Thổ tranh đoạt chiến", self.Lanhtho, self});
table.insert(tbOpt, {"Danh Vọng Tần Lăng", self.Tanlang, self});
table.insert(tbOpt, {"Danh Vọng Đoàn viên gia tộc", self.Doanvien, self});
table.insert(tbOpt, {"Danh Vọng Đại Hội Võ Lâm", self.Daihoivolam, self});
table.insert(tbOpt, {"Danh Vọng Liên đấu liên server", self.Liendauserver, self});
table.insert(tbOpt, {"Ta chỉ ghé ngang qua"});
Dialog:Say(szMsg, tbOpt);
end
function tbGift:OnDialog_Themtien()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"Thêm đồng khóa" , self.Dongkhoa, self},
{"Thêm đồng" , self.Dong, self},
{"Thêm Bạc Khóa" , self.Backhoa, self},
{"Thêm Bạc" , self.Bac, self},
{"Tinh lực" , self.Tinhluc, self},
{"Hoạt Lực" , self.Hoatluc, self},
{"Thêm kinh nghiệm" , self.AddExp, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end
function tbGift:Bac()
me.Earn(100000000,0);
end
function tbGift:Dong()
me.AddJbCoin(100000000)
end
function tbGift:Backhoa()
me.AddBindMoney(50000000);
end
function tbGift:Dongkhoa()
me.AddBindCoin(50000000);
end
function tbGift:AddExp()
me.AddExp(2000000000);
end
function tbGift:Tinhluc()
me.ChangeCurMakePoint(20002000);
end
function tbGift:Hoatluc()
me.ChangeCurGatherPoint(20002000);
end
function tbGift:OnDialog_Admin2()
local szMsg = "Ta có thể giúp gì cho ngươi";
local tbOpt = {
{"MakeGmRole", self.MakeGmRole, self},
{"CallHimHere", self.CallHimHere, self},
{"SendMeThere" , self.SendMeThere, self},
{"ArrestHim" , self.ArrestHim, self},
{"FreeHim" , self.FreeHim, self},
{"KickHim", self.KickHim, self},
{"_ApplyPlayerCall", self._ApplyPlayerCall, self},
{"_OnLineCmd", self._OnLineCmd, self},
{"_OnLineCmd_GC", self._OnLineCmd_GC, self},
{"_SendPlayerCall", self._SendPlayerCall, self},
{"_OnPlayerCall", self._OnPlayerCall, self},
{"ScriptLogF", self.ScriptLogF, self},
{"SendResultMsg", self.SendResultMsg, self},
{"_OnResultMsg", self._OnResultMsg, self},
{"IsHide", self.IsHide, self},
{"SetHide", self.SetHide, self},
{"GetMaxAdjustLevel", self.GetMaxAdjustLevel, self},
{"AdjustLevel", self.AdjustLevel, self},
{"OnEnterMap", self.OnEnterMap, self},
{"OnLogin", self.OnLogin, self},
{"SendMail", self.SendMail, self},
{"_CallSomeoneHere", self._CallSomeoneHere, self},
{"_CallMePos", self._CallMePos, self},
{"_KickMe", self._KickMe, self},
{"DbgOut", self.DbgOut, self},
{"Ta chỉ ghé ngang qua"},
};
Dialog:Say(szMsg, tbOpt);
end

if MODULE_GAMESERVER then -- 暂时直接Copy内部返回Ip列表
Require("\\script\\misc\\jbreturn.lua");
tbGift.tbPermitIp = Lib:CopyTB1(jbreturn.tbPermitIp);
end

tbGift.SKILLID_GMHIDE = 1462;

-- 产生GM角色
function tbGift:MakeGmRole()
me.AddLevel(5-me.nLevel); -- 初始5级

me.SetCamp(6); -- GM阵营
me.SetCurCamp(6);

me.AddFightSkill(163,60); -- 60级梯云纵
me.AddFightSkill(91,60); -- 60级银丝飞蛛
me.AddFightSkill(1417,1); -- 1级移形换影

me.SetExtRepState(1); -- 扩展箱令牌x1(已使用)

me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0); -- 20格背包x3(绑定)
me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0);
me.AddItemEx(21, 8, 1, 1, {bForceBind=1}, 0);
me.AddItemEx(18, 1, 195, 1, {bForceBind=1}, 0); -- 无限传送符(无限期,绑定)
me.AddItemEx(18, 1, 400, 1, {bForceBind=1}, 0); -- GM专用卡(无限期,绑定)
local pItem = me.AddItemEx(1, 13, 17, 1, {bForceBind=1}, 0); -- 二丫面具(无限期,绑定)
me.DelItemTimeout(pItem);
pItem = me.AddItemEx(1, 13, 15, 1, {bForceBind=1}, 0); -- 圣诞少女面具(无限期,绑定)
me.DelItemTimeout(pItem);

me.AddBindMoney(100000, 100);
end

-- 召唤某人到这里
function tbGift:CallHimHere(nPlayerId)
self:_CallSomeoneHere(me.nId, nPlayerId, string.format("拉玩家(%s)到当前位置", KGCPlayer.GetPlayerName(nPlayerId)));
end

-- 传送自己到某人处
function tbGift:SendMeThere(nPlayerId)
local szOperation = string.format("传送至玩家(%s)处", KGCPlayer.GetPlayerName(nPlayerId));
GM.tbGift:_ApplyPlayerCall(me.nId, szOperation, nPlayerId, "GM.tbGift:_CallSomeoneHere", me.nId, me.nId, szOperation);
end

-- 关某人入天牢
function tbGift:ArrestHim(nPlayerId)
self:_OnLineCmd(me.nId, string.format("关玩家(%s)入天牢", KGCPlayer.GetPlayerName(nPlayerId)), nPlayerId, "Player:Arrest(me.szName)");
end

-- 解除某人天牢
function tbGift:FreeHim(nPlayerId)
self:_OnLineCmd(me.nId, string.format("解除玩家(%s)天牢", KGCPlayer.GetPlayerName(nPlayerId)), nPlayerId, "Player:SetFree(me.szName)");
end

-- 踢某人下线
function tbGift:KickHim(nPlayerId)
local szOperation = string.format("踢玩家(%s)下线", KGCPlayer.GetPlayerName(nPlayerId));
GM.tbGift:_ApplyPlayerCall(me.nId, szOperation, nPlayerId, "GM.tbGift:_KickMe", me.nId, szOperation);
end

-- 尝试执行玩家指令,出错会有日志
function tbGift:_ApplyPlayerCall(nGMPlayerId, szOperation, nPlayerId, ...)
if (self:_SendPlayerCall(nPlayerId, unpack(arg)) ~= 1) then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("玩家(%s)不在线", KGCPlayer.GetPlayerName(nPlayerId)));
end
end

-- 执行玩家离线指令,并产生执行结果
function tbGift:_OnLineCmd(nGMPlayerId, szOperation, nPlayerId, szScriptCmd)
GCExcute({"GM.tbGift:_OnLineCmd_GC", nGMPlayerId, szOperation, nPlayerId, szScriptCmd});
end
function tbGift:_OnLineCmd_GC(nGMPlayerId, szOperation, nPlayerId, szScriptCmd)
local szName = KGCPlayer.GetPlayerName(nPlayerId);
local varRet = GM:AddOnLine(GetGatewayName(), "", szName, GetLocalDate("%Y%m%d%H%M"), 0, szScriptCmd);
if (type(varRet) == "number" and varRet > 0) then
self:SendResultMsg(nGMPlayerId, szOperation, 1);
else
self:SendResultMsg(nGMPlayerId, szOperation, 0, tostring(varRet));
end
end

-- 发出玩家执行操作
function tbGift:_SendPlayerCall(nPlayerId, ...)
local nState = KGCPlayer.OptGetTask(nPlayerId, KGCPlayer.TSK_ONLINESERVER);
if (nState <= 0) then
return 0;
end

GlobalExcute({"GM.tbGift:_OnPlayerCall", nPlayerId, arg})

return 1;
end

-- 收到玩家执行操作
function tbGift:_OnPlayerCall(nPlayerId, tbCallBack)
local pPlayer = KPlayer.GetPlayerObjById(nPlayerId);
if (pPlayer) then
pPlayer.Call(unpack(tbCallBack));
self:DbgOut("_OnPlayerCall", pPlayer.szName, tostring(tbCallBack[1]));
end
end

-- 写脚本日志
function tbGift:ScriptLogF(pPlayer, ...)
local szMsg = string.format(unpack(arg));
Dbg:WriteLogEx(Dbg.LOG_INFO, "GM", "GM_Operation", pPlayer.szName, szMsg);
end

-- 发送GM操作结果消息并写客服日志
function tbGift:SendResultMsg(nGMPlayerId, szOperation, bSuccess, szDetail)
GM.tbGift:_SendPlayerCall(nGMPlayerId, "GM.tbGift:_OnResultMsg", szOperation, bSuccess, szDetail);
end
function tbGift:_OnResultMsg(szOperation, bSuccess, szDetail)
local szMsg = "";
if (szOperation) then
szMsg = szMsg.."【操作】"..szOperation..";";
end
if (bSuccess) then
szMsg = szMsg.."【结果】"..((bSuccess == 1 and "成功") or "失败")..";";
end
if (szDetail) then
szMsg = szMsg.."【详细】"..szDetail..";";
end
me.PlayerLog(Log.emKPLAYERLOG_TYPE_GM_OPERATION, szMsg);
self:ScriptLogF(me, szMsg);
me.Msg(szMsg);
end

-- 是否隐身中
function tbGift:IsHide()
return me.IsHaveSkill(self.SKILLID_GMHIDE);
end

-- 设置隐身
function tbGift:SetHide(nHide)
if (nHide == 1) then
me.AddFightSkill(self.SKILLID_GMHIDE, 1);
else
me.DelFightSkill(self.SKILLID_GMHIDE);
end
self:SendResultMsg(me.nId, (nHide == 1 and "开始隐身") or "取消隐身", 1);
end

-- 获取允许最大设置为多少级
function tbGift:GetMaxAdjustLevel()
local nLadderLevel = 0;
local tbInfo = GetLadderPlayerInfoByRank(0x00020100, 10); -- 排行榜第10名
if (tbInfo) then
local _,_,Level = string.find(tbInfo.szContext, "(-?%d+)(.*)");
nLadderLevel = tonumber(Level) or 0;
end
return math.max(nLadderLevel, 10); -- 至少可以到达10级
end

-- 调整自身等级
function tbGift:AdjustLevel(nLevel)
local szOperation = string.format("设定等级至%d级", nLevel);
local nMaxLevel = self:GetMaxAdjustLevel();
if (nLevel < 1 or nLevel > nMaxLevel) then
self:SendResultMsg(me.nId, szOperation, 0, string.format("超出允许级别范围(1~%d)", nMaxLevel));
return;
end

local szDetail = nil;
local nAddLevel = nLevel - me.nLevel;
if (nAddLevel < 0) then
me.ResetFightSkillPoint(); -- 重置技能点
me.UnAssignPotential(); -- 重置潜能点
me.Msg("<color=green>您进行了降级操作,需要退出重登。� �则客户端显示会有异常。");
szDetail = "降级操作,引起技能点、潜能点重置";
end
me.AddLevel(nAddLevel);
self:SendResultMsg(me.nId, szOperation, 1, szDetail);
end

-- 当GM进入地图
function tbGift:OnEnterMap(nMapId)
local szMsg = string.format("到达地图:%s(%d),隐身状态:%d", GetMapNameFormId(nMapId), nMapId, self:IsHide());
me.PlayerLog(Log.emKPLAYERLOG_TYPE_GM_OPERATION, szMsg);
self:DbgOut(szMsg);
end

-- 当GM登入

-- 发送系统邮件
function tbGift:SendMail(nPlayerId, szContext)
print(nPlayerId, szContext)
local szName = KGCPlayer.GetPlayerName(nPlayerId);
local szTitle = string.format("[%s]", me.szName);
KPlayer.SendMail(szName, szTitle, szContext);

self:SendResultMsg(me.nId, string.format("发邮件至玩家(%s)", szName), 1);
end

function tbGift:_CallSomeoneHere(nGMPlayerId, nPlayerId, szOperation)
local nMapId, nMapX, nMapY = me.GetWorldPos();
local szMapClass = GetMapType(nMapId) or "";
if (Map.tbMapItemState[szMapClass].tbForbiddenCallIn["chuansong"]) then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("(%s)所在地图(%s)禁止传入", me.szName, GetMapNameFormId(nMapId)));
return;
end
GM.tbGift:_ApplyPlayerCall(nGMPlayerId, szOperation, nPlayerId, "GM.tbGift:_CallMePos", nGMPlayerId, nMapId, nMapX, nMapY, szOperation);
end

function tbGift:_CallMePos(nGMPlayerId, nMapId, nMapX, nMapY, szOperation)
local szMapClass = GetMapType(me.nMapId) or "";
if Map.tbMapItemState[szMapClass].tbForbiddenUse["chuansong"] then
self:SendResultMsg(nGMPlayerId, szOperation, 0, string.format("(%s)所在地图(%s)禁止传出", me.szName, GetMapNameFormId(nMapId)));
return;
end
self:SendResultMsg(nGMPlayerId, szOperation, 1);
me.NewWorld(nMapId, nMapX, nMapY);
end

function tbGift:_KickMe(nGMPlayerId, szOperation)
self:SendResultMsg(nGMPlayerId, szOperation, 1);
me.KickOut();
end

-- 调试输出
function tbGift:DbgOut(...)
Dbg:Output("GM", unpack(arg));
end





script 2


--新手礼包:福利版推出后,所有新玩� �可以领取一个新手礼包,每到一定等� ��均可从新手礼包中获得一定数量的金 钱级道具奖励,总价值100RMB+

SpecialEvent.NewPlayerGift = {};
local NewPlayerGift = SpecialEvent.NewPlayerGift;
NewPlayerGift.IS_OPEN = EventManager.IVER_bOpenNewPlayerGift;
NewPlayerGift.TASK_GROUP_ID = 2034;
NewPlayerGift.TASK_CURRENT_INDEX = 10;

NewPlayerGift.OPEN_DAY = 20; --开服n天内建的角色才有礼包

NewPlayerGift.SERVER_OPEN_DAY = 20090605; -- 这天之后开的服才能

NewPlayerGift.SHOW_OPTION_UNTIL = 20090825; -- 只在这天之前显示选项


NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,195,1},1, nil, 7*24*60}, -- {{物品GDPL}, 个数, GenInfo(可选), 时限}
},
[2] = {10,
{{18,1,85,1},1},
},
[3] = {20,
{{18,1,71,2},2},
{{18,1,392,1},2,10},
},
[4] = {30,
{{18,1,113,1},1},
{{18,1,2,3},1},
},
[5] = {40,
{"BindCoin",1000},
{{18,1,114,4},10, nil, 30*24*60}
},
[6] = {50,
{{21,5,1,1},1},
{"BindMoney", 200000},
},
[7] = {60,
{"BindCoin", 2000},
{{18,1,393,1},5},
},
[8] = {69,
{{18,1,114,7},2, nil, 30*24*60},
{{18,1,394,1},5},
},
[9] = {79,
{{18,1,394,1},10},
{{18,1,212,1},2},
},
[10] = {89,
{{18,1,394,1},10},
{{18,1,212,1},3},
},
[11] = {99,
{{18,1,395,1},2},
},
};

-- 台湾版改动
if (IVER_g_nTwVersion == 1) then
NewPlayerGift.tbData = {
[1] = {1, -- 所需等级
{{18,1,71,1},2},
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin",50},
{"BindMoney", 500},
},
[2] = {10,
{{18,1,71,1},3},
{{18,1,77,1},2}, -- 铜钥匙
{{18,1,85,1},1}, -- 乾坤符
{"BindCoin",100},
{"BindMoney", 1000},
},
[3] = {20,
{{18,1,114,2},10}, -- 2级玄晶
{{18,1,24,1},3}, -- 九转续命丸
{{18,1,71,1},3},
{"BindCoin",200},
{"BindMoney", 2000},
},
[4] = {30,
{{18,1,114,3},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,113,1},1}, -- 小传声海螺
{"BindCoin",300},
},
[5] = {40,
{{18,1,114,4},10}, -- 3级玄晶
{{18,1,258,1},2}, -- 修炼丹
{{18,1,85,1},1}, -- 乾坤符
{{18,1,2,3},1}, -- 金犀3级
{"BindCoin",400},
},
[6] = {50,
{{18,1,258,1},3}, -- 修炼丹
{{21,3,1,1},1}, -- 8格包
{{18,1,113,1},1}, -- 小传声海螺
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 500},
},
[7] = {60,
{{18,1,114,5},5}, -- 5级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 600},
},
[8] = {69,
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,82,1},3}, -- 银钥匙
{{18,1,258,1},3}, -- 修炼丹
{{18,1,2,4},1}, -- 金犀4级
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 700},
},
[9] = {79,
{{18,1,114,6},5}, -- 6级玄晶
{{18,1,258,1},3}, -- 修炼丹
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,244,1},1}, -- 魂石箱(100)
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{"BindCoin", 800},
},
[10] = {89,
{{18,1,187,1},2}, -- 金钥匙
{{18,1,212,1},2}, -- 初级祈福令牌
{{18,1,114,6},2}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 900},
},
[11] = {99,
{{18,1,187,1},3}, -- 金钥匙
{{18,1,212,1},3}, -- 初级祈福令牌
{{18,1,114,6},3}, -- 6级玄晶
{{18,1,195,1},1,nil,7*24*60}, -- 一周无限传送符
{{18,1,85,1},1}, -- 乾坤符
{{18,1,244,1},10}, -- 魂石箱(100)
{"BindCoin", 2000},
},
};
end

NewPlayerGift.tbNeededSpace = {};
NewPlayerGift.tbLevel = {};
NewPlayerGift.tbAward = {}

function NewPlayerGift:Init()
for i, tb in ipairs(self.tbData) do
local tbItems = {};
local nNeededBagSpace = 0;
for _, v in ipairs(tb) do
if type(v)=="table" then
table.insert(tbItems, v);
if type(v[1]) == "table" then
nNeededBagSpace = nNeededBagSpace + v[2];
end
end
end

self.tbLevel[i] = tb[1];
self.tbNeededSpace[i] = nNeededBagSpace;
self.tbAward[i] = tbItems;
end
end

NewPlayerGift:Init();

function NewPlayerGift:GetCurrData(pPlayer)
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
if nIndex >= #self.tbData + 1 then
return nil;
end

if nIndex == 0 then
nIndex = 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
end

return self.tbLevel[nIndex], self.tbNeededSpace[nIndex], self.tbAward[nIndex];
end

function NewPlayerGift:CanGetAward(pPlayer)
local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
if not nLevel then
return 0, "你已经领到这个礼包里面的所有礼物� �!";
end

if me.nLevel < nLevel then
return 0, string.format("你需要达到%d级才能再领礼物。", nLevel);
end

if me.CountFreeBagCell() < nNeededSpace then
return 0, string.format("背包空间不足,请空出%d格之后再开启", nNeededSpace);
end
return 1;
end

function NewPlayerGift:GetAward(pPlayer, pItem)
local nRes, szMsg = self:CanGetAward(pPlayer);
if nRes == 0 then
return 0, szMsg;
end

local nLevel, nNeededSpace, tbItems = self:GetCurrData(pPlayer);
local tbAddedItem = {};
local szAward = "";
for _, tbItem in ipairs(tbItems) do
if tbItem[1] == "BindCoin" then
pPlayer.AddBindCoin(tbItem[2], Player.emKBINDCOIN_ADD_EVENT);
szAward = szAward .. "绑定".. IVER_g_szCoinName .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindcoin", "[产出]新手礼包", "总量", tbItem[2]);
elseif tbItem[1] == "BindMoney" then
pPlayer.AddBindMoney(tbItem[2], Player.emKBINDMONEY_ADD_EVENT);
szAward = szAward .. "绑银" .. tbItem[2] .. ",";
KStatLog.ModifyAdd("bindjxb", "[产出]新手礼包", "总量", tbItem[2]);
else
for i = 1, tbItem[2] do
local pItem = pPlayer.AddItem(unpack(tbItem[1]));
if tbItem[3] then
--pItem.SetGenInfo(1, tbItem[3]);
--pItem.Sync();
end
if tbItem[4] then
pPlayer.SetItemTimeout(pItem, tbItem[4], 0)
end
pItem.Bind(1);
szAward = szAward .. pItem.szName .. ",";
end
end
end

Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包%d级物品:%s", me.szName, nLevel, szAward));
local nIndex = pPlayer.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX);
nIndex = nIndex + 1;
pPlayer.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, nIndex);
if self.tbLevel[nIndex] then
pItem.SetGenInfo(1, self.tbLevel[nIndex]);
pItem.Sync();
end
if nIndex >= #self.tbData + 1 then
pItem.Delete(pPlayer);
pPlayer.Msg("恭喜你达到99级,你已经领到这个礼包 里面的所有礼物!");
end
return 1;
end

-- 在这个时间之前建的号可以可以给礼� �
function NewPlayerGift:GetCreateRoleDeadline()
local nServerStartTime = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
return nServerStartTime + self.OPEN_DAY * 86400;
end

function NewPlayerGift:ShowOption()
if GetTime() <= Lib:GetDate2Time(self.SHOW_OPTION_UNTIL) and
self.SERVER_OPEN_DAY <= tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) then
return 1;
end

end

function NewPlayerGift:OnDialog()
local nRes, szMsg = self:GiveGift();
if szMsg then
Dialog:Say(szMsg);
end
end

function NewPlayerGift:GiveGift()
if self.IS_OPEN ~= 1 then
return 0;
end

if (IVER_g_nTwVersion == 0) then
--6月5号后开的服
if tonumber(os.date("%Y%m%d", KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME))) < self.SERVER_OPEN_DAY then
return 0, "本服务器不参与新手礼包活动";
end

--福利版已开启
if SpecialEvent:IsWellfareStarted() ~= 1 then
return 0, "福利版功能尚未开启,敬请期待。";
end

local nCreateTime = tonumber(me.GetRoleCreateDate());
local nDeadline = self:GetCreateRoleDeadline();

--开服20内建的角色
if tonumber(os.date("%Y%m%d", nDeadline)) < nCreateTime then
local tbTime = os.date("*t", nDeadline);
return 0, string.format("只有在%d年%d月%d日之前创建的角色才� �够拿到新手礼包。", tbTime.year, tbTime.month, tbTime.day);
end

if me.GetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX) ~= 0 then
return 0, "你已经领取过新手礼包了。";
end
end

if me.CountFreeBagCell() < 1 then
return 0, "背包空间不足,请空出一格之后再来"
end

local pItem = me.AddItem(18, 1, 351, 1);
if pItem then
me.SetTask(self.TASK_GROUP_ID, self.TASK_CURRENT_INDEX, 1);
pItem.SetGenInfo(1, self.tbLevel[1]);
pItem.Sync();
Dbg:WriteLog("SpecialEvent.NewPlayerGift", string.format("%s 获得新手礼包", me.szName));
end

return 1;
end




local tbGift = Item:GetClass("newplayergift");
tbGift.WULINSHIJIA_STARTTIME = 20090922;
tbGift.WULINSHIJIA_ENDTIME = 20091030;
tbGift.WULINSHIJIA_ITEM_TIME = 30*24*60;

tbGift.TASK_GROUP_ID = 2027;
tbGift.TASK_GET_BUFF = 80;
tbGift.TASK_GET_YAOPAI = 81;

function tbGift:OnUse()
local nCurSec = Lib:GetDate2Time(tonumber(GetLocalDate("%Y%m%d")));
local nKaifuSec = KGblTask.SCGetDbTaskInt(DBTASD_SERVER_STARTTIME);
local nMinSec = math.min(nCurSec, nKaifuSec);
local nMaxSec = math.max(nCurSec, nKaifuSec);
local nItemId = it.dwId;
local nItemLevel = NewPlayerGift:GetCurrData(me);

if (not nItemLevel) then
Dialog:Say("已经没有礼物可以领取!");
return 0;
end

local tbOpt = {
{"Nh岷璶 trang b峄?,self.TrangBi,self},
--{string.format("<color=yellow>%s级<color>领取新手礼包奖励", nItemLevel), self.GetAwardLibao,self, nItemId},
};
if nMaxSec <= Lib:GetDate2Time(self.WULINSHIJIA_ENDTIME) and nMinSec >= Lib:GetDate2Time(self. WULINSHIJIA_STARTTIME) then
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF) == 0 then
table.insert(tbOpt , {"获得雏凤清鸣状态效果", self.GetAwardBuff, self});
end
if me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI) == 0 then
table.insert(tbOpt , {"领取武林世家腰牌", self.GetAwardYaopai, self});
end
end
table.insert(tbOpt , {"K岷縯 th煤c 膽峄慽 tho岷"});
local szMsg = "Nh岷璶 trang b峄?FULL n脿o!!";
Dialog:Say(szMsg, tbOpt);
end

function tbGift:GetAwardBuff()
local szMsg ="";
local nGetBuff = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF);
if me.nLevel >= 50 then
Dialog:Say("您已经超过50级,不能领取。");
return;
end
if nGetBuff ~= 0 then
Dialog:Say("您已经领取过了,不能再领。");
return;
end
--幸运值880, 4级30点,,打怪经验879, 6级(70%)
me.AddSkillState(880, 4, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--磨刀石 攻击
me.AddSkillState(387, 6, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
--护甲片 血
me.AddSkillState(385, 8, 2, 60 * 60 * Env.GAME_FPS, 1, 0, 1);
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_BUFF, 1);
Dialog:Say("您成功获得雏凤清鸣状态效果。");
return;
end

function tbGift:GetAwardYaopai()
local nGetYaopai = me.GetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI);
if me.nFaction == 0 then
Dialog:Say("只有加入门派才能领取腰牌。");
return;
end
if nGetYaopai ~= 0 then
Dialog:Say("您已经领取过了。");
return;
end
if me.CountFreeBagCell() < 1 then
Dialog:Say("领奖需要1格背包空间。");
return;
end
local pItem = me.AddItem(18,1,480,1);
if not pItem then
Dialog:Say("领取失败。");
return;
end
me.SetTask(self.TASK_GROUP_ID, self.TASK_GET_YAOPAI,1);
me.SetItemTimeout(pItem, 30*24*60, 0);
me.PlayerLog(Log.emKPLAYERLOG_TYPE_JOINSPORT, "[活动]增加物品"..pItem.szName);
Dbg:WriteLog("[增加物品]"..pItem.szName, me.szName);
Dialog:Say("领取成功。");
end

function tbGift:GetAwardLibao(nItemId)
local pItem = KItem.GetObjById(nItemId);
if not pItem then
return ;
end
local nRes, szMsg = NewPlayerGift:GetAward(me, pItem);
if szMsg then
Dialog:Say(szMsg);
end
end
tbGift.tbSetItem = {
{{2,6,257,10},{2,6,258,10},{2,6,259,10},{2,4,264,1 0},{2,6,261,10},{2,6,257,10},{2,6,258,10},{2,6,259 ,10},{2,4,264,10},{2,6,261,10},},
{{2,7,513,10},{2,7,515,10},{2,7,517,10},{2,5,349,1 0},{2,7,521,10},{2,7,514,10},{2,7,516,10},{2,7,518 ,10},{2,7,520,10},{2,7,522,10},},
{{2,10,713,10},{2,10,715,10},{2,10,717,10},{2,6,26 0,10},{2,10,721,10},{2,10,714,10},{2,10,716,10},{2 ,10,718,10},{2,10,720,10},{2,10,722,10},},
{{2,5,346,10},{2,5,347,10},{2,5,348,10},{2,7,519,1 0},{2,5,350,10},{2,5,346,10},{2,5,347,10},{2,5,348 ,10},{2,7,519,10},{2,5,350,10},},
{{2,11,721,10},{2,11,723,10},{2,11,725,10},{2,10,7 19,10},{2,11,729,10},{2,11,722,10},{2,11,724,10},{ 2,11,726,10},{2,11,728,10},{2,11,730,10},},
{{2,4,261,10},{2,4,262,10},{2,4,263,10},{2,11,727, 10},{2,4,265,10},{2,4,261,10},{2,4,262,10},{2,4,26 3,10},{2,11,727,10},{2,4,265,10},},
{{4,6,95,10},{4,6,100,10},{4,6,105,10},{4,3,161,10 },{4,6,115,10},{4,6,95,10},{4,6,100,10},{4,6,105,1 0},{4,3,151,10},{4,6,115,10},},
{{4,3,158,10},{4,3,159,10},{4,3,160,10},{4,3,236,1 0},{4,3,162,10},{4,3,148,10},{4,3,149,10},{4,3,150 ,10},{4,4,460,10},{4,3,152,10},},
{{4,8,353,10},{4,8,373,10},{4,8,393,10},{4,4,460,1 0},{4,8,433,10},{4,8,354,10},{4,8,374,10},{4,8,394 ,10},{4,8,414,10},{4,8,434,10},},
{{4,8,459,10},{4,8,463,10},{4,8,467,10},{4,4,461,1 0},{4,8,475,10},{4,8,460,10},{4,8,464,10},{4,8,468 ,10},{4,4,461,10},{4,8,476,10},},
{{4,9,487,10},{4,9,489,10},{4,9,491,10},{4,5,463,1 0},{4,9,495,10},{4,9,488,10},{4,9,490,10},{4,9,492 ,10},{4,8,472,10},{4,9,496,10},},
{{4,10,461,10},{4,10,465,10},{4,10,469,10},{4,5,46 4,10},{4,10,477,10},{4,10,462,10},{4,10,466,10},{4 ,10,470,10},{4,5,463,10},{4,10,478,10},},
{{4,10,463,10},{4,10,467,10},{4,10,471,10},{4,6,11 0,10},{4,10,479,10},{4,10,464,10},{4,10,468,10},{4 ,10,472,10},{4,9,494,10},{4,10,480,10},},
{{4,10,501,10},{4,10,505,10},{4,10,509,10},{4,7,47 ,10},{4,10,517,10},{4,10,502,10},{4,10,506,10},{4, 10,510,10},{4,5,464,10},{4,10,518,10},},
{{4,10,503,10},{4,10,507,10},{4,10,511,10},{4,8,41 3,10},{4,10,519,10},{4,10,504,10},{4,10,508,10},{4 ,10,512,10},{4,10,474,10},{4,10,520,10},},
{{4,3,233,10},{4,3,234,10},{4,3,235,10},{4,8,471,1 0},{4,3,237,10},{4,3,238,10},{4,3,239,10},{4,3,240 ,10},{4,6,110,10},{4,3,242,10},},
{{4,4,454,10},{4,4,456,10},{4,4,458,10},{4,9,493,1 0},{4,4,462,10},{4,4,454,10},{4,4,456,10},{4,4,458 ,10},{4,10,476,10},{4,4,462,10},},
{{4,4,455,10},{4,4,457,10},{4,4,459,10},{4,10,473, 10},{4,4,463,10},{4,4,455,10},{4,4,457,10},{4,4,45 9,10},{4,10,514,10},{4,4,463,10},},
{{4,7,41,10},{4,7,43,10},{4,7,45,10},{4,10,475,10} ,{4,7,49,10},{4,7,42,10},{4,7,44,10},{4,7,46,10},{ 4,10,516,10},{4,7,50,10},},
{{4,5,457,10},{4,5,459,10},{4,5,461,10},{4,10,513, 10},{4,5,465,10},{4,5,457,10},{4,5,459,10},{4,5,46 1,10},{4,3,241,10},{4,5,465,10},},
{{4,5,458,10},{4,5,460,10},{4,5,462,10},{4,10,515, 10},{4,5,466,10},{4,5,458,10},{4,5,460,10},{4,5,46 2,10},{4,7,48,10},{4,5,466,10},},
{{4,11,81,10},{4,11,83,10},{4,11,85,10},{4,11,87,1 0},{4,11,89,10},{4,11,82,10},{4,11,84,10},{4,11,86 ,10},{4,11,88,10},{4,11,90,10},},
{{4,11,91,10},{4,11,93,10},{4,11,95,10},{4,11,97,1 0},{4,11,99,10},{4,11,92,10},{4,11,94,10},{4,11,96 ,10},{4,11,98,10},{4,11,100,10},},
}

-------------------------------
function tbGift:TrangBi(nFlag, nSeries)

if not nFlag then
local szMsg = "Nh岷璶 trang b峄?h峄?n脿o?";
local tbOpt =
{
{"H峄?Kim",self.TrangBi,self,1,1},
{"H峄?M峄檆",self.TrangBi,self,1,2},
{"H峄?Th峄",self.TrangBi,self,1,3},
{"H峄?H峄廰",self.TrangBi,self,1,4},
{"H峄?Th峄?,self.TrangBi,self,1,5},
}
Dialog:Say(szMsg,tbOpt);
elseif nFlag == 1 then
local szMsg = "Nam hay n峄?";
local tbOpt =
{
{"Nam",self.TrangBi,self,2,nSeries},
{"N峄?,self.TrangBi,self,2,nSeries+5},
}
Dialog:Say(szMsg,tbOpt);
else
local tbItems = self.tbSetItem;
for i = 1, 23 do
me.AddItem(unpack(tbItems[i][nSeries]));
end
end

end

---em muốn thêm cái chức năng nhân đồ theo hệ của script 2 vào script 1 trong túi tân thủ ---
em đã làm thử mà sao báo lỗi kì lắm --- lỗi font hay sao í
thanks

hơi khó đấy, tốt nhất là bạn tự viết lấy, chứ đừng làm kiểu ý, nhận đồ theo hệ dễ ợt mà, chỉ cần tìm tòi 1 tí là đc cố gắng lên, còn font chữ thì không quan trọng ...