Advertisement
Guest User

Untitled

a guest
Dec 16th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.60 KB | None | 0 0
  1. --De Osler para Wowcreador.com
  2. local AIO = AIO or require("AIO")
  3. local MyHandlers = AIO.AddHandlers("NewGossip", {})
  4.  
  5. local NpcId = 1432 --ID del NPC
  6. local token_id = 49426 --Objeto necesario para llevar a cabo la solicitud
  7.  
  8. if AIO.AddAddon() then
  9.     --[[
  10. #########################################################
  11. ##################START SERVER###########################
  12. #########################################################
  13.     ]]
  14.     -- we are on server
  15.     local function OnGossipHello(event, player, object)
  16.         player:GossipClearMenu() --Creamos un gossip vacio
  17.         player:GossipSendMenu(1, object, MenuId)
  18.         AIO.Handle(player, "NewGossip", "ShowFrame") --AL abrir el gossip manda al cliente que abra el nuevo gossip
  19.     end
  20.  
  21.     function MyHandlers.Morph(player, ...)
  22.         if player:GetDistance(-8848.3144, 614.4602, 95.1868) > 3.6 then --Coordenadas del NPC (x, y, z) para evitar abusar el sistema
  23.             player:SendBroadcastMessage("You are too far away from the NPC")
  24.         else
  25.             if player:GetItemCount(token_id) >= 1 then
  26.                 player:RemoveItem(token_id, 1)
  27.                 player:SetDisplayId(17822)
  28.                 AIO.Handle(player, "NewGossip", "UpdateTitle") --Actualiza el titulo para reflejar la cantidad de tokens restante
  29.             else
  30.                 player:SendBroadcastMessage("You don't have the required amount of tokens")
  31.             end
  32.         end
  33.     end
  34.  
  35.     RegisterCreatureGossipEvent(NpcId, 1, OnGossipHello)
  36.  
  37. else
  38.     --[[
  39. #########################################################
  40. ##################START CLIENT###########################
  41. #########################################################
  42.     ]]
  43.     -- Creamos el nuevo gossip
  44.     NewGossip = CreateFrame("Frame", "NewGossip", UIParent, "UIPanelDialogTemplate")
  45.     local frame = NewGossip
  46.     frame:SetSize(200, 200)
  47.     frame:RegisterForDrag("LeftButton")
  48.     frame:SetPoint("BOTTOM", 0, 0)
  49.     frame:SetToplevel(true)
  50.     frame:SetClampedToScreen(true)
  51.     frame:SetMovable(true)
  52.     frame:EnableMouse(true)
  53.     frame:SetScript("OnDragStart", frame.StartMoving)
  54.     frame:SetScript("OnHide", frame.StopMovingOrSizing)
  55.     frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
  56.     AIO.SavePosition(frame)
  57.     frame:Hide()
  58.     frame:RegisterEvent("GOSSIP_CLOSED")
  59.  
  60.     local fontTitle = frame:CreateFontString("fontTitle")
  61.     fontTitle:SetFont("Fonts\\FRIZQT__.TTF", 13)
  62.     fontTitle:SetSize(190, 5)
  63.     fontTitle:SetPoint("TOP", 0, -13)
  64.  
  65.     frame:SetScript("OnEvent", function(self,event, ...) --Cuando se cierra un gossip restaura la ventana a su condicion normal
  66.         if event == "GOSSIP_CLOSED" then
  67.             GossipFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT",0,-104)
  68.             GossipFrame:SetScale(1)
  69.             frame:Hide()
  70.         end
  71.     end)
  72.     frame:SetScript("OnShow", function() --Oculta el gossip original al aparecer el nuevo
  73.         GossipFrame:ClearAllPoints()
  74.         GossipFrame:SetPoint("LEFT",UIParent,"LEFT",-1000,-1000)
  75.         GossipFrame:SetScale(0.01)
  76.         fontTitle:SetText("|cffFFC125Morpher |r".."-".."|cffddff25Tokens: |r"..GetItemCount(token_id)) --Actualiza el titulo
  77.     end)
  78.  
  79.     NewGossipClose:SetScript("OnClick", function()CloseGossip()end) --Hacemos que el gossip original se cierre con el nuevo
  80.  
  81.     function MyHandlers.ShowFrame(player)
  82.         frame:Show()
  83.     end
  84.  
  85.     function MyHandlers.HideFrame(player)
  86.         frame:Hide()
  87.     end
  88.  
  89.     function MyHandlers.UpdateTitle()
  90.         fontTitle:SetText("|cffFFC125Morpher |r".."-".."|cffddff25Tokens: |r"..GetItemCount(token_id))
  91.     end
  92.  
  93.     --Boton de prueba
  94.     local ButTest = CreateFrame("Button", "ButTest", frame, "UIPanelButtonTemplate")
  95.     ButTest:SetSize(128, 32)
  96.     ButTest:SetPoint("CENTER", frame, "CENTER", 0, 50)
  97.     ButTest:EnableMouse(true)
  98.     ButTest:SetText("Velen")
  99.     ButTest:SetScript("OnClick", function() AIO.Handle("NewGossip", "Morph") end)
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement