Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print(">> Loading ItemUpSystem Code by Ayase")
- local EquipUpItemEntry = 60001
- local pSelectGos={}
- local clNum = nil
- local SlotName = {
- [0]="|cFF0000FF Head:|r", [1]="|cFF0000FF Necklace:|r", [2]="|cFF0000FF Shoulder:|r", [3]="|cFF0000FF chest:|r",
- [4]="|cFF0000FF Chest:|r", [5]="|cFF0000FF Belt:|r", [6]="|cFF0000FF Legs:|r", [7]="|cFF0000FF Feet:|r",
- [8]="|cFF0000FF Wrist:|r", [9]="|cFF0000FF Gloves:|r", [10]="|cFF0000FF Ring:|r", [11]="|cFF0000FF Ring:|r",
- [12]="|cFF0000FF Trinket:|r", [13]="|cFF0000FF Trinket:|r", [14]="|cFF0000FF Back:|r", [15]="|cFF0000FF Main Hand Weapon:|r",
- [16]="|cFF0000FF Off-Item:|r", [17]="|cFF0000FF Ranged:|r", [18]="|cFF0000FF Shirt:|r",
- }
- local ItemDisplay = {}
- local ItemUpData = {}
- local DBItemData = {}
- local MGItem = {}
- local function MGItem()
- local UseMagicCoins = AuthDBQuery("SELECT magiccoins from account where id='" .. id .. "'")
- local MagicCoins = 0
- if(UseMagicCoins) then
- repeat
- MagicCoins = VIPLevel:GetUInt32(0)
- until not UseMagicCoins:NextRow()
- end
- return MagicCoins
- end
- local function LoadDBItemUP()
- local query = WorldDBQuery("SELECT * FROM zz_item_up;")
- local a = 0
- if (query) then
- local Time1 = os.clock() * 1000
- clNum = (query:GetColumnCount()-4)/2
- repeat
- ItemUpData[query:GetUInt32(0)] = {
- ["up"] = query:GetUInt32(1),
- ["jl"] = query:GetUInt32(2),
- ["num"] = query:GetUInt32(3),
- ["cl"] = {}
- }
- for i=1,clNum do
- ItemUpData[query:GetUInt32(0)]["cl"]["id"..i] = query:GetUInt32(2*i+2)
- ItemUpData[query:GetUInt32(0)]["cl"]["num"..i] = query:GetUInt32(2*i+3)
- end
- a = a+1
- until not query:NextRow()
- local Time2 = os.clock() * 1000
- print(" ItemUP->Loading "..a.." ItemUpData in "..Time2-Time1.." ms")
- end
- end
- local function LoadDBItemData()
- local query = WorldDBQuery("SELECT entry,displayid FROM item_template;")
- if (query) then
- local Time1 = os.clock() * 1000
- repeat
- DBItemData[query:GetUInt32(0)] = query:GetUInt32(1)
- until not query:NextRow()
- local Time2 = os.clock() * 1000
- print(" ItemUP->Loading "..#DBItemData.." ItemData in "..Time2-Time1.."ms")
- end
- end
- local function LoadDBItemIcons()
- local query = WorldDBQuery("SELECT displayid,icon FROM zz_item_icon;")
- if (query) then
- local Time1 = os.clock() * 1000
- repeat
- ItemDisplay[query:GetUInt32(0)] = query:GetString(1)
- until not query:NextRow()
- local Time2 = os.clock() * 1000
- print(" ItemUP->Loading "..#ItemDisplay.." ItemIcon in "..Time2-Time1.."ms")
- end
- end
- LoadDBItemUP()
- LoadDBItemData()
- LoadDBItemIcons()
- local function EquipmentUpgradeSystemEvent(event, p, item, target)
- local pGuid = p:GetGUIDLow()
- pSelectGos[pGuid] = 10086
- EquipmentUpgradeSystem(_,p,_,_)
- end
- function EquipmentUpgradeSystem(_,p,_,_)
- local pGuid = p:GetGUIDLow()
- p:GossipClearMenu()
- if pSelectGos[pGuid] == 10086 then
- for i=0,18 do
- local equip = p:GetEquippedItemBySlot(i)
- if equip then
- p:GossipMenuAddItem(0," "..SlotName[i].."\n|TInterface/ICONS/"..ItemDisplay[equip:GetDisplayId()]..":40:40:-15:12|t"..equip:GetItemLink(),1,i)
- end
- end
- p:GossipSendMenu(1,p,50021)
- else
- local equip = p:GetEquippedItemBySlot(pSelectGos[pGuid])
- if ItemUpData[equip:GetEntry()] == nil or DBItemData[ItemUpData[equip:GetEntry()]["up"]]==nil then
- p:SendBroadcastMessage("Items can not be upgraded~")
- p:GossipComplete()
- else
- local UpEntry = ItemUpData[equip:GetEntry()]["up"]
- p:GossipMenuAddItem(0," Can be upgraded to:\n|TInterface/ICONS/"..ItemDisplay[DBItemData[UpEntry]]..":40:40:-15:12|t"..GetItemLink(UpEntry),1,1000)
- local TextTem = "|TInterface/ICONS/"..ItemDisplay[equip:GetDisplayId()]..":40:40:-15:12|t"
- if ItemUpData[equip:GetEntry()]["num"] ~= 0 then
- p:GossipMenuAddItem(0," |cFF0066CCNeed original items: |r\n"..TextTem..GetItemLink(equip:GetEntry()).." x "..ItemUpData[equip:GetEntry()]["num"],1,1000)
- end
- for i=1,clNum do
- if ItemUpData[equip:GetEntry()]["cl"]["id"..i] ~=0 then
- local ItemIcon = "|TInterface/ICONS/"..ItemDisplay[DBItemData[ItemUpData[equip:GetEntry()]["cl"]["id"..i]]]..":40:40:-15:12|t"..GetItemLink(ItemUpData[equip:GetEntry()]["cl"]["id"..i])
- p:GossipMenuAddItem(0," |cFF666699 Need items"..i..":|r\n"..ItemIcon.." x "..ItemUpData[equip:GetEntry()]["cl"]["num"..i],1,1000)
- end
- end
- p:GossipMenuAddItem(0,"Magic Gold:"..MagicCoins.." Left",1,1000)
- p:GossipMenuAddItem(0,"Upgrade chance:"..ItemUpData[equip:GetEntry()]["jl"].."%",1,1000)
- p:GossipMenuAddItem(0,"Confirm the upgrade",1,999)
- p:GossipSendMenu(1,p,50021)
- end
- end
- end
- local function EquipmentUpgradeSystem_GossipSelect(event, player, object, sender, intid, code, menu_id)
- local pGuid = player:GetGUIDLow()
- if intid == 1000 then
- player:GossipComplete()
- elseif intid == 999 then
- if player:IsInCombat()==false then
- local equip = player:GetEquippedItemBySlot(pSelectGos[pGuid])
- local ItemId = equip:GetEntry()
- local UpCheck = true
- if ItemUpData[ItemId]["num"]-1 >0 then
- if player:HasItem(ItemId,ItemUpData[ItemId]["num"]-1) == false then
- UpCheck = false
- player:SendBroadcastMessage("material:"..GetItemLink(ItemId).."Insufficient amount.")
- end
- end
- for i=1,clNum do
- if ItemUpData[ItemId]["cl"]["id"..i] ~=0 then
- if player:HasItem(ItemUpData[ItemId]["cl"]["id"..i],ItemUpData[ItemId]["cl"]["num"..i]) == false then
- UpCheck = false
- player:SendBroadcastMessage("material:"..GetItemLink(ItemUpData[ItemId]["cl"]["id"..i]).."Insufficient amount.")
- end
- end
- end
- if UpCheck then
- local jl = math.random(1,100)
- if jl <= ItemUpData[ItemId]["jl"] then
- local pEnchantment = {}
- for i=0,6 do
- pEnchantment[i] = equip:GetEnchantmentId(i)
- end
- player:RemoveItem(equip,1)
- player:RemoveItem(ItemId,ItemUpData[ItemId].num - 1)
- player:EquipItem(ItemUpData[ItemId]["up"],pSelectGos[pGuid])
- local pItem = player:GetEquippedItemBySlot(pSelectGos[pGuid])
- for i=0,6 do
- if pEnchantment[i]~= 0 then
- pItem:SetEnchantment(pEnchantment[i], i)
- end
- end
- pEnchantment=nil
- player:SendBroadcastMessage("Equipment upgrade was successful. Obtain items"..GetItemLink(ItemUpData[ItemId]["up"]))
- else
- player:SendBroadcastMessage("Equipment upgrade failed")
- end
- for i=1,clNum do
- if ItemUpData[ItemId]["cl"]["id"..i] ~=0 then
- player:RemoveItem(ItemUpData[ItemId]["cl"]["id"..i],ItemUpData[ItemId]["cl"]["num"..i])
- end
- end
- end
- else
- player:SendBroadcastMessage("You are fighting, can not be used, unless you want to die~ ")
- end
- player:GossipComplete()
- else
- for i=0,18 do
- if intid == i then
- local item = player:GetEquippedItemBySlot(i)
- pSelectGos[pGuid] = i
- return EquipmentUpgradeSystem(event,player,item,_)
- end
- end
- end
- end
- RegisterItemEvent(60001, 2, EquipmentUpgradeSystemEvent)
- RegisterPlayerGossipEvent(50021,2,EquipmentUpgradeSystem_GossipSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement