万物创造者
- CN币
- 1 颗
- 威望
- 575
- 贡献
- 793
- UID
- 1
- QQ

- 微信Wechat
- ahsinsoft
- 居住地
- 中国 上海市 杨浦区 定海路街道
|
发表于 2024-11-3 18:10:34
|
显示全部楼层
每日任务模板
- --模块类
- local meiriModule = ModuleBase:createModule('meiri')
- --加载模块钩子
- function meiriModule:onLoad()
- self:logInfo('load')
- --self:regCallback('TalkEvent',Func.bind(self.wanjiashuohua,self))--玩家说话触发
- --NL.RegTalkEvent(nil,'wanjiashuohua')
- meirinpc = self:NPC_createNormal('每日npc',14592,{x=232,y=63,mapType=0,map=1000,direction=6})--创建npc
- self:NPC_regTalkedEvent(meirinpc,Func.bind(self.mianxiangnpc,self))--面向npc触发
- self:NPC_regWindowTalkedEvent(meirinpc,Func.bind(self.ckancf,self))--npc的弹窗的窗口按钮触发
- end
- local qdcs = {}--签到次数表
- local qdr = {}--签到日表
- function meiriModule:mianxiangnpc(meirinpc,player,seq,sel,data)--玩家面向npc时,触发window
- tanchuang(player,meirinpc)
- end
- function tanchuang(player,meirinpc)--自己创建的函数
- local xunxi = "@c\\n\\n\\n"
- ..'\\n你要签到吗?'
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_是否%,player+65465,xunxi)
- end
- function meiriModule:ckancf(meirinpc,player,seq,sel,data)--npc的弹窗的窗口按钮触发
- seq = seq or 0
- sel = sel or 0
- data = data or 0
- --NLG.SystemMessage(player,'seq:'..seq..',sel:'..sel..',data:'..data)
- if seq == player+65465 and sel == 8 then--玩家选了否
- --NLG.SystemMessage(player,'不签到,来找我干嘛?')
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+78075,'@c\\n\\n\\n不签到,来找我干嘛?')
- end
- if seq == player+65465 and sel == 4 then--玩家选了是
- local wanjiaqian = Char.GetData(player,%对象_金币%)
- local wanjiagezi = Char.ItemSlot(player)
- print('玩家道具栏:'..wanjiagezi)
-
- if wanjiaqian > 900000 then
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+198075,'@c\\n\\n\\n你的钱太多了,本次签到失败。')
- return
- end
-
- if wanjiagezi > 18 then
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+208075,'@c\\n\\n\\n你的东西多了,本次签到失败。')
- return
- end
-
- local n,y,r = nyr()
- local nowdate = n..y..r--202485
- nowdate = tonumber(nowdate)
- --签到次数[player] = 0
-
- ::again::
- qdcs[player] = tonumber(Field.Get(player,'签到次数')) or 0--获取到签到次
- qdr[player] = tonumber(Field.Get(player,'签到日')) or 0--获取到签到日
-
- if qdr[player] ~= nowdate then--今天和上一次签到的日子不同
- print('跑到这里了1')
- --如果不同,那么就把次数清零
- --把数据库里签到日改成今天
- Field.Set(player,'签到日',n..y..r)
- Field.Set(player,'签到次数',0)
- goto again
- end
-
- if qdr[player] == nowdate then--今天和上一次签到的日子相同
- print('跑到这里了2')
- --那么就去判断签到次数
- if qdcs[player] == 2 then--判断,签到次数,是不是2
- print('跑到这里了3')
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+88075,'@c\\n\\n\\n你已经签到过2次了。')
- end
-
- if qdcs[player] < 2 then--判断,签到次数是否小于2
- print('跑到这里了4')
- Field.Set(player,'签到日',n..y..r)
- Field.Set(player,'签到次数',qdcs[player] + 1)
- NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+98075,'@c\\n\\n\\n你已经签到成功'..(qdcs[player] + 1)..'次。')
- Char.GiveItem(player,1,2)--给2把刀
- Char.AddGold(player,100000)--给10万
- end
- end
-
-
-
- end
- end
- function nyr()--自定义年月日的功能函数
- local timestamp = os.time() -- 获取当前时间戳
- local date_format = os.date("*t", timestamp) -- 将时间戳转换为日期表(table)
- -- 打印年月日
- print("年:", date_format.year)
- print("月:", date_format.month)
- print("日:", date_format.day)
- local n = tonumber(date_format.year)--2024
- local y = tonumber(date_format.month)--8
- local r = tonumber(date_format.day)--5
- return n,y,r
- end
- --function meiriModule:wanjiashuohua(player,msg)--玩家说话触发
- --
- -- return 1--必须留着
- --end
- --卸载模块钩子
- function meiriModule:onUnload()
- self:logInfo('unload')
- end
- return meiriModule
复制代码
|
|