开服主机32/月起点击投放广告百度网盘18/月
服务器88元/月起点击投放广告点击投放广告
1234下一页
返回列表 发布新帖
查看: 7447|回复: 50

[教程] 自用DOF插件DP代码

739

主题

31

回帖

2万

积分

管理员

黄金
22
银两
1038699
金币
21570 个

耳熟能详TGL尊享TGL亲王TGL龙年限定

发表于 2022-9-16 13:30:22 | 显示全部楼层 |阅读模式
  1. ---@type DP
  2. local dp = _DP
  3. ---@type DPXGame
  4. local dpx = _DPX

  5. local game = require("df.game")
  6. local logger = require("df.logger")
  7. local luv = require("luv")
  8. local luasql = require("luasql.mysql")

  9. logger.info("opt: %s", dpx.opt())
  10. local item_handler = { }
  11. -- see dp2/lua/df/doc for document !

  12. -- 记录在线情况
  13. local online = {}

  14. -- 以下是跨界石代码 只要在背包装备栏的第一格,无论什么品级都可以被转移(不用就删掉这一大段)!
  15. item_handler[123001] = function(user, item_id)
  16.     if not user:MoveToAccCargo(game.ItemSpace.INVENTORY, 9) then
  17.         dpx.item.add(user.cptr, item_id)
  18.     end
  19. end
  20. -- 以上是跨界石代码 只要在背包装备栏的第一格,无论什么品级都可以被转移(不用就删掉这一大段)!

  21. -- 以下是异界2 次数重置券(不用就删掉这一大段)!
  22. item_handler[123002] = function(user, item_id)
  23.     user:ResetDimensionInout(0)
  24.     user:ResetDimensionInout(1)
  25.     user:ResetDimensionInout(2)
  26. end
  27. -- 以下是异界3 次数重置券(不用就删掉这一大段)!
  28. item_handler[123003] = function(user, item_id)
  29.     user:ResetDimensionInout(3)
  30.     user:ResetDimensionInout(4)
  31.     user:ResetDimensionInout(5)
  32. end

  33. ---------------------------------- 以下代码是装备继承券,不需要就删除-------------------------------- !
  34. --[[
  35. 装备继承券
  36. 仿照7576新建一个道具, 删除[string data]节, 以实现一个可以在城镇中使用后毫无效果的道具
  37. 将装备背包中的第一格道具的强化/增幅继承到第二格道具上
  38. ]]
  39. item_handler[123004] = function(user, item_id)
  40.     local mask = game.InheritMask.FLAG_UPGRADE | game.InheritMask.FLAG_AMPLIFY
  41.     mask = mask | game.InheritMask.FLAG_MOVE_UPGRADE | game.InheritMask.FLAG_MOVE_AMPLIFY

  42.     if not dpx.item.inherit(user.cptr, 9, 10, mask) then
  43.         dpx.item.add(user.cptr, item_id)
  44.     end
  45. end


  46. -- 以下是主线任务完成券代码 自动完成符合等级的主线任务(不用就删掉这一大段)!
  47. item_handler[123005] = function(user, item_id)
  48.     local quest = dpx.quest
  49.     local lst = quest.all(user.cptr)
  50.     local chr_level = user:GetCharacLevel()
  51.     --下面{}内写要排除的任务编号即可,就不会自动完成如下编号的任务,例子是辅助装备魔法石
  52.     local evade_lst = {}
  53.     for i, v in ipairs(lst) do
  54.         for j, w in ipairs(evade_lst) do
  55.             if v == w then
  56.                 table.remove(lst, i)
  57.             end
  58.         end
  59.     end
  60.     for i, v in ipairs(lst) do
  61.         local id = v
  62.         local info = quest.info(user.cptr, id)
  63.         if info then
  64.             if not info.is_cleared and info.type == game.QuestType.epic and info.min_level <= chr_level then
  65.                 quest.clear(user.cptr, id)
  66.             end
  67.         end
  68.     end
  69.     quest.update(user.cptr)
  70. end
  71. -- 以上是任务完成券代码 自动完成符合等级的主线任务(不用就删掉这一大段)!

  72. -- 以下是普通任务完成券代码 自动完成符合等级的普通任务(不用就删掉这一大段)!
  73. item_handler[123006] = function(user, item_id)
  74.     local quest = dpx.quest
  75.     local lst = quest.all(user.cptr)
  76.     local chr_level = user:GetCharacLevel()
  77.     --下面{}内写要排除的任务编号即可,就不会自动完成如下编号的任务,例子是辅助装备魔法石
  78.     local evade_lst = { 2708, 2710, 2712, 2702 }
  79.     for i, v in ipairs(lst) do
  80.         for j, w in ipairs(evade_lst) do
  81.             if v == w then
  82.                 table.remove(lst, i)
  83.             end
  84.         end
  85.     end
  86.     for i, v in ipairs(lst) do
  87.         local id = v
  88.         local info = quest.info(user.cptr, id)
  89.         if info then
  90.             if not info.is_cleared and info.type == game.QuestType.common_unique and info.min_level <= chr_level then
  91.                 quest.clear(user.cptr, id)
  92.             end
  93.         end
  94.     end
  95.     quest.update(user.cptr)
  96. end
  97. -- 以上是任务完成券代码 自动完成符合等级的普通任务(不用就删掉这一大段)!

  98. -- 以下是宠物删除券代码 删除宠物前2栏(不用就删掉这一大段)!
  99. item_handler[123007] = function(user, item_id)
  100.     for i = 0, 13, 1 do
  101.         local info = dpx.item.info(user.cptr, game.ItemSpace.CREATURE, i)
  102.         if info then
  103.             logger.info(string.format("will delete [iteminfo] id: %d count: %d name: %s attach: %d",
  104.                     info.id, info.count, info.name, info.attach_type))
  105.             dpx.item.delete(user.cptr, game.ItemSpace.CREATURE, i)
  106.         end
  107.     end
  108.     user:SendItemSpace(game.ItemSpace.CREATURE)
  109.     user:SendNotiPacketMessage("\n已清理宠物前2栏!", 1)
  110. end
  111. -- 以下是宠物删除券代码 删除宠物前2栏(不用就删掉这一大段)!

  112. -- 副职业一键分解券 需要学习分解师副职
  113. item_handler[123008] = function(user, item_id)
  114.     dpx.item.add(user.cptr, item_id)
  115.     for i = 9, 100, 1 do
  116.         local info = dpx.item.info(user.cptr, game.ItemSpace.INVENTORY, i)
  117.         if info then
  118.             logger.info(string.format("will Disjoint [iteminfo] id: %d count: %d name: %s attach: %d",
  119.                     info.id, info.count, info.name, info.attach_type))
  120.             user:Disjoint(game.ItemSpace.INVENTORY, i, user)
  121.         end
  122.     end
  123.     user:SendItemSpace(game.ItemSpace.INVENTORY)
  124. end

  125. -- 以下是20级直升券代码 升到20级并清理前19级任务,可在20级前任意一级使用(不用就删掉这一大段)!
  126. item_handler[123009] = function(user, item_id)
  127.     local currentLevel = user:GetCharacLevel()
  128.     if currentLevel >= 20 then
  129.         dpx.item.add(user.cptr, item_id)
  130.         user:SendNotiPacketMessage("\n当前用户已满20级,无法使用20级直升券!", 1)
  131.     else
  132.         for i = currentLevel, 18, 1 do
  133.             user:AddCharacExpPercent(1)
  134.         end
  135.         logger.info(string.format("%d 升到19级", user:GetCharacNo()))
  136.         local quest = dpx.quest
  137.         local lst = quest.all(user.cptr)
  138.         local chr_level = user:GetCharacLevel()
  139.         --下面{}内写要排除的任务编号即可,就不会自动完成如下编号的任务,例子是辅助装备魔法石
  140.         local evade_lst = {}
  141.         for i, v in ipairs(lst) do
  142.             for j, w in ipairs(evade_lst) do
  143.                 if v == w then
  144.                     table.remove(lst, i)
  145.                 end
  146.             end
  147.         end
  148.         for i, v in ipairs(lst) do
  149.             local id = v
  150.             local info = quest.info(user.cptr, id)
  151.             if info then
  152.                 if not info.is_cleared and info.type == game.QuestType.epic and info.min_level <= chr_level then
  153.                     quest.clear(user.cptr, id)
  154.                 end
  155.             end
  156.         end
  157.         quest.update(user.cptr)
  158.         logger.info(string.format("%d 19级主线清理完成", user:GetCharacNo()))
  159.         user:AddCharacExpPercent(1)
  160.         logger.info(string.format("%d 升到20级", user:GetCharacNo()))
  161.     end
  162. end
  163. -- 以下是20级直升券代码 升到20级并清理前19级任务(不用就删掉这一大段)!

  164. -- 以下是懸賞令 - 牛頭械王 强制接取懸賞令 - 牛頭械王任务(不用就删掉这一大段)!
  165. item_handler[512489248] = function(user, item_id)
  166.     dpx.quest.accept(user, 1289, true)
  167.     dpx.quest.update(user)
  168. end
  169. -- 以下是懸賞令 - 牛頭械王 强制接取懸賞令 - 牛頭械王任务(不用就删掉这一大段)!

  170. -- 物品回收券 无限使用
  171. item_handler[2021121904] = function(user, item_id)
  172.     dpx.item.add(user.cptr, item_id)
  173.     local env = luasql.mysql()
  174.     local conn = env:connect("dp2", "game", "uu5!^%jg", "127.0.0.1", 3306)
  175.     conn:execute "SET NAMES latin1"
  176.     -- 宠物回收
  177.     -- 宠物装备回收
  178.     for i = 140, 280, 1 do
  179.         local info = dpx.item.info(user.cptr, game.ItemSpace.CREATURE, i)
  180.         if info then
  181.             logger.info(string.format("%d will CREATURE [iteminfo] id: %d count: %d name: %s attach: %d", i, info.id, info.count, info.name, info.attach_type))
  182.             cur = conn:execute(string.format("select return_id from recycle_item_dict where item_id=%d", info.id));
  183.             row = cur:fetch({}, "a");
  184.             while row do
  185.                 logger.info(string.format("%d will CREATURE [iteminfo] id: %d count: %d name: %s attach: %d return_id %d", i, info.id, info.count, info.name, info.attach_type, row.return_id))
  186.                 dpx.item.add(user.cptr, row.return_id)
  187.                 dpx.item.delete(user.cptr, game.ItemSpace.CREATURE, i)
  188.                 row = cur:fetch(row, "a")
  189.             end
  190.         end
  191.     end
  192.     -- 时装回收
  193.     -- 徽章回收
  194.     -- 装备回收
  195.     user:SendItemSpace(game.ItemSpace.CREATURE)
  196.     conn:close()
  197.     env:close()
  198. end

  199. local my_useitem2 = function(_user, item_id)
  200.     local user = game.fac.user(_user)
  201.     local handler = item_handler[item_id]
  202.     if handler then
  203.         handler(user, item_id)
  204.         logger.info("[useitem] acc: %d chr: %d item_id: %d", user:GetAccId(), user:GetCharacNo(), item_id)
  205.     end
  206. end

  207. -- 聊天框GM功能
  208. local on_input = function(next, _user, input)
  209.     local user = game.fac.user(_user)
  210.     local env = luasql.mysql()
  211.     local conn = env:connect("taiwan_billing", "game", "uu5!^%jg", "127.0.0.1", 3306)
  212.     conn:execute "SET NAMES latin1"
  213.     logger.info("INPUT|%d|%s|%s", user:GetAccId(), user:GetCharacName(), input)
  214.     if input == "//expert_job_lv_max" then
  215.         --todo 缺少是否学习副职业的判断
  216.         conn:execute(string.format("update taiwan_cain.charac_stat set expert_job_exp=2054 where charac_no=%d",
  217.                 user:GetCharacNo()))
  218.         user:SendNotiPacketMessage("\n机器人已为您将副职业提升至满级,请重新登录!", 1)
  219.         return 0
  220.     elseif input == "//g" then
  221.         user:SendNotiPacketMessage("==========机器人指令大全==========", 1)
  222.         user:SendNotiPacketMessage("1.开启原始台服GM //open_gm", 1)
  223.         user:SendNotiPacketMessage("2.发送点券 //cash 数量 (默认发送100w点券)", 1)
  224.         user:SendNotiPacketMessage("3.解除地图难度限制 //open_all_dungeon", 1)
  225.         user:SendNotiPacketMessage("4.解除角色创建限制 //open_create_limit", 1)
  226.         user:SendNotiPacketMessage("5.副职业满级 //expert_job_lv_max", 1)
  227.         user:SendNotiPacketMessage("6.设置pvp等级 //set_pvp_lv 等级 (0-34,默认设置为29 即至尊10)", 1)
  228.         user:SendNotiPacketMessage("7.开启活动 //start_event 活动编号 (默认开启泡点活动)", 1)
  229.         user:SendNotiPacketMessage("8.关闭活动 //stop_event 活动编号 (默认关闭泡点活动)", 1)
  230.         user:SendNotiPacketMessage("9.关闭原始台服GM //close_gm", 1)
  231.         user:SendNotiPacketMessage("10.清理时装 //clean_avatar 格数 (默认清理前2栏)", 1)
  232.         user:SendNotiPacketMessage("11.查询物品代码 //itemcode 物品名", 1)
  233.         user:SendNotiPacketMessage("12.发送物品 //send_item 物品代码 数量", 1)
  234.         user:SendNotiPacketMessage("==========机器人指令大全==========", 1)
  235.         return 0
  236.     elseif string.startWith(input, "//cash") then
  237.         local cashInfoList = string.split(input, " ")
  238.         if #cashInfoList >= 2 then
  239.             local cashInfo = tonumber(cashInfoList[2])
  240.             conn:execute(string.format("update taiwan_billing.cash_cera set cera=cera+%d where account = %d",
  241.                     cashInfo, user:GetAccId()))
  242.             user:SendNotiPacketMessage(string.format("\n机器人已为您发送点券%d,请查收!", cashInfo), 1)
  243.         else
  244.             conn:execute(string.format("update taiwan_billing.cash_cera set cera=cera+%d where account = %d",
  245.                     1000000, user:GetAccId()))
  246.             user:SendNotiPacketMessage("\n机器人已为您发送点券100万,请查收!", 1)
  247.         end
  248.         return 0
  249.     elseif input == "//open_all_dungeon" then
  250.         conn:execute(string.format("update taiwan_cain.member_dungeon set dungeon='2|3,3|3,4|3,5|3,6|3,7|3,8|3,9|3,11|3,12|3,13|3,14|3,15|3,17|3,21|3,22|3,23|3,24|3,25|3,26|3,27|3,31|3,32|3,33|3,34|3,35|3,36|3,37|3,40|3,42|3,43|3,44|3,45|3,50|3,51|3,52|3,53|3,60|3,61|3,65|2,66|1,67|2,70|3,71|3,72|3,73|3,74|3,75|3,76|3,77|3,80|3,81|3,82|3,83|3,84|3,85|3,86|3,87|3,88|3,89|3,90|3,91|2,92|3,93|3,100|3,101|3,102|3,103|3,104|3,110|3,111|3,112|3,140|3,141|3,502|3,511|3,521|3,1000|3,1500|3,1501|3,1502|3,1504|1,1506|3,3506|3,10000|3' where m_id=%d",
  251.                 user:GetAccId()))
  252.         user:SendNotiPacketMessage("\n机器人已为您解除地图难度限制,请重新登录!", 1)
  253.         return 0
  254.     elseif input == "//open_create_limit" then
  255.         conn:execute(string.format("update d_taiwan.limit_create_character set count=2 where count> 0 and m_id=%d",
  256.                 user:GetAccId()))
  257.         user:SendNotiPacketMessage("\n机器人已为您暂时解除角色创建限制,可再创建2次角色,请重新登录!", 1)
  258.         return 0
  259.     elseif string.startWith(input, "//set_pvp_lv") then
  260.         local pvpInfoList = string.split(input, " ")
  261.         if #pvpInfoList >= 2 then
  262.             local pvpLevel = tonumber(pvpInfoList[2])
  263.             if pvpLevel >= 0 and pvpLevel <= 34 then
  264.                 conn:execute(string.format("UPDATE taiwan_cain.pvp_result t SET t.pvp_grade = %d WHERE t.charac_no=%d",
  265.                         pvpLevel,
  266.                         user:GetCharacNo()))
  267.                 user:SendNotiPacketMessage(string.format("\n机器人已为您设置pvp等级为%d,请重新登录!",
  268.                         pvpLevel), 1)
  269.             else
  270.                 user:SendNotiPacketMessage(string.format("\n命令输出错误 请按照(//set_pvp_lv 20)格式输入!",
  271.                         pvpLevel), 1)
  272.             end
  273.         else
  274.             conn:execute(string.format("UPDATE taiwan_cain.pvp_result t SET t.pvp_grade = 29 WHERE t.charac_no=%d",
  275.                     pvpLevel,
  276.                     user:GetCharacNo()))
  277.             user:SendNotiPacketMessage(string.format("\n机器人已为您设置pvp等级至尊10,请重新登录!",
  278.                     pvpLevel), 1)
  279.         end
  280.         return 0
  281.     elseif input == "//start_event" then
  282.         -- todo 解析活动编号
  283.         conn:execute(string.format("UPDATE dp2.event t SET t.status = 1 WHERE t.id=1",
  284.                 user:GetCharacNo()))
  285.         user:SendNotiPacketMessage("\n机器人已开启泡点活动,请保持登录获取福利!", 1)
  286.         return 0
  287.     elseif input == "//stop_event" then
  288.         -- todo 解析活动编号
  289.         conn:execute(string.format("UPDATE dp2.event t SET t.status = 0 WHERE t.id=1",
  290.                 user:GetCharacNo()))
  291.         user:SendNotiPacketMessage("\n机器人已关闭泡点活动,感谢您的持续支持!", 1)
  292.         return 0
  293.     elseif input == "//open_gm" then
  294.         conn:execute(string.format("insert into taiwan_login.gm_manifest (m_id,level) VALUES(%d,7) ON DUPLICATE KEY UPDATE level=7",
  295.                 user:GetAccId()))
  296.         user:SendNotiPacketMessage("\n机器人已为您开启台服真GM模式,请重新登录", 1)
  297.         return 0
  298.     elseif input == "//close_gm" then
  299.         conn:execute(string.format("delete from taiwan_login.gm_manifest where m_id=%d",
  300.                 user:GetAccId()))
  301.         user:SendNotiPacketMessage("\n机器人已为您关闭台服真GM模式,请重新登录", 1)
  302.         return 0
  303.     elseif string.startWith(input, "//clean_avatar") then
  304.         local avatarInfoList = string.split(input, " ")
  305.         if #avatarInfoList >= 2 then
  306.             local avatarInfo = tonumber(avatarInfoList[2])
  307.             for i = 0, avatarInfo - 1, 1 do
  308.                 local info = dpx.item.info(user.cptr, game.ItemSpace.AVATAR, i)
  309.                 if info then
  310.                     logger.info(string.format("will delete [iteminfo] id: %d count: %d name: %s attach: %d",
  311.                             info.id, info.count, info.name, info.attach_type))
  312.                     dpx.item.delete(user.cptr, game.ItemSpace.AVATAR, i)
  313.                 end
  314.             end
  315.             user:SendItemSpace(game.ItemSpace.AVATAR)
  316.             user:SendNotiPacketMessage(string.format("机器人已为您清理时装前%d格,请及时查看确认!", avatarInfo), 1)
  317.         else
  318.             for i = 0, 13, 1 do
  319.                 local info = dpx.item.info(user.cptr, game.ItemSpace.AVATAR, i)
  320.                 if info then
  321.                     logger.info(string.format("will delete [iteminfo] id: %d count: %d name: %s attach: %d",
  322.                             info.id, info.count, info.name, info.attach_type))
  323.                     dpx.item.delete(user.cptr, game.ItemSpace.AVATAR, i)
  324.                 end
  325.             end
  326.             user:SendItemSpace(game.ItemSpace.AVATAR)
  327.             user:SendNotiPacketMessage("机器人已为您清理时装前2栏,请及时查看确认!", 1)
  328.         end
  329.         return 0
  330.     elseif string.startWith(input, "//itemcode") then
  331.         local itemcodeInfoList = string.split(input, " ")
  332.         if #itemcodeInfoList >= 2 then
  333.             local cur = conn:execute(
  334.                     string.format("select EquipmentCode, EquipmentNameCN from dp2.equipment where EquipmentName like '%%%s%%' union all select StackableCode, StackableNameCN from dp2.stackable where stackable.StackableName like '%%%s%%'",
  335.                             itemcodeInfoList[2], itemcodeInfoList[2]))
  336.             local row = cur:fetch({}, "a")
  337.             user:SendNotiPacketMessage("查询结果:", 1)
  338.             while row do
  339.                 user:SendNotiPacketMessage(string.format("%s %d", row.EquipmentNameCN, row.EquipmentCode), 1)
  340.                 row = cur:fetch({}, "a")
  341.             end
  342.         else
  343.             user:SendNotiPacketMessage("\n命令输出错误 请按照(//itemcode 无色小晶块)格式输入!", 1)
  344.         end
  345.         return 0
  346.     elseif string.startWith(input, "//send_item") then
  347.         local itemcodeInfoList = string.split(input, " ")
  348.         if #itemcodeInfoList >= 3 then
  349.             local cur = conn:execute(
  350.                     string.format("select EquipmentCode, EquipmentNameCN from dp2.equipment where EquipmentCode = %d union all select StackableCode, StackableNameCN from dp2.stackable where stackable.StackableCode = %d",
  351.                             tonumber(itemcodeInfoList[2]), tonumber(itemcodeInfoList[2])))
  352.             local row = cur:fetch({}, "a")
  353.             if row then
  354.                 dpx.item.add(user.cptr, tonumber(itemcodeInfoList[2]), tonumber(itemcodeInfoList[3]))
  355.                 user:SendNotiPacketMessage(string.format("机器人已为您发送 %s %d个,请及时查看确认!",
  356.                         row.EquipmentNameCN, tonumber(itemcodeInfoList[3])), 1)
  357.             else
  358.                 user:SendNotiPacketMessage("\n您要发送的物品不存在,请查询物品代码后再发!", 1)
  359.             end
  360.         else
  361.             user:SendNotiPacketMessage("\n命令输出错误 请按照(//send_item 3037 10)格式输入!", 1)
  362.         end
  363.         return 0
  364.     end
  365.     conn:close()
  366.     env:close()
  367.     return next()
  368. end

  369. -- 每日福利
  370. local daily_fuli = function(_user)
  371.     local user = game.fac.user(_user)
  372.     local uid = user:GetAccId()
  373.     online[uid] = user --登录的时候记录
  374.     local env = luasql.mysql()
  375.     local conn = env:connect("taiwan_billing", "game", "uu5!^%jg", "127.0.0.1", 3306)
  376.     conn:execute "SET NAMES latin1"
  377.     conn:execute "create database if not exists dp2"
  378.     conn:execute "create table if not exists dp2.login(id INT(10) not null primary key AUTO_INCREMENT,account INT(10) default 0 not null, loginTime INT(10) UNSIGNED default 0 not null, firstLogin INT(10) UNSIGNED default 0 not null)"
  379.     local cera = 1000000 -- 需要发送的点券数量
  380.     -- 获取账号的登录是否当日首次登录
  381.     local cur = conn:execute(
  382.             string.format("select firstLogin from dp2.login where account = %d and loginTime >= %d",
  383.                     user:GetAccId(), GetCurrentDayZeroTimestamp()))
  384.     local row = cur:fetch({}, "a")
  385.     if not row then
  386.         -- 未查询到用户记录 说明这次是首次登录 发放每日福利
  387.         conn:execute(string.format("insert into dp2.login(account,loginTime,firstLogin) values (%d,%d,0)",
  388.                 user:GetAccId(), os.time(), 0))
  389.         conn:execute(string.format("update taiwan_billing.cash_cera set cera=cera+%d where account = %d",
  390.                 cera, user:GetAccId()))
  391.         dpx.item.add(user.cptr, 21060501, 1)
  392.                 dpx.item.add(user.cptr, 2021120302, 1)
  393.         user:SendNotiPacketMessage("\n每日首次登录,奖励100w点券,一束鲜花*1赛丽亚抽奖卷*1", 1)
  394.     else
  395.         user:SendNotiPacketMessage("\n每日首次登录,奖励100w点券,一束鲜花*1赛丽亚抽奖卷*1", 1)
  396.     end
  397.     conn:close()
  398.     env:close()
  399. end

  400. function GetCurrentDayZeroTimestamp(_timerStamp)
  401.     --获得当前的时间
  402.     local timeStamp = _timerStamp
  403.     if not timeStamp then
  404.         timeStamp = os.time()
  405.     end
  406.     --获得时间格式
  407.     local formatTime = os.date("*t", timeStamp)
  408.     formatTime.hour = 0
  409.     formatTime.min = 0
  410.     formatTime.sec = 0
  411.     --获得当天零点的时间戳
  412.     local curTimestamp = os.time(formatTime)
  413.     return curTimestamp
  414. end

  415. -- 判断字符串起始
  416. function string:startWith(substr)
  417.     if self == nil or substr == nil then
  418.         return nil, "the string or the sub-stirng parameter is nil"
  419.     end
  420.     if string.find(self, substr) ~= 1 then
  421.         return false
  422.     else
  423.         return true
  424.     end
  425. end

  426. -- 分隔字符串
  427. function string:split(sep)
  428.     local sep, fields = sep or "\t", {}
  429.     local pattern = string.format("([^%s]+)", sep)
  430.     self:gsub(pattern, function(c)
  431.         fields[#fields + 1] = c
  432.     end)
  433.     return fields
  434. end

  435. --修复绝望之塔金币异常
  436. local function MyUseAncientDungeonItems(fnext, _party, _dungeon, _item)
  437.     local dungeon = game.fac.dungeon(_dungeon)
  438.     local dungeon_index = dungeon:GetIndex()
  439.     if dungeon_index >= 11008 and dungeon_index <= 11107 then
  440.         return true
  441.     end
  442.     return fnext()
  443. end

  444. --泡点活动
  445. local paodianTimer = luv.new_timer()
  446. local function paodianEvent()
  447.     local pdCash = 100 -- 每分钟需要发送的点券数量
  448.     local env = luasql.mysql()
  449.     local conn = env:connect("dp2", "game", "uu5!^%jg", "127.0.0.1", 3306)
  450.     conn:execute "SET NAMES latin1"
  451.     myEventCur = assert(conn:execute "SELECT id, status from dp2.event where id = 1")
  452.     myEvent = myEventCur:fetch({}, "a")
  453.     if myEvent.status == "1" then
  454.         for k, v in pairs(online) do
  455.             logger.info(string.format("泡点发送至%s", v:GetCharacName()))
  456.             conn:execute(string.format("update taiwan_billing.cash_cera set cera=cera+%d where account = %d",
  457.                     pdCash, v:GetAccId()))
  458.             v:SendNotiPacketMessage(string.format("泡点奖励获得%d点券", pdCash))
  459.         end
  460.         logger.info("泡点活动已开启,本次泡点发放完毕!")
  461.     else
  462.         logger.info("泡点活动未开启!")
  463.     end
  464.     conn:close()
  465.     env:close()
  466. end
  467. paodianTimer:start(10000, 60000, paodianEvent) --启动后10s开始执行,随后每60s执行一次

  468. --初始化
  469. local initTimer = luv.new_timer()
  470. local function initFun()
  471.     local env = luasql.mysql()
  472.     local conn = env:connect("taiwan_billing", "game", "uu5!^%jg", "127.0.0.1", 3306)
  473.     conn:execute "SET NAMES latin1"
  474.     conn:execute "create database if not exists dp2"
  475.     conn:execute "create table if not exists dp2.event( id int not null, status int default 0 not null, constraint event_pk primary key (id))"
  476.     conn:execute "insert into dp2.event (id,status) VALUES(1,0) ON DUPLICATE KEY UPDATE status=0"
  477.     logger.info("服务器重启,默认关闭泡点活动")
  478.     --logger.info("开始加载pvf信息到数据库,预计需要10分钟")
  479.     --os.execute("rm -rf /var/log/dp2/dp2server.log")
  480.     --os.execute("chmod +x /dp2/dp2server/dp2-server")
  481.     --os.execute("/dp2/dp2server/dp2-server")
  482. end
  483. initTimer:start(1000, 0, initFun) --启动后1s开始执行,只执行一次

  484. -- 登出的时候移除
  485. local function onLogout(_user)
  486.     local user = game.fac.user(_user)
  487.     local uid = user:GetAccId()
  488.     online[uid] = nil
  489. end

  490. dpx.hook(game.HookType.GmInput, on_input)
  491. dpx.hook(game.HookType.UseItem2, my_useitem2)
  492. dpx.hook(game.HookType.Reach_GameWord, daily_fuli)
  493. dpx.hook(game.HookType.Leave_GameWord, onLogout)
  494. dpx.hook(game.HookType.CParty_UseAncientDungeonItems, MyUseAncientDungeonItems) --修复绝望之塔金币异常

  495. -- 以下这些,自行选用,不用的删除当前行就行,用的自行按照说明文档添加!
  496. dpx.disable_item_routing()-- 史诗免确认提示框 !
  497. dpx.disable_giveup_panalty()-- 退出副本后角色默认不虚弱 !
  498. dpx.extend_teleport_item() --瞬间移动药剂扩展
  499. dpx.enable_creator() -- 允许创建缔造者
  500. dpx.set_unlimit_towerofdespair() --绝望之塔通关后仍可继续挑战(需门票)
  501. --dpx.enable_game_master() --开启台服GM模式
复制代码

这些代码都是我自己开群服自用的、自己添加文件道具导入即可。DP用2.6以上的版本、
版本低了一些不支持、其中一键分解需要个人学习分解师并且开启商店然后使用道具才会实现
这个代码自己复制到df_game_r.lua覆盖即可 剩余的自己对接

包含自动每日邮件奖励 那些ID自己需要的物品改即可
回复

使用道具 举报

0

主题

137

回帖

148

积分

六品通判

黄金
0
银两
80
金币
11 个

TGL新人活跃会员

发表于 2022-9-21 22:02:17 | 显示全部楼层
念了十几年书,还是幼儿园。
回复

使用道具 举报

0

主题

168

回帖

183

积分

六品通判

黄金
0
银两
101
金币
15 个

TGL新人活跃会员

发表于 2022-9-26 15:41:58 | 显示全部楼层
还是哥哥稳666666
回复

使用道具 举报

0

主题

137

回帖

148

积分

六品通判

黄金
0
银两
87
金币
11 个

TGL新人活跃会员

发表于 2022-9-27 01:47:12 | 显示全部楼层
还是哥哥稳666666
回复

使用道具 举报

0

主题

144

回帖

151

积分

六品通判

黄金
0
银两
93
金币
7 个

TGL新人活跃会员

发表于 2022-9-30 21:38:21 | 显示全部楼层
谢谢楼主分享
回复

使用道具 举报

0

主题

151

回帖

168

积分

六品通判

黄金
0
银两
89
金币
17 个

TGL新人活跃会员

发表于 2022-10-1 11:13:22 | 显示全部楼层
开车无难事,只怕有新人!
回复

使用道具 举报

0

主题

149

回帖

159

积分

六品通判

黄金
0
银两
94
金币
10 个

TGL新人活跃会员

发表于 2022-10-2 10:33:00 | 显示全部楼层
哈哈,白嫖就是舒服。
回复

使用道具 举报

0

主题

152

回帖

171

积分

六品通判

黄金
0
银两
93
金币
19 个

TGL新人活跃会员

发表于 2022-10-2 10:44:14 | 显示全部楼层
我是个凑数的
回复

使用道具 举报

0

主题

154

回帖

162

积分

六品通判

黄金
0
银两
93
金币
8 个

TGL新人活跃会员

发表于 2022-10-4 21:11:50 | 显示全部楼层
还是哥哥稳666666
回复

使用道具 举报

0

主题

151

回帖

158

积分

六品通判

黄金
0
银两
92
金币
7 个

TGL新人活跃会员

发表于 2022-10-6 06:38:38 | 显示全部楼层
谢谢分享哈哈哈哈哈哈哈
回复

使用道具 举报

0

主题

125

回帖

136

积分

六品通判

黄金
0
银两
77
金币
12 个

TGL新人活跃会员

发表于 2022-10-11 14:56:04 | 显示全部楼层
念了十几年书,还是幼儿园。
回复

使用道具 举报

0

主题

164

回帖

183

积分

六品通判

黄金
0
银两
97
金币
19 个

TGL新人活跃会员

发表于 2022-10-14 04:52:51 | 显示全部楼层
小手一抖,积分到手
回复

使用道具 举报

0

主题

163

回帖

178

积分

六品通判

黄金
0
银两
107
金币
15 个

TGL新人活跃会员

发表于 2022-10-18 08:10:24 | 显示全部楼层
谢谢分享哈哈哈哈哈哈哈
回复

使用道具 举报

0

主题

143

回帖

153

积分

六品通判

黄金
0
银两
86
金币
10 个

TGL新人活跃会员

发表于 2022-10-19 23:02:37 | 显示全部楼层
看帖回帖是美德
回复

使用道具 举报

0

主题

149

回帖

157

积分

六品通判

黄金
0
银两
90
金币
8 个

TGL新人活跃会员

发表于 2022-10-20 16:38:15 | 显示全部楼层
大家一起刷刷分吧!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

举报|手机版|TGL游戏爱好者 渝ICP备2021011488号-2 |网站地图

GMT+8, 2024-5-12 20:31 , Processed in 0.103983 second(s), 12 queries , Redis On.

Powered by Discuz! W1.0

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖QQ客服返回顶部
快速回复 返回顶部 返回列表