Message
Message
----- enQ#1349
-------------------------------------------------------------------------
-- #region :: Header
--
-- #region : Definitions
--#region: localization
--#endregion
--#region: globals
local ternary = function (c, a, b) if c then return a else return b end end
local contend = function (func, callback, ...)
      local t = { pcall(func, ...) }
      if not t[1] then return type(callback) == "function" and callback(t[2]) or
error(t[2], callback or 2) end
      return unpack(t, 2)
end
--#endregion
local dirs = {
      execute = function (t, path, func)
            local p, k for _, s in ipairs(path) do
                  k, p, t = s, t, t[s]
                  if t == nil then return end
            end
            if p[k] then func(p[k]) end
      end,
      replace = function (t, path, value)
            local p, k for _, s in ipairs(path) do
                  k, p, t = s, t, t[s]
                  if t == nil then return end
            end
            p[k] = value
      end,
      find = function (t, path)
            local p, k for _, s in ipairs(path) do
                  k, p, t = s, t, t[s]
                  if t == nil then return end
            end
            return p[k]
      end,
}
--#endregion
-- #endregion
--
--
-- #region : Elements
--#region: arguments
local registry, ragebot, players = {}, {}, {}
local elements = {
      button            = { type = "function", arg = 2, unsavable = true },
      checkbox    = { type = "boolean",   arg = 1, init = false   },
      color_picker= { type = "table",           arg = 5 },
      combobox    = { type = "string",    arg = 2, variable = true },
      hotkey            = { type = "table",           arg = 3, enum = {[0] =
"Always on", "On hotkey", "Toggle", "Off hotkey"} },
      label       = { type = "string",    arg = 1, unsavable = true },
      listbox           = { type = "number",    arg = 2, init = 0, variable =
true },
      multiselect = { type = "table",           arg = 2, init = {}, variable = true
},
      slider            = { type = "number",    arg = 8 },
      textbox           = { type = "string",    arg = 1, init = "" },
      string            = { type = "string",    arg = 2, init = "" },
      unknown           = { type = "string",    arg = 2, init = "" } -- new_string
type
}
local weapons = { "Global", "G3SG1 / SCAR-20", "SSG 08", "AWP", "R8 Revolver",
"Desert Eagle", "Pistol", "Zeus", "Rifle", "Shotgun", "SMG", "Machine gun" }
--#endregion
--#region: registry
do
     client.set_event_callback("shutdown", function ()
           for k, v in next, registry do
                 if v.__ref and not v.__rage then
                       if v.overridden then ui_mset(k, v.original) end
                       ui.set_enabled(k, true)
                       ui.set_visible(k, not v.__hidden)
                 end
           end
           ragebot.cycle(function (active)
                 for k, v in pairs(ragebot.context[active]) do
                       if v ~= nil and registry[k].overridden then
                             ui_mset(k, v)
                       end
                 end
           end, true)
     end)
     client.set_event_callback("pre_config_save", function ()
           for k, v in next, registry do
                 if v.__ref and not v.__rage and v.overridden then
                       v.ovr_restore = { ui_mget(k) }
                       ui_mset(k, v.original)
                 end
           end
           ragebot.cycle(function (active)
                 for k, v in pairs(ragebot.context[active]) do
                       if registry[k].overridden then
                             ragebot.cache[active][k] = { ui_mget(k) }
                             ui_mset(k, v)
                       end
                 end
           end, true)
      end)
      client.set_event_callback("post_config_save", function ()
            for k, v in next, registry do
                  if v.__ref and not v.__rage and v.overridden then
                        ui_mset(k, unpack(v.ovr_restore))
                        v.ovr_restore = nil
                  end
            end
            ragebot.cycle(function (active)
                  for k, v in pairs(ragebot.context[active]) do
                        if registry[k].overridden and ragebot.cache[active][k] ~=
nil then
                              ui_mset(k, unpack(ragebot.cache[active][k]))
                              ragebot.cache[active][k] = nil
                        end
                  end
            end, true)
      end)
end
--#endregion
--#region: elemence
local elemence = {} do
      local callbacks = function (this, isref)
            if this.name == "Weapon type" and string.lower(registry[this.ref].tab)
== "rage" then return ui.get(this.ref) end
           self.ref = ref
           self.name, self.type = ui.name(ref), ui.type(ref)
            --
            registry[ref] = registry[ref] or {
                  type = self.type, ref = ref, tab = add.__tab, container =
add.__container,
                  __ref = add.__ref, __hidden = add.__hidden, __init = add.__init,
__list = add.__list, __rage = add.__rage,
                  __plist = add.__plist and not (self.type == "label" or self.type
== "button" or self.type == "hotkey"),
           if add.__rage then
                 methods_mt.element.set_callback(self, ragebot.memorize)
           end
           if registry[ref].__plist then
                 players.elements[#players.elements+1] = self
                 methods_mt.element.set_callback(self, players.slot_update, true)
           end
           return self
     end
              if self.color then
                    path[#path] = path[#path] .. "_c"
                    dirs.pave(origin, self.color.ref, path)
              end
              if self.hotkey then
                    path[#path] = path[#path] .. "_h"
                    dirs.pave(origin, self.hotkey.ref, path)
              end
     end
      elemence.hidden_refs = {
            "Unlock hidden cvars", "Allow custom game events", "Faster grenade
toss",
            "sv_maxunlag", "sv_maxusrcmdprocessticks", "sv_clockcorrection_msecs",
-- m4kb12jk
      }
--#region: depend
     local cases = {
           combobox = function (v)
                 if v[3] == true then
                       return v[1].value ~= v[2]
                 else
                       for i = 2, #v do
                             if v[1].value == v[i] then return true end
                       end
                 end
                 return false
           end,
           listbox = function (v)
                 if v[3] == true then
                       return v[1].value ~= v[2]
                 else
                       for i = 2, #v do
                             if v[1].value == v[i] then return true end
                       end
                 end
                 return false
           end,
           multiselect = function (v)
                 return table.ihas(v[1].value, unpack(v, 2))
           end,
           slider = function (v)
                 return v[2] <= v[1].value and v[1].value <= (v[3] or v[2])
           end,
     }
           for i = 1, #owner do
                 if depend(owner[i]) then count = count + 1 else break end
            end
      --#endregion
end
--#endregion
--#region: utils
local utils = {}
do
      utils.rgb_to_hex = function (color)
            return string.format("%02X%02X%02X%02X", color[1], color[2], color[3],
color[4] or 255)
      end
            local i = 0
            for letter in string.gmatch(text, ".[\128-\191]*") do
                  i = i + 1
symbols[#symbols+1] = "\aCDCDCDFF"
            return table.concat(symbols)
      end
           return arg
     end
--#region: dispense
     local dispensers = {
           color_picker = function (args)
                 args[1] = string.sub(utils.format(args[1]), 1, 117)
           if dispensers[key] then
                 dispensers[key](args, variable)
           else
                 for i = 1, args.n do
                         if type(args[i]) == "string" then
                               args[i] = string.sub(utils.format(args[i]), 1, 117)
                         end
      --#endregion
end
--#endregion
-- #endregion
--
-- #endregion -----------------------------------------------------------
--
-------------------------------------------------------------------------
-- #region :: pui
--
-- #region : pui
--#region: variables
pui.macros = setmetatable({}, {
      __newindex = function (self, key, value) rawset(self, tostring(key), value)
end,
      __index = function (self, key) return rawget(self, tostring(key)) end
})
do
      local reference = ui.reference("MISC", "Settings", "Menu color")
      pui.accent = utils.rgb_to_hex{ ui.get(reference) }
      local previous = pui.accent
      ui.set_callback(reference, function ()
            local color = { ui.get(reference) }
            pui.accent = utils.rgb_to_hex(color)
client.set_event_callback("paint_ui", function ()
      local state = ui.is_menu_open()
      if state ~= pui.menu_open then
            client.fire_event("pui::menu_state", state)
            pui.menu_open = state
      end
end)
--#endregion
--#region: features
pui.format = utils.format
      for i, v in ipairs(found) do
            found[i] = elemence.new(v, {
                  __ref = true, __hidden = hidden or nil,
                  __tab = tab, __container = container,
                  __rage = string.lower(container) == "aimbot" or nil,
            })
      end
--#endregion
do
      local save = function (config, ...)
            local packed = {}
            return packed
      end
       --
       local package_mt = {
             __type = "pui::package", __metatable = false,
             __call = function (self, raw, ...)
                   return (type(raw) == "table" and load or save)(self[0], raw, ...)
             end,
             save = function (self, ...) return save(self[0], ...) end,
             load = function (self, ...) load(self[0], ...) end,
       }     package_mt.__index = package_mt
--#endregion
-- #endregion
--
--
-- #region : methods
methods_mt.element = {
      __type = "pui::element", __name = "pui::element", __metatable = false,
      __eq = function (this, that) return this.ref == that.ref end,
      __tostring = function (self) return string.format('pui.%s[%d] "%s"',
self.type, self.ref, self.name) end,
      __call = function (self, ...) if #{...} > 0 then ui.set(self.ref, ...) else
return ui.get(self.ref) end end,
--
     registry[v[1].ref].callbacks[#registry[v[1].ref].callbacks+1] = check
                 end
           end
            return self
     end,
--
methods_mt.group = {
      __name = "pui::group",
      __metatable = false,
      __index = function (self, key) return rawget(methods_mt.group, key) or
pui_mt.__index(self, key) end,
      get_location = function (self) return self[1], self[2] end
}
-- #endregion
--
--
-- #region : pui_mt, ragebot and plist handler
do
     local cached = {}
     for k, v in next,   elements do
           cached[k] =   function (origin, ...)
                 local   args, group = utils.dispense(k, origin, ...)
                 local   this = elemence.new( contend(ui["new_".. k], 3, group[1],
group[2], unpack(args, 1, args.n < args.req and args.n or args.req)), args.data )
                   elemence.features(this, args.misc)
                   return this
             end
      end
             return cached[key]
      end
end
ragebot = {
      ref = pui.reference("RAGE", "Weapon type", "Weapon type"),
      context = {}, cache = {},
      silent = false,
} do
      local previous, cycle_action = ragebot.ref.value, nil
      for i, v in ipairs(weapons) do ragebot.context[v], ragebot.cache[v] = {}, {}
end
             for i, v in ipairs(weapons) do
                   ragebot.ref:override(v)
             end
             ragebot.ref:override()
             cycle_action, ragebot.silent = nil, false
      end
             previous = ragebot.ref.value
      end)
--#endregion
players = {
      elements = {}, list = {},
} do
      --#region: stuff
      local selected = 0
      local refs, slot = {
            list = pui.reference("PLAYERS", "Players", "Player list"),
            reset = pui.reference("PLAYERS", "Players", "Reset all"),
            apply = pui.reference("PLAYERS", "Adjustments", "Apply to all"),
      }, {}
--#endregion
      local slot_mt = {
            __type = "pui::player_slot", __metatable = false,
            __tostring = function (self)
                  return string.format("pui::player_slot[%d] of %s", self.idx,
methods_mt.element.__tostring(registry[self.ref].self))
            end,
            set = function (self, ...) -- don't mind
                  local ctx, value = registry[self.ref], {...}
--#endregion
      slot = {
            select = function (idx)
                  if not idx then return end
                  for i, v in ipairs(players.elements) do
                        methods_mt.element.set(v, v[idx].value)
                  end
            end,
            add = function (idx)
                  if not idx then return end
                  for i, v in ipairs(players.elements) do
                        local default = ternary(registry[v.ref].__init ~= nil,
registry[v.ref].__init, v.value)
                        v[idx], players.list[idx] = setmetatable({
                              ref = v.ref, idx = idx, value = default
                        }, slot_mt), true
                  end
            end,
            remove = function (idx)
                  if not idx then return end
                  for i, v in ipairs(players.elements) do
                        v[idx], players.list[idx] = nil, nil
                  end
            end,
      }
     --#endregion
      --#region: callbacks
            slot.select(selected)
            client.fire_event("pui::plist_update", selected)
      end
      do
            local function once ()
                  update{}
                  client.unset_event_callback("pre_render", once)
            end
            client.set_event_callback("pre_render", once)
      end
      methods_mt.element.set_callback(refs.list, update, true)
      client.set_event_callback("player_connect_full", update)
      client.set_event_callback("player_disconnect", update)
      client.set_event_callback("player_spawned", update)
      client.set_event_callback("player_spawn", update)
      client.set_event_callback("player_death", update)
      client.set_event_callback("player_team", update)
--
      methods_mt.element.set_callback(refs.apply, function ()
            players.traverse(function (v)
                  for idx, _ in next, players.list do
                        v[idx].value = v[selected].value
                  end
           end)
      end)
      methods_mt.element.set_callback(refs.reset, function ()
            players.traverse(function (v)
                  for idx, _ in next, players.list do
                        if idx == selected then
                              slot_mt.set(v[idx], registry[v.ref].__init)
                        else
                              v[idx].value = registry[v.ref].__init
                        end
                  end
            end)
      end)
      --#endregion
end
--#endregion
-- #endregion
--
-- #endregion -----------------------------------------------------------
--