找回密码
 立即注册
查看: 176|回复: 8

[提问/求助] 求个每日副本lua

[复制链接]
苍之风云

1

主题

67

回帖

224

积分
CN币
0 颗


威望
44

贡献
68

UID
135

QQ
QQ

微信Wechat
420400121

居住地
中国

发表于 2024-11-3 08:32:08 | 显示全部楼层 |阅读模式
可以设定每日可打几次哪种第二天自动刷新次数的
万物创造者

189

主题

207

回帖

2345

积分
CN币
1 颗


威望
575

贡献
793

UID
1

QQ
QQ

微信Wechat
ahsinsoft

居住地
中国 上海市 杨浦区 定海路街道

发表于 2024-11-3 15:03:30 | 显示全部楼层
你目前技术如何,方案有,你自己会改吗
苍之风云

1

主题

67

回帖

224

积分
CN币
0 颗


威望
44

贡献
68

UID
135

QQ
QQ

微信Wechat
420400121

居住地
中国

 楼主| 发表于 2024-11-3 16:00:26 | 显示全部楼层
ahsin 发表于 2024-11-3 15:03
你目前技术如何,方案有,你自己会改吗

刚开始学 看你视频一点点学呢
万物创造者

189

主题

207

回帖

2345

积分
CN币
1 颗


威望
575

贡献
793

UID
1

QQ
QQ

微信Wechat
ahsinsoft

居住地
中国 上海市 杨浦区 定海路街道

发表于 2024-11-3 18:10:34 | 显示全部楼层
每日任务模板

  1. --模块类
  2. local meiriModule = ModuleBase:createModule('meiri')

  3. --加载模块钩子
  4. function meiriModule:onLoad()
  5.         self:logInfo('load')
  6.         --self:regCallback('TalkEvent',Func.bind(self.wanjiashuohua,self))--玩家说话触发
  7.         --NL.RegTalkEvent(nil,'wanjiashuohua')
  8.         meirinpc = self:NPC_createNormal('每日npc',14592,{x=232,y=63,mapType=0,map=1000,direction=6})--创建npc
  9.         self:NPC_regTalkedEvent(meirinpc,Func.bind(self.mianxiangnpc,self))--面向npc触发
  10.         self:NPC_regWindowTalkedEvent(meirinpc,Func.bind(self.ckancf,self))--npc的弹窗的窗口按钮触发
  11. end

  12. local qdcs = {}--签到次数表
  13. local qdr = {}--签到日表

  14. function meiriModule:mianxiangnpc(meirinpc,player,seq,sel,data)--玩家面向npc时,触发window
  15.         tanchuang(player,meirinpc)
  16. end

  17. function tanchuang(player,meirinpc)--自己创建的函数
  18.         local xunxi = "@c\\n\\n\\n"
  19.         ..'\\n你要签到吗?'
  20.         NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_是否%,player+65465,xunxi)
  21. end

  22. function meiriModule:ckancf(meirinpc,player,seq,sel,data)--npc的弹窗的窗口按钮触发
  23.         seq = seq or 0
  24.         sel = sel or 0
  25.         data = data or 0
  26.         --NLG.SystemMessage(player,'seq:'..seq..',sel:'..sel..',data:'..data)
  27.         if seq == player+65465 and sel == 8 then--玩家选了否
  28.                 --NLG.SystemMessage(player,'不签到,来找我干嘛?')
  29.                 NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+78075,'@c\\n\\n\\n不签到,来找我干嘛?')
  30.         end
  31.         if seq == player+65465 and sel == 4 then--玩家选了是
  32.                 local wanjiaqian = Char.GetData(player,%对象_金币%)
  33.                 local wanjiagezi = Char.ItemSlot(player)
  34.                 print('玩家道具栏:'..wanjiagezi)
  35.                
  36.                 if wanjiaqian > 900000 then
  37.                         NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+198075,'@c\\n\\n\\n你的钱太多了,本次签到失败。')
  38.                         return
  39.                 end
  40.                
  41.                 if wanjiagezi > 18 then
  42.                         NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+208075,'@c\\n\\n\\n你的东西多了,本次签到失败。')
  43.                         return
  44.                 end
  45.                
  46.                 local n,y,r = nyr()
  47.                 local nowdate = n..y..r--202485
  48.                 nowdate = tonumber(nowdate)
  49.                 --签到次数[player] = 0
  50.                
  51.                 ::again::
  52.                 qdcs[player] = tonumber(Field.Get(player,'签到次数')) or 0--获取到签到次
  53.                 qdr[player] = tonumber(Field.Get(player,'签到日')) or 0--获取到签到日
  54.                
  55.                 if qdr[player] ~= nowdate then--今天和上一次签到的日子不同
  56.                 print('跑到这里了1')
  57.                         --如果不同,那么就把次数清零
  58.                         --把数据库里签到日改成今天
  59.                         Field.Set(player,'签到日',n..y..r)
  60.                         Field.Set(player,'签到次数',0)
  61.                         goto again
  62.                 end
  63.                
  64.                 if qdr[player] == nowdate then--今天和上一次签到的日子相同
  65.                         print('跑到这里了2')
  66.                         --那么就去判断签到次数
  67.                         if qdcs[player] == 2 then--判断,签到次数,是不是2
  68.                         print('跑到这里了3')
  69.                                 NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+88075,'@c\\n\\n\\n你已经签到过2次了。')
  70.                         end
  71.                        
  72.                         if qdcs[player] < 2 then--判断,签到次数是否小于2
  73.                         print('跑到这里了4')
  74.                                 Field.Set(player,'签到日',n..y..r)
  75.                                 Field.Set(player,'签到次数',qdcs[player] + 1)
  76.                                 NLG.ShowWindowTalked(player,meirinpc,%窗口_信息框%,%按钮_关闭%,player+98075,'@c\\n\\n\\n你已经签到成功'..(qdcs[player] + 1)..'次。')
  77.                                 Char.GiveItem(player,1,2)--给2把刀
  78.                                 Char.AddGold(player,100000)--给10万
  79.                         end
  80.                 end
  81.                
  82.                
  83.                
  84.         end
  85. end

  86. function nyr()--自定义年月日的功能函数
  87. local timestamp = os.time()  -- 获取当前时间戳
  88. local date_format = os.date("*t", timestamp)  -- 将时间戳转换为日期表(table)
  89. -- 打印年月日
  90. print("年:", date_format.year)
  91. print("月:", date_format.month)
  92. print("日:", date_format.day)

  93. local n = tonumber(date_format.year)--2024
  94. local y = tonumber(date_format.month)--8
  95. local r = tonumber(date_format.day)--5

  96. return n,y,r
  97. end


  98. --function meiriModule:wanjiashuohua(player,msg)--玩家说话触发
  99. --
  100. --         return 1--必须留着
  101. --end

  102. --卸载模块钩子
  103. function meiriModule:onUnload()
  104.   self:logInfo('unload')
  105. end

  106. return meiriModule
复制代码


苍之风云

1

主题

67

回帖

224

积分
CN币
0 颗


威望
44

贡献
68

UID
135

QQ
QQ

微信Wechat
420400121

居住地
中国

 楼主| 发表于 2024-11-3 19:58:31 | 显示全部楼层

谢谢  我学着改改
圣洁的灵魂 [SVIP]

14

主题

26

回帖

2106

积分
CN币
76 颗


威望
693

贡献
599

UID
284

QQ
QQ



发表于 2024-11-6 23:13:40 | 显示全部楼层


这个应该比较符合需求


  1. --模块类
  2. local Module = ModuleBase:createModule('taskWarp')

  3. local count_Max = 2;                --副本次数
  4. --副本分类
  5. local warp_map_name = {};
  6. local warp_map_point = {};
  7. local warp_map_lvlimit = {};
  8. local warp_map_payfor = {};
  9. --剩余次数计算
  10. local warp_map_daily_user = {};
  11. local warp_map_daily_user_count = {};
  12. warp_map_daily_user_count[1] = {};        --个次数计算
  13. warp_map_daily_user_count[2] = {};        --个次数计算
  14. warp_map_daily_user_count[3] = {};        --个次数计算
  15. warp_map_daily_user_count[4] = {};        --个次数计算
  16. warp_map_daily_user_count[5] = {};        --个次数计算
  17. warp_map_daily_user_count[6] = {};        --个次数计算

  18. warp_map_name[1] = "十二星座副本";
  19. warp_map_point[1] = {7324,10,14};
  20. warp_map_lvlimit[1] = 100;
  21. warp_map_payfor[1] = 20000;

  22. warp_map_name[2] = "機甲魔獸";
  23. warp_map_point[2] = {7339,22,26};
  24. warp_map_lvlimit[2] = 150;
  25. warp_map_payfor[2] = 20000;

  26. warp_map_name[3] = "機甲靈裝";
  27. warp_map_point[3] = {7340,22,26};
  28. warp_map_lvlimit[3] = 150;
  29. warp_map_payfor[3] = 20000;

  30. warp_map_name[4] = "暗黑勢力";
  31. warp_map_point[4] = {7341,16,20};
  32. warp_map_lvlimit[4] = 150;
  33. warp_map_payfor[4] = 20000;

  34. warp_map_name[5] = "海之窟";
  35. warp_map_point[5] = {20262,41,4};
  36. warp_map_lvlimit[5] = 150;
  37. warp_map_payfor[5] = 20000;

  38. warp_map_name[6] = "陸之窟";
  39. warp_map_point[6] = {20263,10,4};
  40. warp_map_lvlimit[6] = 150;
  41. warp_map_payfor[6] = 20000;

  42. ------------------------------------------------------------------------------------------------------------------------
  43. --功能函数
  44. function Time_Check(_obj)        --判定是否一天时间已过
  45.         if (os.date("%d",_obj) ~= os.date("%d",os.time())) then
  46.                 return true;
  47.         end
  48.         return false;
  49. end

  50. function Time_Out(player)        --每日24点为判定超时
  51.         local _obj = warp_map_daily_user[Playerkey(player)];
  52.         --如果首次登录
  53.         if (_obj == nil) then
  54.                 warp_map_daily_user[Playerkey(player)] = os.time();
  55.                 return true;
  56.         else
  57.                 return Time_Check(_obj);
  58.         end
  59. end

  60. function Playerkey(player)
  61.         if (player ~= nil) then
  62.                 local fanhui1 = Char.GetData(player,CONST.CHAR_名字);
  63.                 local fanhui2 = Char.GetData(player,CONST.CHAR_CDK);
  64.                 if (fanhui1 == nil or fanhui2 == nil) then
  65.                         if(fanhui2 == nil) then
  66.                                 fanhui2 = "bus"
  67.                         end
  68.                 end
  69.                 return fanhui1..fanhui2;
  70.         else
  71.                 return 1;
  72.         end
  73. end

  74. function mykgold(player,gold)
  75.         local tjb = Char.GetData(player,CONST.对象_金币);
  76.         tjb = tjb - gold;
  77.         if (tjb >= 0) then
  78.                 Char.SetData(player,CONST.对象_金币,tjb);
  79.                 NLG.UpChar(player);
  80.                 NLG.SystemMessage(player,"交出了"..gold.." G魔幣。");
  81.                 return true;
  82.         end
  83.         return false;
  84. end

  85. ------------------------------------------------------------------------------------------------------------------------
  86. --加载模块
  87. function Module:onLoad()
  88.         self:logInfo('load')
  89.         local warpNPC = self:NPC_createNormal('副本管理员',14063,{x=226, y=84, mapType=0, map=1000, direction=6})
  90.         self:NPC_regWindowTalkedEvent(warpNPC,Func.bind(self.click,self))
  91.         self:NPC_regTalkedEvent(warpNPC,Func.bind(self.facetonpc,self))
  92. end

  93. local function calcWarp()--计算翻页
  94.         local page = math.modf(#warp_map_name/8) + 1
  95.         local remainder = math.fmod(#warp_map_name,8)
  96.         return page,remainder
  97. end

  98. function Module:click(npc,player,_seqno,_select,_data)--窗口中点击触发
  99.         local column = tonumber(_data)
  100.         local page = tonumber(_seqno)
  101.         local warpPage = page;
  102.         if (page==1000) then        --回到主菜单
  103.                 self:facetonpc(npc, player);
  104.                 return;
  105.         end

  106.         local winMsg = "1|\\n這裡是副本管理系統,你...要去哪裡...讀取中...\\n";
  107.         local winButton = CONST.BUTTON_关闭;
  108.         local totalPage, remainder = calcWarp()
  109.         --上页16 下页32 取消2
  110.         if _select > 0 then
  111.                 --多页按钮
  112.                 if _select == 32 then
  113.                         warpPage = warpPage + 1
  114.                         if (warpPage == totalPage) or (warpPage == (totalPage - 1) and remainder == 0) then
  115.                                 winButton = 18        --上取消
  116.                         else
  117.                                 winButton = 50        --上下取消
  118.                         end
  119.                 elseif _select == 16 then
  120.                         warpPage = warpPage - 1
  121.                         if warpPage == 1 then
  122.                                 winButton = 34        --下取消
  123.                         else
  124.                                 winButton = 50        --上下取消
  125.                         end
  126.                 elseif _select == 2 then
  127.                         warpPage = 1
  128.                         return
  129.                 end
  130.                 --副本次数计算
  131.                 if (Time_Out(player)) then
  132.                         warp_map_daily_user[Playerkey(player)] = os.time();
  133.                         for i=1,#warp_map_daily_user_count do                        --每日副本个别次数
  134.                                 warp_map_daily_user_count[i][Playerkey(player)] = nil;
  135.                         end
  136.                 end
  137.                 --多页内容
  138.                 local count = 8 * (warpPage - 1)
  139.                 if warpPage == totalPage then
  140.                         for i = 1 + count, remainder + count do
  141.                                 local tcount = warp_map_daily_user_count[i][Playerkey(player)];
  142.                                 if (tcount == nil) then
  143.                                         tcount = count_Max;
  144.                                 else
  145.                                         tcount = count_Max - tcount;
  146.                                 end
  147.                                 winMsg = winMsg .. " "..warp_map_name[i].."   <金額"..warp_map_payfor[i].."G>  剩餘<"..tcount..">次\\n"
  148.                         end
  149.                 else
  150.                         for i = 1 + count, 8 + count do
  151.                                 local tcount = warp_map_daily_user_count[i][Playerkey(player)];
  152.                                 if (tcount == nil) then
  153.                                         tcount = count_Max;
  154.                                 else
  155.                                         tcount = count_Max - tcount;
  156.                                 end
  157.                                 winMsg = winMsg .. " "..warp_map_name[i].."   <金額"..warp_map_payfor[i].."G>  剩餘<"..tcount..">次\\n"
  158.                         end
  159.                 end
  160.                 NLG.ShowWindowTalked(player,npc,CONST.窗口_选择框, winButton, warpPage, winMsg);
  161.         else
  162.                 if (_seqno == 1 and select == CONST.按钮_关闭) then
  163.                         return;
  164.                 elseif (_seqno == 1 and column >= 1) then
  165.                         --local selectitem = tonumber(_data);
  166.                         local count = 8 * (warpPage - 1) + column;

  167.                         local getlvlit = warp_map_lvlimit[count];
  168.                         if (getlvlit > Char.GetData(player,CONST.CHAR_等级)) then        --等级判定
  169.                                 NLG.SystemMessage(player, "您的等級不夠,"..getlvlit.."級再來吧!");
  170.                                 return;
  171.                         end
  172.                         if (Char.PartyNum(player)>1) then                        --组队判定
  173.                                 NLG.SystemMessage(player, "[系統]副本須要單人進行傳送!!");
  174.                                 return;
  175.                         end

  176.                         local getcountless = warp_map_daily_user_count[count][Playerkey(player)];
  177.                         if (getcountless ==nil) then
  178.                                 getcountless = 0;
  179.                                 warp_map_daily_user_count[count][Playerkey(player)] = 0;
  180.                         end
  181.                         if (getcountless >= count_Max) then
  182.                                 local msg = "\\n\\n\\n@c您的次數已經用完了。"
  183.                                 NLG.ShowWindowTalked(player,npc,CONST.窗口_信息框,CONST.按钮_关闭, 1000, msg);
  184.                                 return;
  185.                         end

  186.                         if (mykgold(player, warp_map_payfor[count])) then
  187.                                 warp_map_daily_user_count[count][Playerkey(player)] = getcountless + 1;
  188.                                 Char.DischargeParty(player);
  189.                                 Char.Warp(player,0, warp_map_point[count][1], warp_map_point[count][2], warp_map_point[count][3]);
  190.                         else
  191.                                 NLG.SystemMessage(player, "\\n\\n\\n您的魔幣不夠。");
  192.                                 return;
  193.                         end
  194.                 end
  195.         end
  196. end

  197. function Module:facetonpc(npc,player)
  198.         if NLG.CanTalk(npc,player) == true then
  199.                 if (Time_Out(player)) then
  200.                         warp_map_daily_user[Playerkey(player)] = os.time();
  201.                         for i=1,#warp_map_daily_user_count do                        --每日副本个别次数
  202.                                 warp_map_daily_user_count[i][Playerkey(player)] = nil;
  203.                         end
  204.                 end

  205.                 local winMsg = "1|\\n這裡是副本管理系統,你...要去哪裡...讀取中...\\n";
  206.                 for i=1, 6 do
  207.                         local tcount = warp_map_daily_user_count[i][Playerkey(player)];
  208.                         if (tcount == nil) then
  209.                                 tcount = count_Max;
  210.                         else
  211.                                 tcount = count_Max - tcount;
  212.                         end
  213.                         --对齐格式
  214.                         local name_len = #warp_map_name[i];
  215.                         if (name_len < 12) then
  216.                                 name_spacelen = 12 - name_len;
  217.                                 name_spaceMsg = " ";
  218.                                 for k = 1, math.modf(name_spacelen) do
  219.                                         name_spaceMsg = name_spaceMsg .." ";
  220.                                 end
  221.                         else
  222.                                 name_spaceMsg = " ";
  223.                         end
  224.                         winMsg = winMsg .. " "..warp_map_name[i].. name_spaceMsg .."<金額"..warp_map_payfor[i].."G> 剩餘<"..tcount..">次\\n";
  225.                 end
  226.                 NLG.ShowWindowTalked(player,npc,CONST.窗口_选择框,CONST.按钮_关闭, 1, winMsg);
  227.         end
  228.         return
  229. end

  230. --卸载模块
  231. function Module:onUnload()
  232.         self:logInfo('unload')
  233. end
  234. return Module
复制代码


苍之风云

1

主题

67

回帖

224

积分
CN币
0 颗


威望
44

贡献
68

UID
135

QQ
QQ

微信Wechat
420400121

居住地
中国

 楼主| 发表于 2024-11-7 13:48:37 | 显示全部楼层
xman 发表于 2024-11-6 23:13
这个应该比较符合需求

感谢大佬
苍之风云

1

主题

80

回帖

438

积分
CN币
5 颗


威望
135

贡献
82

UID
276

QQ
QQ

微信Wechat
yuhan

居住地
中国

发表于 2024-11-11 09:54:49 | 显示全部楼层
多谢大佬技术支持
万物创造者

189

主题

207

回帖

2345

积分
CN币
1 颗


威望
575

贡献
793

UID
1

QQ
QQ

微信Wechat
ahsinsoft

居住地
中国 上海市 杨浦区 定海路街道

发表于 2025-4-5 21:49:17 | 显示全部楼层
最新日交互npc脚本拓展
http://bbs.cnmlb.com:233/thread-310-1-1.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|CN魔力实验室

GMT+8, 2025-4-28 07:10 , Processed in 0.042242 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表