Platform.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. Platform = {}
  2. local this = Platform;
  3. PLATFORMSYSDATA = "R$platform_sys_data"
  4. local MonthCardType = 40
  5. local PlatformType = {
  6. KaiYing = "kaiying"
  7. }
  8. function Platform.init()
  9. local data = {}
  10. data.channel = ConfigDataManager.getTableValue("cfg_global", "value", "id", 500)
  11. setsysvar(PLATFORMSYSDATA, data)
  12. end
  13. function Platform.putIntoBag(actor, itemId)
  14. local data = getsysvar(PLATFORMSYSDATA)
  15. if data == nil then
  16. return
  17. end
  18. -- if data.channel == PlatformType.KaiYing then
  19. if PrivilegeMonth.hasPrivilegeType(actor, MonthCardType) ~= true then
  20. Platform.setItemBind(actor, itemId, 1)
  21. else
  22. local item = getbagiteminfo(actor, itemId, 1)
  23. if item == nil then
  24. return
  25. end
  26. local lockItem = ConfigDataManager.getTableValue("cfg_item", "lockItem", "id", item.cfgid)
  27. if lockItem ~= "" and lockItem == "1" then
  28. Platform.setItemBind(actor, itemId, 0)
  29. end
  30. end
  31. -- end
  32. end
  33. function Platform.monthPrivilegeActivation(actor, p_type)
  34. -- 解锁了月卡.道具也不能恢复到绑定状态
  35. -- -- 月卡激活
  36. -- if p_type == 72 then
  37. -- -- 降低消耗
  38. -- local data = getsysvar(PLATFORMSYSDATA)
  39. -- if data == nil then
  40. -- return
  41. -- end
  42. -- -- if data.channel ~= PlatformType.KaiYing then
  43. -- -- return
  44. -- -- end
  45. -- -- 把玩家穿戴.背包.仓库的东西.变为可交易状态
  46. -- local equips = getallbagiteminfo(actor)
  47. -- for k, v in pairs(equips) do
  48. -- local lockItem = ConfigDataManager.getTableValue("cfg_item", "lockItem", "id", v.cfgid)
  49. -- if lockItem ~= nil and lockItem == "1" then
  50. -- Platform.setItemBind(actor, v.id, 0)
  51. -- end
  52. -- end
  53. -- for i = 1, 10 do
  54. -- local equips = getalliteminfoinstore(actor, i)
  55. -- for k, v in pairs(equips) do
  56. -- local lockItem = ConfigDataManager.getTableValue("cfg_item", "lockItem", "id", v.cfgid)
  57. -- if lockItem ~= nil and lockItem == "1" then
  58. -- local isbind = API.GetItemData(actor, v.id, "isbind")
  59. -- if isbind ~= 1 then
  60. -- -- 没办法修改仓库中物品的数据.只能打上标签.让他显示为可交易状态
  61. -- API.SetItemData(actor, v.id, "isbind", 0)
  62. -- end
  63. -- -- Platform.setItemBind(actor, v.id, 0)
  64. -- end
  65. -- end
  66. -- end
  67. -- local equips = getputonequipinfo(actor)
  68. -- for k, v in pairs(equips) do
  69. -- local lockItem = ConfigDataManager.getTableValue("cfg_item", "lockItem", "id", v.cfgid)
  70. -- if lockItem ~= nil and lockItem == "1" then
  71. -- Platform.setItemBind(actor, v.id, 0)
  72. -- end
  73. -- end
  74. -- end
  75. end
  76. function Platform.setItemBind(actor, itemId, bind)
  77. local isbind = API.GetItemData(actor, itemId, "isbind")
  78. if isbind == 1 then
  79. return
  80. end
  81. changeitembindstate(actor, itemId, bind)
  82. local res = {
  83. itemId = itemId,
  84. bindId = bind == 1 and true or false
  85. }
  86. sendluamsg(actor, LuaMessageIdToClient.RES_EQUIP_BIND_DATA_CHANGE, res)
  87. end
  88. function Platform.isLimitPick(actor)
  89. if PrivilegeMonth.hasPrivilegeType(actor, MonthCardType) ~= true then
  90. return true
  91. end
  92. return false
  93. end
  94. function Platform.pickUpItem(actor, items)
  95. local allow = {}
  96. local rid = getbaseinfo(actor, "rid")
  97. local tip = false
  98. for k, v in pairs(items) do
  99. if v.luaextdata ~= nil and v.luaextdata.onlypick ~= nil and v.luaextdata.onlypick ~= tonumber(rid) then
  100. tip = true
  101. allow[v.id] = {
  102. allow = false,
  103. }
  104. else
  105. allow[v.id] = {
  106. allow = true,
  107. }
  108. end
  109. end
  110. if tip then
  111. messagebox(actor, "该物品归属为无公爵特权玩家,其他玩家无法拾取!")
  112. end
  113. return allow
  114. end
  115. function Platform.resetPick(actor, items, allow)
  116. local rid = getbaseinfo(actor, "rid")
  117. local tip = false
  118. for k, v in pairs(allow) do
  119. local index, item = table.findByCondi(items, function(a)
  120. return a.id == k
  121. end)
  122. if item and item.luaextdata and item.luaextdata.onlypick ~= nil and item.luaextdata.onlypick ~= tonumber(rid) then
  123. tip = true
  124. allow[k].allow = false
  125. end
  126. end
  127. if tip then
  128. messagebox(actor, "该物品归属为无公爵特权玩家,其他玩家无法拾取!")
  129. end
  130. return allow
  131. end