GuardiaoBrindes = {} --#region REGISTRA FUN��ES DO SISTEMA function GuardiaoBrindes.Init() if GuardiaoBrindes_Config.Enabled == false then return end -- (o pack nao tinha chave no cliente) InterfaceController.MainProcInterface(GuardiaoBrindes.Interface) InterfaceController.ClientProtocol(GuardiaoBrindes.Protocol) InterfaceController.MainProcWorldKey(GuardiaoBrindes.KeyListener) InterfaceController.InterfaceClickEvent(GuardiaoBrindes.ClickEvent) InterfaceController.ScrollMouse(GuardiaoBrindes.ScrollMouse) GuardiaoBrindes.Define() end --#endregion --#region DEFINE VARIAVEIS function GuardiaoBrindes.Define() GuardiaoBrindes_Config.TextArea = {onFocus = false, timer = 0, cursor = "|"} GuardiaoBrindes_Config.Codigo = "" GuardiaoBrindes_Config.AlertWindow = {Show = false, Type = 0} GuardiaoBrindes_Config.Lista ={ Codigo = {}, Item = {} } GuardiaoBrindes_Config.ShortLista = { Codigo = {}, Item = {} } GuardiaoBrindes_Config.ShortListaConfig = { Codigo = {Offset = 0, Count = 8, Steps = 0, CurrentStep = 0, Selected = {}}, Item = {Offset = 0, Count = 7, Steps = 0, CurrentStep = 0, Selected = {}} } GuardiaoBrindes_Config.Page = 0 GuardiaoBrindes_Config.Area = {sx = 260, ex = 450} GuardiaoBrindes_Config.Button = {} GuardiaoBrindes_Config.ButtonID = { fechar = 1, acessar = 2, meuscodigos = 3, textarea = 4, ok = 5 } GuardiaoBrindes_Config.Alfabeto = { [48] = "0",[49] = "1",[50] = "2",[51] = "3",[52] = "4",[53] = "5",[54] = "6",[55] = "7",[56] = "8",[57] = "9",[65] = "A",[66] = "B",[67] = "C",[68] = "D",[69] = "E",[70] = "F",[71] = "G",[72] = "H",[73] = "I",[74] = "J",[75] = "K",[76] = "L",[77] = "M",[78] = "N",[79] = "O",[80] = "P",[81] = "Q",[82] = "R",[83] = "S",[84] = "T",[85] = "U",[86] = "V",[87] = "W",[88] = "X",[89] = "Y",[90] = "Z",[96] = "0",[97] = "1",[98] = "2",[99] = "3",[100] = "4",[101] = "5",[102] = "6",[103] = "7",[104] = "8",[105] = "9",[109] = "-",[189] = "-" } end --#endregion --#region ABRE A JANELA function GuardiaoBrindes.Open() -- S3: o pack abria UIChaosBox/UIShop nativos so como "fundo" (S6). Aqui a -- janela e desenhada pelo proprio script em 260..450 e precisa do inventario. CloseAllWindowsExcept(-1) OpenWindow(UIInventory) UICustomInterface = GuardiaoBrindes_Config.WindowID end --#endregion --#region FECHA A JANELA function GuardiaoBrindes.Close() SetUnlockInterfaces() CloseWindow(UIInventory) UICustomInterface = 0 GuardiaoBrindes.Define() local pname = string.format("2-%s-%d", UserGetName(), UserGetIndex()) CreatePacket(pname, GuardiaoBrindes_Config.Packet) SendPacket(pname) ClearPacket(pname) end --#endregion --#region VERIFICA JANELA ABERTA E AREA PROTEGIDA DA TELA function GuardiaoBrindes.CheckOpen() if UICustomInterface == GuardiaoBrindes_Config.WindowID then return true else return false end end function GuardiaoBrindes.CheckArea(x) if x >= GuardiaoBrindes_Config.Area.sx and x <= GuardiaoBrindes_Config.Area.ex then return true end return false end --#endregion --#region FUN��ES DE BOT�O function GuardiaoBrindes.CreateButton(ButtonID, x, y, w, h) if GuardiaoBrindes_Config.Button[ButtonID] == nil then table.insert(GuardiaoBrindes_Config.Button, ButtonID) GuardiaoBrindes_Config.Button[ButtonID] = { x = x, y = y, w = w, h = h, clicked = false, timer = 0 } else GuardiaoBrindes_Config.Button[ButtonID].x = x GuardiaoBrindes_Config.Button[ButtonID].y = y GuardiaoBrindes_Config.Button[ButtonID].w = w GuardiaoBrindes_Config.Button[ButtonID].h = h end end function GuardiaoBrindes.ButtonClicked(ButtonID) if GuardiaoBrindes_Config.Button[ButtonID].clicked then if GuardiaoBrindes_Config.Button[ButtonID].timer >= 2 then GuardiaoBrindes_Config.Button[ButtonID].timer = 0 GuardiaoBrindes_Config.Button[ButtonID].clicked = false return false end GuardiaoBrindes_Config.Button[ButtonID].timer = GuardiaoBrindes_Config.Button[ButtonID].timer + 1 return true end return false end function GuardiaoBrindes.ButtonMouseOver(ButtonID, x, y) if x >= GuardiaoBrindes_Config.Button[ButtonID].x and x <= (GuardiaoBrindes_Config.Button[ButtonID].x+GuardiaoBrindes_Config.Button[ButtonID].w) then if y >= GuardiaoBrindes_Config.Button[ButtonID].y and y <= (GuardiaoBrindes_Config.Button[ButtonID].y+GuardiaoBrindes_Config.Button[ButtonID].h) then return true end end return false end --#endregion --#region FUN��ES BARRA DE ROLAGEM CODIGOS function GuardiaoBrindes.GerarScrollBarCodigos() GuardiaoBrindes_Config.ShortListaConfig.Codigo.Steps = #GuardiaoBrindes_Config.Lista.Codigo-#GuardiaoBrindes_Config.ShortLista.Codigo end function GuardiaoBrindes.GerarListaCodigos() local count = 1 GuardiaoBrindes_Config.ShortLista.Codigo = {} for i in ipairs(GuardiaoBrindes_Config.Lista.Codigo) do if i > GuardiaoBrindes_Config.ShortListaConfig.Codigo.Offset then if count <= GuardiaoBrindes_Config.ShortListaConfig.Codigo.Count then table.insert(GuardiaoBrindes_Config.ShortLista.Codigo, GuardiaoBrindes_Config.Lista.Codigo[i]) count = count + 1 end end end if GuardiaoBrindes_Config.Page ~= 1 then GuardiaoBrindes_Config.Page = 1 end end --#endregion --#region BARRA DE ROLAGEM ITENS function GuardiaoBrindes.GerarScrollBarItem(tipo) if tipo > 0 then GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep = 0 end GuardiaoBrindes_Config.ShortListaConfig.Item.Steps = #GuardiaoBrindes_Config.Lista.Item-#GuardiaoBrindes_Config.ShortLista.Item end function GuardiaoBrindes.GerarListaItem(tipo) local count = 1 if tipo > 0 then GuardiaoBrindes_Config.ShortListaConfig.Item.Offset = 0 GuardiaoBrindes_Config.ShortListaConfig.Item.Selected = {} end GuardiaoBrindes_Config.ShortLista.Item = {} for i in ipairs(GuardiaoBrindes_Config.Lista.Item) do if i > GuardiaoBrindes_Config.ShortListaConfig.Item.Offset then if count <= GuardiaoBrindes_Config.ShortListaConfig.Item.Count then table.insert(GuardiaoBrindes_Config.ShortLista.Item, GuardiaoBrindes_Config.Lista.Item[i]) count = count + 1 end end end if GuardiaoBrindes_Config.Page ~= 2 then GuardiaoBrindes_Config.Page = 2 end end --#endregion --#region INTERFACE function GuardiaoBrindes.Interface() GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.fechar,0, 0, 0, 0) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.acessar,0, 0, 0, 0) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.meuscodigos,0, 0, 0, 0) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.textarea,0, 0, 0, 0) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.ok,0, 0, 0, 0) if not GuardiaoBrindes.CheckOpen() then return end if CheckWindowOpen(UIInventory) == 0 then GuardiaoBrindes.Close() return end --#region BASE JANELA EnableAlphaTest(1) CreateInterface(IMG_WIN_TOP, 260, 0, 190, 256, 0, 0, 0.7424124, 1, 1,1) CreateInterface(IMG_WIN_LOW, 260, 256, 190, 177, 0, 0, 0.7424124, 0.6918124, 1,1) SetFont(0) SetTextBackColor(0, 0, 0, 255) SetTextColor(255, 255, 255, 240) SetText2(355, 15, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][1])) if GuardiaoBrindes.CheckArea(MousePosX()) or GuardiaoBrindes_Config.TextArea.onFocus then SetLockInterfaces() else SetUnlockInterfaces() end GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.fechar,470, 395, 24, 24) DisableAlphaBlend() --#endregion --#region JANELA INICIAL if GuardiaoBrindes_Config.Page == 0 then SetBlend() glColor4f(0.0, 0.0, 0.0, 0.6) DrawBar(280, 50, 150, 370) EndDrawBar() EnableAlphaTest(1) CreateInterface(IMG_LINE, 280, 50, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) for r = 54, 374, 40 do CreateInterface(IMG_LINE, 280, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) end CreateInterface(IMG_LINE, 280, 414, 150, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(GuardiaoBrindes_Config.Images.GB_Chest, 273, 60, 154, 135, 0, 0, 0.92982659, 0.8181264, 1,1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.acessar, 310, 330, 90, 24) CreateInterface(IMG_BTN, 310, 330, 90, 24, 0, 0, 0.875, 0.75, 1,1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.meuscodigos, 310, 368, 90, 24) CreateInterface(IMG_BTN, 310, 368, 90, 24, 0, 0, 0.875, 0.75, 1,1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.textarea, 300, 290, 110, 18) CreateInterface(IMG_EDITBOX, 300, 290, 110, 18, 0, 0, 0.8828125, 0.5625, 1, 1) DisableAlphaBlend() if not GuardiaoBrindes.ButtonClicked(GuardiaoBrindes_Config.ButtonID.acessar) then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, MousePosX(), MousePosY()) then SetBlend() glColor4f(0.7, 0.7, 0.7, 0.1) DrawBar(310, 330, 90, 24) EndDrawBar() end end if not GuardiaoBrindes.ButtonClicked(GuardiaoBrindes_Config.ButtonID.meuscodigos) then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.meuscodigos, MousePosX(), MousePosY()) then SetBlend() glColor4f(0.7, 0.7, 0.7, 0.1) DrawBar(310, 368, 90, 24) EndDrawBar() end end EnableAlphaTest(1) SetFont(0) SetTextBackColor(0, 0, 0, 50) SetTextColor(255, 85, 0, 255) SetText2(355, 190, GuardiaoBrindes_Config.Texts[getLanguage()][2]) SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) SetText2(355, 220, GuardiaoBrindes_Config.Texts[getLanguage()][3]) SetText2(355, 230, GuardiaoBrindes_Config.Texts[getLanguage()][4]) SetText2(355, 240, GuardiaoBrindes_Config.Texts[getLanguage()][5]) SetText2(355, 260, GuardiaoBrindes_Config.Texts[getLanguage()][6]) SetText2(355, 270, GuardiaoBrindes_Config.Texts[getLanguage()][7]) if GuardiaoBrindes_Config.TextArea.onFocus then if GuardiaoBrindes_Config.TextArea.timer >= 8 then if GuardiaoBrindes_Config.TextArea.timer >= 16 then GuardiaoBrindes_Config.TextArea.timer = 0 end SetText(315, 294, GuardiaoBrindes_Config.Codigo) else SetText(315, 294, GuardiaoBrindes_Config.Codigo..GuardiaoBrindes_Config.TextArea.cursor) end GuardiaoBrindes_Config.TextArea.timer = GuardiaoBrindes_Config.TextArea.timer + 1 else GuardiaoBrindes_Config.TextArea.timer = 0 SetText(315, 294, GuardiaoBrindes_Config.Codigo) end SetText2(355, 337, GuardiaoBrindes_Config.Texts[getLanguage()][8]) SetText2(355, 375, GuardiaoBrindes_Config.Texts[getLanguage()][9]) if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type == 0 then CreateInterface(IMG_PANEL, 210, 70, 180, 70, 0, 0, 0.83203125, 1.0, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.ok, 275, 110, 50, 15) if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) else CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) end SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) SetText2(300, 85, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][20])) SetText2(300, 95, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][21])) end if GuardiaoBrindes_Config.AlertWindow.Type == 1 then CreateInterface(IMG_PANEL, 210, 70, 180, 70, 0, 0, 0.83203125, 1.0, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.ok, 275, 110, 50, 15) if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) else CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) end SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) SetText2(300, 90, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][23])) end end DisableAlphaBlend() end --#endregion --#region JANELA MEUS CODIGOS if GuardiaoBrindes_Config.Page == 1 then SetBlend() glColor4f(0.0, 0.0, 0.0, 0.6) DrawBar(280, 50, 150, 84) DrawBar(280, 50, 150, 25) DrawBar(280, 180, 150, 234) DrawBar(280, 180, 150, 20) glColor4f(0.8, 0.8, 0.8, 0.1) local line = 229 local c = 1 while c < #GuardiaoBrindes_Config.ShortLista.Codigo do DrawBar(290, line, 110, 1) line = line+25 c = c+1 end c = nil EndDrawBar() EnableAlphaTest(1) CreateInterface(IMG_LINE, 280, 50, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 54, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 94, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 54, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 94, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 134, 150, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 180, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 184, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 184, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 200, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) for r = 214, 374, 40 do CreateInterface(IMG_LINE, 280, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) end CreateInterface(IMG_LINE, 280, 414, 150, 4, 0, 0, 0.83203125, 0.625, 1, 1) for r = 230, 350, 40 do CreateInterface(IMG_LINE, 413, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) end local cursorPos = 230 + (GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep*(150/(#GuardiaoBrindes_Config.Lista.Codigo-8))) CreateInterface(IMG_BTN, 407, cursorPos, 15, 10, 0, 0, 0.875, 0.75, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.acessar, 310, 146, 90, 24) CreateInterface(IMG_BTN, 310, 146, 90, 24, 0, 0, 0.875, 0.75, 1,1) DisableAlphaBlend() if not GuardiaoBrindes.ButtonClicked(GuardiaoBrindes_Config.ButtonID.acessar) then if GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.ListID ~= nil then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, MousePosX(), MousePosY()) then SetBlend() glColor4f(0.7, 0.7, 0.7, 0.1) DrawBar(310, 146, 90, 24) EndDrawBar() end else SetBlend() glColor4f(0.0, 0.0, 0.0, 0.4) DrawBar(310, 146, 90, 24) EndDrawBar() end end if MousePosX() >= 290 and MousePosX() <= 400 then local line = 204 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Codigo) do if MousePosY() >= line+1 and MousePosY() <= line+24 then SetBlend() glColor4f(1.0, 1.0, 1.0, 0.1) DrawBar(290, line+2, 110, 22) EndDrawBar() end line = line+25 end end EnableAlphaTest(1) SetFont(0) SetTextBackColor(0, 0, 0, 0) if GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.ListID ~= nil then SetTextColor(255, 255, 255, 255) else SetTextColor(255, 255, 255, 100) end SetText2(355, 153, GuardiaoBrindes_Config.Texts[getLanguage()][12]) if GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.ListID ~= nil then SetTextColor(255, 85, 0, 255) SetText2(355, 60, GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.Nome) SetTextColor(255, 208, 0, 180) SetText2(355, 79, GuardiaoBrindes_Config.Texts[getLanguage()][13]) SetText2(355, 109, GuardiaoBrindes_Config.Texts[getLanguage()][14]) SetTextColor(255, 255, 255, 255) SetText2(355, 89, GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.Codigo) if GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.TemValidade == 1 then SetText2(355, 119, GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.Data) else SetText2(355, 119, "-") end end SetTextColor(255, 85, 0, 255) SetText2(355, 188, GuardiaoBrindes_Config.Texts[getLanguage()][11]) SetTextColor(255, 255, 255, 255) local line = 212 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Codigo) do CreateInterface(GuardiaoBrindes_Config.Images.GB_Ponto, 290, line+2, 5, 5, 0, 0, 0.591827401425252121, 0.591827401425252121, 1, 1) SetText(300, line, string.format("%s", GuardiaoBrindes_Config.ShortLista.Codigo[i].Nome)) line = line+25 end if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type == 0 then CreateInterface(IMG_PANEL, 210, 70, 180, 70, 0, 0, 0.83203125, 1.0, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.ok, 275, 110, 50, 15) if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) else CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) end SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) SetText2(300, 85, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][20])) SetText2(300, 95, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][21])) end end DisableAlphaBlend() end --#endregion --#region JANELA ITENS if GuardiaoBrindes_Config.Page == 2 then SetBlend() glColor4f(0.0, 0.0, 0.0, 0.6) DrawBar(280, 50, 150, 114) DrawBar(280, 210, 150, 204) DrawBar(280, 210, 150, 20) glColor4f(0.8, 0.8, 0.8, 0.1) local line = 259 local c = 1 while c < #GuardiaoBrindes_Config.ShortLista.Item do DrawBar(290, line, 110, 1) line = line+25 c = c+1 end c = nil EndDrawBar() EnableAlphaTest(1) CreateInterface(IMG_LINE, 280, 50, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 54, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 94, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 124, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 54, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 94, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 124, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 164, 150, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 210, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 210, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, 210, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 280, 230, 151, 4, 0, 0, 0.83203125, 0.625, 1, 1) for r = 214, 374, 40 do CreateInterface(IMG_LINE, 280, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) CreateInterface(IMG_LINE, 426, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) end CreateInterface(IMG_LINE, 280, 414, 150, 4, 0, 0, 0.83203125, 0.625, 1, 1) for r = 245, 365, 40 do CreateInterface(IMG_LINE, 413, r, 4, 40, 0, 0, 0.015625, 0.625, 1, 1) end local cursorPos = 245 + (GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep*(150/(#GuardiaoBrindes_Config.Lista.Item-7))) CreateInterface(IMG_BTN, 407, cursorPos, 15, 10, 0, 0, 0.875, 0.75, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.acessar, 310, 175, 90, 24) CreateInterface(IMG_BTN, 310, 175, 90, 24, 0, 0, 0.875, 0.75, 1,1) DisableAlphaBlend() if not GuardiaoBrindes.ButtonClicked(GuardiaoBrindes_Config.ButtonID.acessar) then if GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.ListID ~= nil then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, MousePosX(), MousePosY()) then SetBlend() glColor4f(0.7, 0.7, 0.7, 0.1) DrawBar(310, 175, 90, 24) EndDrawBar() end else SetBlend() glColor4f(0.0, 0.0, 0.0, 0.4) DrawBar(310, 175, 90, 24) EndDrawBar() end end if GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.ListID ~= nil then CreateItem(GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.X, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Y, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.W, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.H, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Index) EndDrawBar() if GuardiaoBrindes_Config.Description then if MousePosX() >= GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.X and MousePosX() <= GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.X+GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.W then if MousePosY() >= GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Y and MousePosY() <= GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Y+GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.H then SetBlend() ShowItemDescription(MousePosX()+100, MousePosY()+110, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Index, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Level, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Skill, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Luck, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Opt, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Dur, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.Exc, 0) EndDrawBar() end end end end if MousePosX() >= 290 and MousePosX() <= 400 then local line = 234 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Item) do if MousePosY() >= line+1 and MousePosY() <= line+24 then SetBlend() glColor4f(1.0, 1.0, 1.0, 0.1) DrawBar(290, line+2, 110, 22) EndDrawBar() end line = line+25 end end EnableAlphaTest(1) SetFont(0) SetTextBackColor(0, 0, 0, 0) if GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.ListID ~= nil then SetTextColor(255, 255, 255, 255) else SetTextColor(255, 255, 255, 100) end SetText2(355, 182, GuardiaoBrindes_Config.Texts[getLanguage()][15]) SetTextColor(255, 85, 0, 255) SetText2(355, 217, GuardiaoBrindes_Config.Texts[getLanguage()][16]) SetTextColor(255, 255, 255, 255) local line = 244 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Item) do CreateInterface(GuardiaoBrindes_Config.Images.GB_Ponto, 290, line+2, 5, 5, 0, 0, 0.591827401425252121, 0.591827401425252121, 1, 1) SetText(300, line, string.format("%s", GuardiaoBrindes_Config.ShortLista.Item[i].Nome)) line = line+25 end if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type >= 0 then CreateInterface(IMG_PANEL, 210, 70, 180, 70, 0, 0, 0.83203125, 1.0, 1, 1) GuardiaoBrindes.CreateButton(GuardiaoBrindes_Config.ButtonID.ok, 275, 110, 50, 15) if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, MousePosX(), MousePosY()) then glColor4f(0.8, 0.8, 0.8, 1.0) CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) glColor4f(1.0, 1.0, 1.0, 1.0) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) else CreateInterface(IMG_BTN, 275, 110, 50, 15, 0, 0, 0.875, 0.75, 1, 1) SetFont(1) SetTextBackColor(0, 0, 0, 0) SetTextColor(30, 30, 30, 255) SetText(294, 113, "OK") SetFont(0) end SetFont(0) SetTextBackColor(0, 0, 0, 0) SetTextColor(255, 255, 255, 255) if GuardiaoBrindes_Config.AlertWindow.Type < 2 then SetText2(300, 90, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][17])) end if GuardiaoBrindes_Config.AlertWindow.Type == 2 then SetText2(300, 90, string.format(GuardiaoBrindes_Config.Texts[getLanguage()][18])) end end end DisableAlphaBlend() end --#endregion end --#endregion --#region DETECTA TECLADO function GuardiaoBrindes.KeyListener(key) if GetChatPlayerOpen() == 1 then return false end if not GuardiaoBrindes.CheckOpen() then return false end if not GuardiaoBrindes_Config.TextArea.onFocus then if key == Keys.I or key == Keys.V or key == Keys.Escape then GuardiaoBrindes.Close() return true end else if key == Keys.Escape then GuardiaoBrindes.Close() return true end end if GuardiaoBrindes_Config.Page == 0 then if GuardiaoBrindes_Config.TextArea.onFocus then if GetChatPlayerOpen() ~= 1 then if GuardiaoBrindes_Config.Alfabeto[key] ~= nil then if string.len(GuardiaoBrindes_Config.Codigo) < 16 then GuardiaoBrindes_Config.Codigo = GuardiaoBrindes_Config.Codigo..GuardiaoBrindes_Config.Alfabeto[key] GuardiaoBrindes_Config.TextArea.timer = 0 return true end end if key == 8 then if string.len(GuardiaoBrindes_Config.Codigo) > 0 then GuardiaoBrindes_Config.Codigo = GuardiaoBrindes_Config.Codigo:sub(1, -2) GuardiaoBrindes_Config.TextArea.timer = 0 return true end end end end end end --#endregion --#region DETECA CLIQUE ESQUERDO MOUSE function GuardiaoBrindes.ClickEvent() if not GuardiaoBrindes.CheckOpen() then return false end local x = MousePosX() local y = MousePosY() if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.fechar, x, y) then GuardiaoBrindes.Close() return true end if GuardiaoBrindes_Config.Page == 0 then if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type <= 1 then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, x, y) then GuardiaoBrindes_Config.Codigo = "" GuardiaoBrindes_Config.AlertWindow.Show = false GuardiaoBrindes_Config.AlertWindow.Type = 0 return true end end return true end if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, x, y) then if GuardiaoBrindes_Config.TextArea.onFocus then GuardiaoBrindes_Config.TextArea.onFocus = false end GuardiaoBrindes_Config.Button[GuardiaoBrindes_Config.ButtonID.acessar].clicked = true if string.len(GuardiaoBrindes_Config.Codigo) ~= 16 then GuardiaoBrindes_Config.Codigo = "" LogDebug(GuardiaoBrindes_Config.Texts[getLanguage()][19]) return true end GuardiaoBrindes.RequestItens() return true end if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.meuscodigos, x, y) then if GuardiaoBrindes_Config.TextArea.onFocus then GuardiaoBrindes_Config.TextArea.onFocus = false end local pname = string.format("3-%s-%d", UserGetName(), UserGetIndex()) CreatePacket(pname, GuardiaoBrindes_Config.Packet) SendPacket(pname) ClearPacket(pname) GuardiaoBrindes_Config.Button[GuardiaoBrindes_Config.ButtonID.meuscodigos].clicked = true return true end if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.textarea, x, y) then GuardiaoBrindes_Config.TextArea.onFocus = true return true else GuardiaoBrindes_Config.TextArea.onFocus = false return true end end if GuardiaoBrindes_Config.Page == 1 then if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type == 0 then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, x, y) then GuardiaoBrindes_Config.Codigo = "" GuardiaoBrindes_Config.AlertWindow.Show = false GuardiaoBrindes_Config.AlertWindow.Type = 0 end end return true end if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, x, y) then if GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.ListID ~= nil then GuardiaoBrindes_Config.Button[GuardiaoBrindes_Config.ButtonID.acessar].clicked = true GuardiaoBrindes.RequestItens() end return true end if x >= 290 and x <= 400 then local line = 204 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Codigo) do if y >= line+1 and y <= line+24 then GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected = GuardiaoBrindes_Config.ShortLista.Codigo[i] return true end line = line+25 end end end if GuardiaoBrindes_Config.Page == 2 then if GuardiaoBrindes_Config.AlertWindow.Show then if GuardiaoBrindes_Config.AlertWindow.Type > 0 then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, x, y) then GuardiaoBrindes_Config.AlertWindow.Show = false GuardiaoBrindes_Config.AlertWindow.Type = 0 return true end end if GuardiaoBrindes_Config.AlertWindow.Type == 0 then if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.ok, x, y) then GuardiaoBrindes.Define() return true end end return true end if GuardiaoBrindes.ButtonMouseOver(GuardiaoBrindes_Config.ButtonID.acessar, x, y) then if GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.ListID ~= nil then GuardiaoBrindes_Config.Button[GuardiaoBrindes_Config.ButtonID.acessar].clicked = true GuardiaoBrindes.RetirarItem() end return true end if x >= 290 and x <= 400 then local line = 234 for i in ipairs(GuardiaoBrindes_Config.ShortLista.Item) do if y >= line+1 and y <= line+24 then GuardiaoBrindes_Config.ShortListaConfig.Item.Selected = GuardiaoBrindes_Config.ShortLista.Item[i] return true end line = line+25 end end end end --#endregion --#region DETECTA SCROLL DO MOUSE function GuardiaoBrindes.ScrollMouse(Direction) local x = MousePosX() local y = MousePosY() if GuardiaoBrindes.CheckOpen() then if GuardiaoBrindes_Config.AlertWindow.Show then return true end if GuardiaoBrindes_Config.Page == 1 then if x >= 285 and x <= 425 and y >= 205 and y <= 415 then if Direction > 0 then if GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep > 0 then GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep = GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep - 1 GuardiaoBrindes_Config.ShortListaConfig.Codigo.Offset = GuardiaoBrindes_Config.ShortListaConfig.Codigo.Offset - 1 GuardiaoBrindes.GerarListaCodigos() end else if GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep < GuardiaoBrindes_Config.ShortListaConfig.Codigo.Steps then GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep = GuardiaoBrindes_Config.ShortListaConfig.Codigo.CurrentStep + 1 GuardiaoBrindes_Config.ShortListaConfig.Codigo.Offset = GuardiaoBrindes_Config.ShortListaConfig.Codigo.Offset + 1 GuardiaoBrindes.GerarListaCodigos() end end return true end end if GuardiaoBrindes_Config.Page == 2 then if x >= 285 and x <= 425 and y >= 230 and y <= 415 then if Direction > 0 then if GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep > 0 then GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep = GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep - 1 GuardiaoBrindes_Config.ShortListaConfig.Item.Offset = GuardiaoBrindes_Config.ShortListaConfig.Item.Offset - 1 GuardiaoBrindes.GerarListaItem(0) end else if GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep < GuardiaoBrindes_Config.ShortListaConfig.Item.Steps then GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep = GuardiaoBrindes_Config.ShortListaConfig.Item.CurrentStep + 1 GuardiaoBrindes_Config.ShortListaConfig.Item.Offset = GuardiaoBrindes_Config.ShortListaConfig.Item.Offset + 1 GuardiaoBrindes.GerarListaItem(0) end end return true end end end end --#endregion --#region RECEBE PACKETS DO SERVIDOR function GuardiaoBrindes.Protocol(Packet, PacketName) if Packet == GuardiaoBrindes_Config.Packet then if PacketName == string.format("1-%s-%d", UserGetName(), UserGetIndex()) then ClearPacket(PacketName) GuardiaoBrindes.Open() return true end if PacketName == string.format("4-%s-%d", UserGetName(), UserGetIndex()) then GuardiaoBrindes_Config.Lista.Codigo = {} local qtd = GetDwordPacket(PacketName, -1) for l = 1, qtd do local lenCodigo = GetBytePacket(PacketName, -1) local codigo = GetCharPacketLength(PacketName, -1, lenCodigo) local lenNome = GetBytePacket(PacketName, -1) local nomecodigo = GetCharPacketLength(PacketName, -1, lenNome) local temvalidade = GetBytePacket(PacketName, -1) local data = os.date("%d/%m/%Y %X", GetDwordPacket(PacketName, -1)) table.insert(GuardiaoBrindes_Config.Lista.Codigo, {ListID = l, Codigo = codigo, Nome = nomecodigo, TemValidade = temvalidade, Data = data}) end ClearPacket(PacketName) GuardiaoBrindes.GerarListaCodigos() GuardiaoBrindes.GerarScrollBarCodigos() return true end if PacketName == string.format("6-%s-%d", UserGetName(), UserGetIndex()) then GuardiaoBrindes_Config.Lista.Item = {} local qtd = GetBytePacket(PacketName, -1) for l = 1, qtd do local itemid = GetDwordPacket(PacketName, -1) local lenNome = GetBytePacket(PacketName, -1) local nomeitem = GetCharPacketLength(PacketName, -1, lenNome) local index = GetWordPacket(PacketName, -1) local level = GetBytePacket(PacketName, -1) local dur = GetBytePacket(PacketName, -1) local skill = GetBytePacket(PacketName, -1) local luck = GetBytePacket(PacketName, -1) local opt = GetBytePacket(PacketName, -1) local exc = GetBytePacket(PacketName, -1) local x = GetWordPacket(PacketName, -1) local y = GetWordPacket(PacketName, -1) local w = GetWordPacket(PacketName, -1) local h = GetWordPacket(PacketName, -1) table.insert(GuardiaoBrindes_Config.Lista.Item, { ListID = l, ItemID = itemid, Nome = nomeitem, Index = index, Level = level, Dur = dur, Skill = skill, Luck = luck, Opt = opt, Exc = exc, X = x, Y = y, W = w, H = h }) end local tipo = GetBytePacket(PacketName, -1) ClearPacket(PacketName) if tipo > 0 then GuardiaoBrindes_Config.AlertWindow.Type = tipo GuardiaoBrindes_Config.AlertWindow.Show = true end GuardiaoBrindes.GerarListaItem(tipo) GuardiaoBrindes.GerarScrollBarItem(tipo) return true end if PacketName == string.format("8-%s-%d", UserGetName(), UserGetIndex()) then ClearPacket(PacketName) GuardiaoBrindes_Config.AlertWindow.Type = 0 GuardiaoBrindes_Config.AlertWindow.Show = true return true end if PacketName == string.format("9-%s-%d", UserGetName(), UserGetIndex()) then ClearPacket(PacketName) GuardiaoBrindes_Config.AlertWindow.Type = 1 GuardiaoBrindes_Config.AlertWindow.Show = true return true end end end --#endregion --#region SOLICITA LISTA DE ITENS function GuardiaoBrindes.RequestItens() if GuardiaoBrindes_Config.Page == 1 then GuardiaoBrindes_Config.Codigo = GuardiaoBrindes_Config.ShortListaConfig.Codigo.Selected.Codigo end local pname = string.format("5-%s-%d", UserGetName(), UserGetIndex()) CreatePacket(pname, GuardiaoBrindes_Config.Packet) local len = string.len(GuardiaoBrindes_Config.Codigo) SetBytePacket(pname, len) SetCharPacketLength(pname, GuardiaoBrindes_Config.Codigo, len) SendPacket(pname) ClearPacket(pname) end --#endregion --#region RETIRA UM ITEM function GuardiaoBrindes.RetirarItem() local pname = string.format("7-%s-%d", UserGetName(), UserGetIndex()) CreatePacket(pname, GuardiaoBrindes_Config.Packet) local len = string.len(GuardiaoBrindes_Config.Codigo) SetBytePacket(pname, len) SetCharPacketLength(pname, GuardiaoBrindes_Config.Codigo, len) SetDwordPacket(pname, GuardiaoBrindes_Config.ShortListaConfig.Item.Selected.ItemID) SendPacket(pname) ClearPacket(pname) end --#endregion GuardiaoBrindes.Init() return GuardiaoBrindes