Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.14 KB | None | 0 0
  1. print(">> Loading ItemUpSystem Code by Ayase")
  2.  
  3. local EquipUpItemEntry = 60001
  4. local pSelectGos={}
  5. local clNum = nil
  6.  
  7. local SlotName = {
  8. [0]="|cFF0000FF Head:|r", [1]="|cFF0000FF Necklace:|r", [2]="|cFF0000FF Shoulder:|r", [3]="|cFF0000FF chest:|r",
  9. [4]="|cFF0000FF Chest:|r", [5]="|cFF0000FF Belt:|r", [6]="|cFF0000FF Legs:|r", [7]="|cFF0000FF Feet:|r",
  10. [8]="|cFF0000FF Wrist:|r", [9]="|cFF0000FF Gloves:|r", [10]="|cFF0000FF Ring:|r", [11]="|cFF0000FF Ring:|r",
  11. [12]="|cFF0000FF Trinket:|r", [13]="|cFF0000FF Trinket:|r", [14]="|cFF0000FF Back:|r", [15]="|cFF0000FF Main Hand Weapon:|r",
  12. [16]="|cFF0000FF Off-Item:|r", [17]="|cFF0000FF Ranged:|r", [18]="|cFF0000FF Shirt:|r",
  13. }
  14.  
  15. local ItemDisplay = {}
  16. local ItemUpData = {}
  17. local DBItemData = {}
  18. local MGItem = {}
  19.  
  20. local function MGItem()
  21. local UseMagicCoins = AuthDBQuery("SELECT magiccoins from account where id='" .. id .. "'")
  22. local MagicCoins = 0
  23. if(UseMagicCoins) then
  24. repeat
  25. MagicCoins = VIPLevel:GetUInt32(0)
  26. until not UseMagicCoins:NextRow()
  27. end
  28. return MagicCoins
  29. end
  30.  
  31.  
  32.  
  33. local function LoadDBItemUP()
  34. local query = WorldDBQuery("SELECT * FROM zz_item_up;")
  35. local a = 0
  36. if (query) then
  37. local Time1 = os.clock() * 1000
  38. clNum = (query:GetColumnCount()-4)/2
  39. repeat
  40. ItemUpData[query:GetUInt32(0)] = {
  41. ["up"] = query:GetUInt32(1),
  42. ["jl"] = query:GetUInt32(2),
  43. ["num"] = query:GetUInt32(3),
  44. ["cl"] = {}
  45. }
  46. for i=1,clNum do
  47. ItemUpData[query:GetUInt32(0)]["cl"]["id"..i] = query:GetUInt32(2*i+2)
  48. ItemUpData[query:GetUInt32(0)]["cl"]["num"..i] = query:GetUInt32(2*i+3)
  49. end
  50. a = a+1
  51. until not query:NextRow()
  52. local Time2 = os.clock() * 1000
  53. print(" ItemUP->Loading "..a.." ItemUpData in "..Time2-Time1.." ms")
  54. end
  55. end
  56.  
  57. local function LoadDBItemData()
  58. local query = WorldDBQuery("SELECT entry,displayid FROM item_template;")
  59. if (query) then
  60. local Time1 = os.clock() * 1000
  61. repeat
  62. DBItemData[query:GetUInt32(0)] = query:GetUInt32(1)
  63. until not query:NextRow()
  64. local Time2 = os.clock() * 1000
  65. print(" ItemUP->Loading "..#DBItemData.." ItemData in "..Time2-Time1.."ms")
  66. end
  67. end
  68.  
  69. local function LoadDBItemIcons()
  70. local query = WorldDBQuery("SELECT displayid,icon FROM zz_item_icon;")
  71. if (query) then
  72. local Time1 = os.clock() * 1000
  73. repeat
  74.  
  75. ItemDisplay[query:GetUInt32(0)] = query:GetString(1)
  76.  
  77. until not query:NextRow()
  78. local Time2 = os.clock() * 1000
  79. print(" ItemUP->Loading "..#ItemDisplay.." ItemIcon in "..Time2-Time1.."ms")
  80. end
  81. end
  82.  
  83. LoadDBItemUP()
  84. LoadDBItemData()
  85. LoadDBItemIcons()
  86.  
  87. local function EquipmentUpgradeSystemEvent(event, p, item, target)
  88. local pGuid = p:GetGUIDLow()
  89. pSelectGos[pGuid] = 10086
  90. EquipmentUpgradeSystem(_,p,_,_)
  91. end
  92.  
  93. function EquipmentUpgradeSystem(_,p,_,_)
  94. local pGuid = p:GetGUIDLow()
  95. p:GossipClearMenu()
  96. if pSelectGos[pGuid] == 10086 then
  97. for i=0,18 do
  98. local equip = p:GetEquippedItemBySlot(i)
  99. if equip then
  100. p:GossipMenuAddItem(0," "..SlotName[i].."\n|TInterface/ICONS/"..ItemDisplay[equip:GetDisplayId()]..":40:40:-15:12|t"..equip:GetItemLink(),1,i)
  101. end
  102. end
  103. p:GossipSendMenu(1,p,50021)
  104. else
  105. local equip = p:GetEquippedItemBySlot(pSelectGos[pGuid])
  106. if ItemUpData[equip:GetEntry()] == nil or DBItemData[ItemUpData[equip:GetEntry()]["up"]]==nil then
  107. p:SendBroadcastMessage("Items can not be upgraded~")
  108. p:GossipComplete()
  109. else
  110. local UpEntry = ItemUpData[equip:GetEntry()]["up"]
  111. p:GossipMenuAddItem(0," Can be upgraded to:\n|TInterface/ICONS/"..ItemDisplay[DBItemData[UpEntry]]..":40:40:-15:12|t"..GetItemLink(UpEntry),1,1000)
  112. local TextTem = "|TInterface/ICONS/"..ItemDisplay[equip:GetDisplayId()]..":40:40:-15:12|t"
  113. if ItemUpData[equip:GetEntry()]["num"] ~= 0 then
  114. p:GossipMenuAddItem(0," |cFF0066CCNeed original items: |r\n"..TextTem..GetItemLink(equip:GetEntry()).." x "..ItemUpData[equip:GetEntry()]["num"],1,1000)
  115. end
  116. for i=1,clNum do
  117. if ItemUpData[equip:GetEntry()]["cl"]["id"..i] ~=0 then
  118. local ItemIcon = "|TInterface/ICONS/"..ItemDisplay[DBItemData[ItemUpData[equip:GetEntry()]["cl"]["id"..i]]]..":40:40:-15:12|t"..GetItemLink(ItemUpData[equip:GetEntry()]["cl"]["id"..i])
  119. p:GossipMenuAddItem(0," |cFF666699 Need items"..i..":|r\n"..ItemIcon.." x "..ItemUpData[equip:GetEntry()]["cl"]["num"..i],1,1000)
  120. end
  121. end
  122. p:GossipMenuAddItem(0,"Magic Gold:"..MagicCoins.." Left",1,1000)
  123. p:GossipMenuAddItem(0,"Upgrade chance:"..ItemUpData[equip:GetEntry()]["jl"].."%",1,1000)
  124. p:GossipMenuAddItem(0,"Confirm the upgrade",1,999)
  125. p:GossipSendMenu(1,p,50021)
  126. end
  127. end
  128. end
  129.  
  130. local function EquipmentUpgradeSystem_GossipSelect(event, player, object, sender, intid, code, menu_id)
  131. local pGuid = player:GetGUIDLow()
  132. if intid == 1000 then
  133. player:GossipComplete()
  134. elseif intid == 999 then
  135. if player:IsInCombat()==false then
  136. local equip = player:GetEquippedItemBySlot(pSelectGos[pGuid])
  137. local ItemId = equip:GetEntry()
  138. local UpCheck = true
  139. if ItemUpData[ItemId]["num"]-1 >0 then
  140. if player:HasItem(ItemId,ItemUpData[ItemId]["num"]-1) == false then
  141. UpCheck = false
  142. player:SendBroadcastMessage("material:"..GetItemLink(ItemId).."Insufficient amount.")
  143. end
  144. end
  145. for i=1,clNum do
  146. if ItemUpData[ItemId]["cl"]["id"..i] ~=0 then
  147. if player:HasItem(ItemUpData[ItemId]["cl"]["id"..i],ItemUpData[ItemId]["cl"]["num"..i]) == false then
  148. UpCheck = false
  149. player:SendBroadcastMessage("material:"..GetItemLink(ItemUpData[ItemId]["cl"]["id"..i]).."Insufficient amount.")
  150. end
  151. end
  152. end
  153. if UpCheck then
  154. local jl = math.random(1,100)
  155. if jl <= ItemUpData[ItemId]["jl"] then
  156. local pEnchantment = {}
  157. for i=0,6 do
  158. pEnchantment[i] = equip:GetEnchantmentId(i)
  159. end
  160. player:RemoveItem(equip,1)
  161. player:RemoveItem(ItemId,ItemUpData[ItemId].num - 1)
  162. player:EquipItem(ItemUpData[ItemId]["up"],pSelectGos[pGuid])
  163. local pItem = player:GetEquippedItemBySlot(pSelectGos[pGuid])
  164. for i=0,6 do
  165. if pEnchantment[i]~= 0 then
  166. pItem:SetEnchantment(pEnchantment[i], i)
  167. end
  168. end
  169. pEnchantment=nil
  170. player:SendBroadcastMessage("Equipment upgrade was successful. Obtain items"..GetItemLink(ItemUpData[ItemId]["up"]))
  171. else
  172. player:SendBroadcastMessage("Equipment upgrade failed")
  173. end
  174. for i=1,clNum do
  175. if ItemUpData[ItemId]["cl"]["id"..i] ~=0 then
  176. player:RemoveItem(ItemUpData[ItemId]["cl"]["id"..i],ItemUpData[ItemId]["cl"]["num"..i])
  177. end
  178. end
  179. end
  180. else
  181. player:SendBroadcastMessage("You are fighting, can not be used, unless you want to die~ ")
  182. end
  183. player:GossipComplete()
  184. else
  185. for i=0,18 do
  186. if intid == i then
  187. local item = player:GetEquippedItemBySlot(i)
  188. pSelectGos[pGuid] = i
  189. return EquipmentUpgradeSystem(event,player,item,_)
  190. end
  191. end
  192. end
  193. end
  194.  
  195. RegisterItemEvent(60001, 2, EquipmentUpgradeSystemEvent)
  196. RegisterPlayerGossipEvent(50021,2,EquipmentUpgradeSystem_GossipSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement