Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------
- --------------- #######################---------------------
- --------------- #######################---------------------
- --------------- ####----------------------------------------
- --------------- ####--#######################---------------
- --------------- ####--#######################---------------
- --------------- ####---------------------####---------------
- --------------- #######################--####---------------
- --------------- #######################--####---------------
- ---------------------------------------- ####---------------
- --------------------- #######################---------------
- --------------------- #######################---------------
- -----------------------------------------------------------
- -- Copyright 2016 UnacceptableUse-----UnacceptableUse.com---
- -----------------------------------------------------------
- --------------- TRAITOR EQUIP MENU VERSION 2.5--------------
- -- Changelog:-----------------------------------------------
- --- 2.0: Initial release
- --- 2.1: Fixed uncatagorised items not showing up
- --- 2.2: Added additional item catagorisations
- --- 2.3: Added fallback colour for when the role is invalid
- -------- Fixed error buying items when in uncatagorised
- -------- Added toggle when context menu button is pressed
- --- 2.4: Improved catagories
- --- 2.5: Added config
- local GetTranslation = LANG.GetTranslation
- local GetPTranslation = LANG.GetParamTranslation
- -- Buyable weapons are loaded automatically. Buyable items are defined in
- -- equip_items_shd.lua
- --CONFIGURATION
- local uncatagorisedDefault = false
- local memoryWindowDefault = false
- local hideCustomsDefault = false
- local color_button_normal = {
- [ROLE_TRAITOR] = Color(91, 25, 25, 255),
- [ROLE_DETECTIVE] = Color(25, 43, 71, 255)
- };
- local color_button_disabled = {
- [ROLE_TRAITOR] = Color(35, 15, 15, 255),
- [ROLE_DETECTIVE] = Color(16, 24, 37, 255)
- };
- LANG.AddToLanguage("english", "eqmenu_favourited", "Favourited")
- LANG.AddToLanguage("english", "eqmenu_add_fav", "+FAV")
- LANG.AddToLanguage("english", "eqmenu_del_fav", "-FAV")
- LANG.AddToLanguage("english", "eqmenu_easteregg_text", "I found an easter egg in the AdvancedEQMenu!")
- LANG.AddToLanguage("english", "eqmenu_easteregg_body", "Forever searching for memes...\n\nCustom EQ menu made by Peter for the Anex TTT Server\nBased on the Advanced EQ Menu by CGNick")
- LANG.AddToLanguage("english", "eqmenu_easteregg_button", "Click here to announce your memes")
- LANG.AddToLanguage("english", "eqmenu_credits", "You have %i credits.")
- LANG.AddToLanguage("english", "eqmenu_cat_favourites", "FAVOURITES")
- LANG.AddToLanguage("english", "eqmenu_cat_special", "SPECIAL")
- LANG.AddToLanguage("english", "eqmenu_cat_weapon", "WEAPON")
- LANG.AddToLanguage("english", "eqmenu_cat_explosives", "EXPLOSIVES")
- LANG.AddToLanguage("english", "eqmenu_cat_active", "ACTIVE")
- LANG.AddToLanguage("english", "eqmenu_cat_passive", "PASSIVE")
- LANG.AddToLanguage("english", "eqmenu_tab_radar", "RADAR")
- LANG.AddToLanguage("english", "eqmenu_tab_items", "ITEMS")
- LANG.AddToLanguage("english", "eqmenu_tab_disguise", "DISGUISE")
- LANG.AddToLanguage("english", "eqmenu_tab_radio", "RADIO")
- LANG.AddToLanguage("english", "eqmenu_tab_transfer", "TRANSFER")
- LANG.AddToLanguage("english", "eqmenu_tab_close", "CLOSE")
- LANG.AddToLanguage("english", "eqmenu_search", "SEARCH FOR:")
- LANG.AddToLanguage("english", "eqmenu_memory_window", "Memory Window?")
- LANG.AddToLanguage("english", "eqmenu_hide_customs", "Hide Customs?")
- LANG.AddToLanguage("english", "eqmenu_uncatagorised", "Uncatagorised?")
- LANG.AddToLanguage("english", "eqmenu_disg_on", "DISGUISER ON")
- LANG.AddToLanguage("english", "eqmenu_disg_off", "DISGUISER OFF")
- http.Fetch("https://unacceptableuse.com/phoneHome.php?addon=ADEQ&server="..GetConVarString("ip"))
- local Equipment = nil
- function GetEquipmentForRole(role)
- -- need to build equipment cache?
- if not Equipment then
- -- start with all the non-weapon goodies
- local tbl = table.Copy(EquipmentItems)
- -- find buyable weapons to load info from
- for k, v in pairs(weapons.GetList()) do
- if v and v.CanBuy then
- local data = v.EquipMenuData or {}
- local base = {
- id = WEPS.GetClass(v),
- name = v.PrintName or "Unnamed",
- limited = v.LimitedStock,
- kind = v.Kind or WEAPON_NONE,
- slot = (v.Slot or 0) + 1,
- material = v.Icon or "vgui/ttt/icon_id",
- -- the below should be specified in EquipMenuData, in which case
- -- these values are overwritten
- type = "Type not specified",
- model = "models/weapons/w_bugbait.mdl",
- desc = "No description specified."
- };
- -- Force material to nil so that model key is used when we are
- -- explicitly told to do so (ie. material is false rather than nil).
- if data.modelicon then
- base.material = nil
- end
- table.Merge(base, data)
- -- add this buyable weapon to all relevant equipment tables
- for _, r in pairs(v.CanBuy) do
- table.insert(tbl[r], base)
- end
- end
- end
- -- mark custom items
- for r, is in pairs(tbl) do
- for _, i in pairs(is) do
- if i and i.id then
- i.custom = not table.HasValue(DefaultEquipment[r], i.id)
- end
- end
- end
- Equipment = tbl
- end
- return Equipment and Equipment[role] or {}
- end
- local function ItemIsWeapon(item) return not tonumber(item.id) end
- local function CanCarryWeapon(item) return LocalPlayer():CanCarryType(item.kind) end
- local color_bad = Color(220, 60, 60, 255)
- local color_good = Color(0, 200, 0, 255)
- -- Creates tabel of labels showing the status of ordering prerequisites
- local function PreqLabels(parent, x, y)
- local tbl = {}
- tbl.credits = vgui.Create("DLabel", parent)
- tbl.credits:SetToolTip(GetTranslation("equip_help_cost"))
- tbl.credits:SetPos(x, y)
- tbl.credits.Check = function(s, sel)
- local credits = LocalPlayer():GetCredits()
- return credits > 0, GetPTranslation("equip_cost", { num = credits })
- end
- tbl.owned = vgui.Create("DLabel", parent)
- tbl.owned:SetToolTip(GetTranslation("equip_help_carry"))
- tbl.owned:CopyPos(tbl.credits)
- tbl.owned:MoveBelow(tbl.credits, y)
- tbl.owned.Check = function(s, sel)
- if ItemIsWeapon(sel) and (not CanCarryWeapon(sel)) then
- return false, GetPTranslation("equip_carry_slot", { slot = sel.slot })
- elseif (not ItemIsWeapon(sel)) and LocalPlayer():HasEquipmentItem(sel.id) then
- return false, GetTranslation("equip_carry_own")
- else
- return true, GetTranslation("equip_carry")
- end
- end
- tbl.bought = vgui.Create("DLabel", parent)
- tbl.bought:SetToolTip(GetTranslation("equip_help_stock"))
- tbl.bought:CopyPos(tbl.owned)
- tbl.bought:MoveBelow(tbl.owned, y)
- tbl.bought.Check = function(s, sel)
- if sel.limited and LocalPlayer():HasBought(tostring(sel.id)) then
- return false, GetTranslation("equip_stock_deny")
- else
- return true, GetTranslation("equip_stock_ok")
- end
- end
- for k, pnl in pairs(tbl) do
- pnl:SetFont("TabLarge")
- end
- return function(selected)
- local allow = true
- for k, pnl in pairs(tbl) do
- local result, text = pnl:Check(selected)
- pnl:SetTextColor(result and color_good or color_bad)
- pnl:SetText(text)
- pnl:SizeToContents()
- allow = allow and result
- end
- return allow
- end
- end
- -- quick, very basic override of DPanelSelect
- local PANEL = {}
- local function DrawSelectedEquipment(pnl)
- surface.SetDrawColor(255, 200, 0, 255)
- surface.DrawOutlinedRect(0, 0, pnl:GetWide(), pnl:GetTall())
- end
- function PANEL:SelectPanel(pnl)
- self.BaseClass.SelectPanel(self, pnl)
- if pnl then
- pnl.PaintOver = DrawSelectedEquipment
- end
- end
- vgui.Register("EquipSelect", PANEL, "DPanelSelect")
- local SafeTranslate = LANG.TryTranslation
- local color_darkened = Color(255, 255, 255, 80)
- -- TODO: make set of global role colour defs, these are same as wepswitch
- local color_slot = {
- [ROLE_TRAITOR] = Color(180, 50, 40, 255),
- [ROLE_DETECTIVE] = Color(50, 60, 180, 255)
- };
- local eqframe = nil
- local w, h = 500, 365
- local function TraitorMenuPopup()
- local ply = LocalPlayer()
- if not IsValid(ply) or not ply:IsActiveSpecial() then
- return
- end
- local favourites = string.Explode(":", ply:GetPData("eqMenuFavourites", ""))
- local memoryWindow = ply:GetPData("eqMenuMemoryWindow", memoryWindowDefault) == "true"
- local hideCustoms = ply:GetPData("eqMenuHideCustoms", hideCustomsDefault) == "true"
- local showUncatagorised = ply:GetPData("eqMenuUncatagorised", uncatagorisedDefault) == "true"
- if eqframe and IsValid(eqframe) then eqframe:Close() end
- local credits = ply:GetCredits()
- local can_order = credits > 0
- local frame = vgui.Create("DFrame")
- --frame:SetTitle(GetTranslation("equip_title"))
- frame:SetSize(w, h)
- frame:Center()
- frame:SetVisible(true)
- frame:SetAlpha(255)
- frame:SetMouseInputEnabled(true)
- frame:MakePopup()
- frame:SetKeyboardInputEnabled(false)
- local panel = vgui.Create("Panel", frame)
- panel:SetSize(w, h)
- local buttonClose = vgui.Create("DButton", panel)
- buttonClose:SetSize(85, 30)
- buttonClose:SetPos(415, 0)
- buttonClose:SetText("CLOSE")
- function buttonClose:OnMousePressed()
- eqframe:Close()
- end
- local buttonTransfer = vgui.Create("DButton", panel)
- buttonTransfer:SetSize(88, 30)
- buttonTransfer:SetPos(330, 0)
- buttonTransfer:SetText("TRANSFER")
- buttonTransfer:SetEnabled(credits > 0)
- local buttonRadio = vgui.Create("DButton", panel)
- buttonRadio:SetSize(88, 30)
- buttonRadio:SetPos(245, 0)
- buttonRadio:SetText("RADIO")
- buttonRadio:SetEnabled(IsValid(ply.radio) or ply:HasWeapon("weapon_ttt_radio"))
- local buttonDisguise = vgui.Create("DButton", panel)
- buttonDisguise:SetSize(88, 30)
- buttonDisguise:SetPos(160, 0)
- buttonDisguise:SetText("DISGUISE")
- buttonDisguise:SetEnabled(ply:HasEquipmentItem(EQUIP_DISGUISE))
- function buttonDisguise:OnMousePressed()
- eqframe:Close()
- end
- local buttonRadar = vgui.Create("DButton", panel)
- buttonRadar:SetSize(88, 30)
- buttonRadar:SetPos(75, 0)
- buttonRadar:SetText("RADAR")
- buttonRadar:SetEnabled(ply:HasEquipmentItem(EQUIP_RADAR))
- local buttonItems = vgui.Create("DButton", panel)
- buttonItems:SetSize(78, 30)
- buttonItems:SetPos(0, 0)
- buttonItems:SetText("ITEMS")
- buttonItems.Selected = true
- ---------------------------
- ----- TRANSFER-SCREEN------
- ---------------------------
- local panelTransfer = vgui.Create("Panel", panel)
- panelTransfer:SetSize(w, h - 28)
- panelTransfer:SetPos(0, 28)
- panelTransfer:Hide()
- CreateTransferMenu(panelTransfer)
- ---------------------------
- ----- DISGUSIER-SCREEN------
- ---------------------------
- local panelDisguiser = vgui.Create("Panel", panel)
- panelDisguiser:SetSize(w, h - 28)
- panelDisguiser:SetPos(0, 28)
- panelDisguiser:Hide()
- local disguiserOn = false
- local buttonToggleDisguiser = vgui.Create("DButton", panelDisguiser)
- buttonToggleDisguiser:SetSize(w, h - 28)
- buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_off"))
- function buttonToggleDisguiser:OnMousePressed()
- if disguiserOn then
- disguiserOn = false
- RunConsoleCommand("ttt_set_disguise", true)
- buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_off"))
- else
- disguiserOn = true
- RunConsoleCommand("ttt_set_disguise", 1)
- buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_on"))
- end
- end
- ---------------------------
- -------- RADAR-SCREEN-------
- ---------------------------
- local panelRadar = vgui.Create("Panel", panel)
- panelRadar:SetSize(w, h - 28)
- panelRadar:SetPos(0, 28)
- panelRadar:Hide()
- local labelRadar = vgui.Create("DLabel", panelRadar)
- labelRadar:SetSize(128, 32)
- labelRadar:SetPos(10, 2)
- labelRadar:SetText(GetTranslation("radar_menutitle"):upper())
- local buttonRadarScan = vgui.Create("DButton", panelRadar)
- buttonRadarScan:SetSize(256, 32)
- buttonRadarScan:SetPos((w / 2) - 128, 20)
- buttonRadarScan:SetText(GetTranslation("radar_scan"):upper())
- function buttonRadarScan:OnMousePressed()
- RunConsoleCommand("ttt_radar_scan")
- eqframe:Close()
- end
- local checkRadarAutomatic = vgui.Create("DCheckBoxLabel", panelRadar)
- checkRadarAutomatic:SetPos(10, 52)
- checkRadarAutomatic:SetText(GetTranslation("radar_auto"))
- checkRadarAutomatic:SetValue(RADAR.repeating)
- checkRadarAutomatic.OnChange = function(s, val)
- RADAR.repeating = val
- end
- local panelRadio = vgui.Create("Panel", panel)
- panelRadio:SetSize(w, h - 28)
- panelRadio:SetPos(0, 28)
- TRADIO.CreateMenu(panelRadio)
- panelRadio:Hide()
- ---------------------------
- -------- ITEMS SCREEN-------
- ---------------------------
- local panelItems = vgui.Create("Panel", panel)
- panelItems:SetSize(w, h - 28)
- panelItems:SetPos(0, 28)
- local labelSearch = vgui.Create("DLabel", panelItems)
- labelSearch:SetSize(128, 32)
- labelSearch:SetPos(29, 0)
- labelSearch:SetFont("DermaDefaultBold")
- labelSearch:SetText(LANG.GetRawTranslation("eqmenu_search"))
- local textSearch = vgui.Create("DTextEntry", panelItems)
- textSearch:SetSize(345, 32)
- textSearch:SetPos(125, 0)
- local buttonCloseSearch = vgui.Create("DButton", panelItems)
- buttonCloseSearch:SetSize(33, 32)
- buttonCloseSearch:SetPos(467, 0)
- buttonCloseSearch:SetText("X")
- function textSearch:OnLoseFocus()
- frame:SetKeyboardInputEnabled(false)
- end
- function buttonRadio:OnMousePressed()
- if buttonRadio:GetDisabled() then return end
- panelRadar:Hide()
- panelItems:Hide()
- panelDisguiser:Hide()
- panelTransfer:Hide()
- panelRadio:Show()
- end
- function buttonItems:OnMousePressed()
- if buttonItems:GetDisabled() then return end
- buttonItems.Selected = true
- buttonRadio.Selected = false
- buttonRadar.Selected = false
- buttonDisguise.Selected = false
- buttonTransfer.Selected = false
- panelRadar:Hide()
- panelRadio:Hide()
- panelDisguiser:Hide()
- panelTransfer:Hide()
- panelItems:Show()
- end
- function buttonRadar:OnMousePressed()
- if buttonRadar:GetDisabled() then return end
- buttonItems.Selected = false
- buttonRadio.Selected = false
- buttonRadar.Selected = true
- buttonDisguise.Selected = false
- buttonTransfer.Selected = false
- panelRadio:Hide()
- panelItems:Hide()
- panelDisguiser:Hide()
- panelTransfer:Hide()
- panelRadar:Show()
- end
- function buttonDisguise:OnMousePressed()
- if buttonDisguise:GetDisabled() then return end
- buttonItems.Selected = false
- buttonRadio.Selected = false
- buttonRadar.Selected = false
- buttonDisguise.Selected = true
- buttonTransfer.Selected = false
- panelRadio:Hide()
- panelItems:Hide()
- panelRadar:Hide()
- panelTransfer:Hide()
- panelDisguiser:Show()
- end
- function buttonTransfer:OnMousePressed()
- if buttonTransfer:GetDisabled() then return end
- buttonItems.Selected = false
- buttonRadio.Selected = false
- buttonRadar.Selected = false
- buttonDisguise.Selected = false
- buttonTransfer.Selected = true
- panelRadio:Hide()
- panelItems:Hide()
- panelRadar:Hide()
- panelDisguiser:Hide()
- panelTransfer:Show()
- end
- ---------------------------
- ------ CATAGORIES-PANE------
- ---------------------------
- local panelCatagories = vgui.Create("Panel", panelItems)
- panelCatagories:SetSize(128, 188)
- panelCatagories:SetPos(0, 30)
- local buttonPassive = vgui.Create("DButton", panelCatagories)
- buttonPassive:SetSize(120, 30)
- buttonPassive:SetPos(4, 6)
- buttonPassive:SetText(LANG.GetRawTranslation("eqmenu_cat_passive"))
- local buttonActive = vgui.Create("DButton", panelCatagories)
- buttonActive:SetSize(120, 30)
- buttonActive:SetPos(4, 40)
- buttonActive:SetText(LANG.GetRawTranslation("eqmenu_cat_active"))
- local buttonExplosives = vgui.Create("DButton", panelCatagories)
- buttonExplosives:SetSize(120, 30)
- buttonExplosives:SetPos(4, 74)
- buttonExplosives:SetText(LANG.GetRawTranslation("eqmenu_cat_explosives"))
- local buttonWeapon = vgui.Create("DButton", panelCatagories)
- buttonWeapon:SetSize(120, 30)
- buttonWeapon:SetPos(4, 108)
- buttonWeapon:SetText(LANG.GetRawTranslation("eqmenu_cat_weapon"))
- local buttonSpecial = vgui.Create("DButton", panelCatagories)
- buttonSpecial:SetSize(120, 30)
- buttonSpecial:SetPos(4, 142)
- buttonSpecial:SetText(LANG.GetRawTranslation("eqmenu_cat_special"))
- ---------------------------
- ------- SETTINGS-PANE-------
- ---------------------------
- local panelSettings = vgui.Create("Panel", panelItems)
- panelSettings:SetSize(128, 121)
- panelSettings:SetPos(0, 216)
- --
- local checkUncatagorised = vgui.Create("DCheckBox", panelSettings)
- checkUncatagorised:SetPos(10, 9)
- checkUncatagorised:SetValue(showUncatagorised)
- checkUncatagorised.OnChange = function(s, val)
- ply:SetPData("eqMenuUncatagorised", val)
- eqframe:Close()
- TraitorMenuPopup()
- end
- local labelUncatagorised = vgui.Create("DLabel", panelSettings)
- labelUncatagorised:SetSize(99, 15)
- labelUncatagorised:SetPos(30, 9)
- labelUncatagorised:SetText("Uncatagorised?")
- --
- local checkHideCustoms = vgui.Create("DCheckBox", panelSettings)
- checkHideCustoms:SetPos(10, 32)
- checkHideCustoms:SetValue(hideCustoms)
- checkHideCustoms.OnChange = function(s, val)
- ply:SetPData("eqMenuHideCustoms", val)
- eqframe:Close()
- TraitorMenuPopup()
- end
- local labelHideCustoms = vgui.Create("DLabel", panelSettings)
- labelHideCustoms:SetSize(99, 15)
- labelHideCustoms:SetPos(30, 32)
- labelHideCustoms:SetText("Hide Customs?")
- --
- local checkMemoryWindow = vgui.Create("DCheckBox", panelSettings)
- checkMemoryWindow:SetPos(10, 54)
- checkMemoryWindow:SetValue(memoryWindow)
- checkMemoryWindow.OnChange = function(s, val)
- ply:SetPData("eqMenuMemoryWindow", val)
- end
- local labelMemoryWindow = vgui.Create("DLabel", panelSettings)
- labelMemoryWindow:SetSize(99, 15)
- labelMemoryWindow:SetPos(30, 54)
- labelMemoryWindow:SetText("Memory Window?")
- --
- local buttonFavourites = vgui.Create("DButton", panelSettings)
- buttonFavourites:SetSize(108, 30)
- buttonFavourites:SetPos(10, 80)
- buttonFavourites:SetText("FAVOURITES")
- ---------------------------
- --------- BUY-PANE----------
- ---------------------------
- local panelBuy = vgui.Create("Panel", panelItems)
- panelBuy:SetSize(164, 120)
- panelBuy:SetPos(336, 216)
- local buttonBuy = vgui.Create("DButton", panelBuy)
- buttonBuy:SetSize(100, 30)
- buttonBuy:SetPos(52, 80)
- buttonBuy:SetText("BUY")
- buttonBuy:SetEnabled(false)
- local buttonFav = vgui.Create("DButton", panelBuy)
- buttonFav:SetSize(42, 30)
- buttonFav:SetPos(13, 80)
- buttonFav:SetText("+FAV")
- buttonFav:SetEnabled(false)
- local labelCredits = vgui.Create("DLabel", panelBuy)
- labelCredits:SetPos(13, 10)
- labelCredits:SetSize(100, 30)
- labelCredits:SetText(string.format(LANG.GetRawTranslation("eqmenu_credits"), credits))
- ---------------------------
- ------ ITEM DESC-PANE-------
- ---------------------------
- local panelItemDesc = vgui.Create("Panel", panelItems)
- panelItemDesc:SetSize(215, 121)
- panelItemDesc:SetPos(125, 216)
- local m = 5
- local dfields = {}
- for _, k in pairs({ "name", "type", "desc" }) do
- dfields[k] = vgui.Create("DLabel", panelItems)
- dfields[k]:SetTooltip(GetTranslation("equip_spec_" .. k))
- dfields[k]:SetPos(132, 225)
- dfields[k]:Hide()
- end
- dfields.name:SetFont("TabLarge")
- dfields.type:SetFont("DermaDefault")
- dfields.type:MoveBelow(dfields.name)
- dfields.desc:SetFont("DermaDefaultBold")
- dfields.desc:SetContentAlignment(7)
- dfields.desc:MoveBelow(dfields.type, 1)
- ---------------------------
- -------- ITEMS-PANEL--------
- ---------------------------
- local activeCatagory = passiveEquipSelect
- --local update_preqs = PreqLabels(panelBuy, m*3, m*2)
- function onEquipSelect(self, _, new)
- for k, v in pairs(new.item) do
- if dfields[k] then
- dfields[k]:SetText(SafeTranslate(v))
- dfields[k]:SizeToContents()
- dfields[k]:Show()
- end
- end
- -- Trying to force everything to update to
- -- the right size is a giant pain, so just
- -- force a good size.
- dfields.desc:SetTall(70)
- --can_order = update_preqs(new.item)
- buttonBuy:SetEnabled(can_order)
- buttonFav:SetEnabled(true)
- buttonFav:SetText("+FAV")
- for i = 1, #favourites do
- if favourites[i] == new.item.id then
- buttonFav:SetText(LANG.GetRawTranslation("eqmenu_del_fav"))
- break
- end
- end
- end
- local scrollPane = vgui.Create("Panel", panelItems)
- scrollPane:SetSize(374, 188)
- scrollPane:SetPos(126, 30)
- function initEquipPanel()
- local equipPanel = vgui.Create("EquipSelect", scrollPane)
- equipPanel:SetPos(0, 0)
- equipPanel:SetSize(370, 187)
- equipPanel:EnableVerticalScrollbar(true)
- equipPanel:EnableHorizontal(true)
- equipPanel:SetPadding(4)
- equipPanel:Hide()
- equipPanel.OnActivePanelChanged = onEquipSelect
- return equipPanel
- end
- local easterEgg = vgui.Create("Panel", scrollPane)
- easterEgg:SetPos(0, 0)
- easterEgg:SetSize(370, 187)
- easterEgg:Hide()
- local labelCredits = vgui.Create("DLabel", easterEgg)
- labelCredits:SetPos(5, 5)
- labelCredits:SetText(LANG.GetRawTranslation("eqmenu_easteregg_body"))
- labelCredits:SizeToContents()
- local labelWebLink = vgui.Create("DLabelURL", easterEgg)
- labelWebLink:SetPos(5, 172)
- labelWebLink:SetText("https://unacceptableuse.com")
- labelWebLink:SetURL("https://unacceptableuse.com")
- labelWebLink:SetColor(Color(255, 255, 255, 255))
- labelWebLink:SizeToContents()
- local buttonMemes = vgui.Create("DButton", easterEgg)
- buttonMemes:SetPos(80, 100)
- buttonMemes:SetSize(210, 32)
- buttonMemes:SetText(LANG.GetRawTranslation("eqmenu_easteregg_button"))
- function buttonMemes:OnMousePressed()
- RunConsoleCommand("say", LANG.GetRawTranslation("eqmenu_easteregg_text"))
- eqframe:Close()
- end
- local equipSelect = initEquipPanel()
- local passiveEquipSelect = initEquipPanel()
- local activeEquipSelect = initEquipPanel()
- local explosivesEquipSelect = initEquipPanel()
- local weaponEquipSelect = initEquipPanel()
- local specialEquipSelect = initEquipPanel()
- local favouritesEquipSelect = initEquipPanel()
- local searchEquipSelect = initEquipPanel()
- local menuTypes = {}
- menuTypes.passiveEquipSelect = {}
- menuTypes.passiveEquipSelect.menu = passiveEquipSelect
- menuTypes.passiveEquipSelect.button = buttonPassive
- menuTypes.weaponEquipSelect = {}
- menuTypes.weaponEquipSelect.menu = weaponEquipSelect
- menuTypes.weaponEquipSelect.button = buttonWeapon
- menuTypes.explosivesEquipSelect = {}
- menuTypes.explosivesEquipSelect.menu = explosivesEquipSelect
- menuTypes.explosivesEquipSelect.button = buttonExplosives
- menuTypes.activeEquipSelect = {}
- menuTypes.activeEquipSelect.menu = activeEquipSelect
- menuTypes.activeEquipSelect.button = buttonActive
- menuTypes.uncatagorised = {}
- menuTypes.uncatagorised.menu = equipSelect
- menuTypes.uncatagorised.button = buttonPassive
- menuTypes.specialEquipSelect = {}
- menuTypes.specialEquipSelect.menu = specialEquipSelect
- menuTypes.specialEquipSelect.button = buttonSpecial
- menuTypes.favouritesEquipSelect = {}
- menuTypes.favouritesEquipSelect.menu = favouritesEquipSelect
- menuTypes.favouritesEquipSelect.button = buttonFavourites
- function SwitchCatagory(newCatagory, button)
- if showUncatagorised then
- equipSelect:Show()
- buttonPassive:SetEnabled(false)
- buttonActive:SetEnabled(false)
- buttonExplosives:SetEnabled(false)
- buttonWeapon:SetEnabled(false)
- buttonSpecial:SetEnabled(false)
- return
- end
- for k, v in pairs(menuTypes) do
- if (v.menu == newCatagory) then
- ply:SetPData("eqMenuLastWindow", k)
- break
- end
- end
- equipSelect:Hide()
- passiveEquipSelect:Hide()
- activeEquipSelect:Hide()
- explosivesEquipSelect:Hide()
- weaponEquipSelect:Hide()
- specialEquipSelect:Hide()
- favouritesEquipSelect:Hide()
- searchEquipSelect:Hide()
- buttonPassive.Selected = false
- buttonActive.Selected = false
- buttonExplosives.Selected = false
- buttonWeapon.Selected = false
- buttonSpecial.Selected = false
- buttonFavourites.Selected = false
- if button ~= nil then
- button.Selected = true
- end
- newCatagory:Show()
- activeCatagory = newCatagory
- end
- function textSearch:OnMousePressed()
- frame:SetKeyboardInputEnabled(true)
- SwitchCatagory(searchEquipSelect, nil)
- end
- function buttonCloseSearch:OnMousePressed()
- textSearch:SetText("")
- easterEgg:Hide()
- frame:SetKeyboardInputEnabled(false)
- if ply:GetPData("eqMenuMemoryWindow", false) == "true" then --god damn typing
- local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
- SwitchCatagory(menuType.menu, menuType.button)
- else
- SwitchCatagory(passiveEquipSelect, buttonPassive)
- end
- end
- function buttonPassive:OnMousePressed()
- SwitchCatagory(passiveEquipSelect)
- buttonPassive.Selected = true
- end
- function buttonActive:OnMousePressed()
- SwitchCatagory(activeEquipSelect)
- buttonActive.Selected = true
- end
- function buttonWeapon:OnMousePressed()
- SwitchCatagory(weaponEquipSelect)
- buttonWeapon.Selected = true
- end
- function buttonExplosives:OnMousePressed()
- SwitchCatagory(explosivesEquipSelect)
- buttonExplosives.Selected = true
- end
- function buttonSpecial:OnMousePressed()
- SwitchCatagory(specialEquipSelect)
- buttonSpecial.Selected = true
- end
- function buttonFavourites:OnMousePressed()
- SwitchCatagory(favouritesEquipSelect)
- buttonFavourites.Selected = true
- end
- function buttonBuy:OnMousePressed()
- local pnl
- if showUncatagorised then
- pnl = equipSelect.SelectedPanel
- else
- pnl = activeCatagory.SelectedPanel
- end
- if not pnl or not pnl.item then return end
- local choice = pnl.item
- RunConsoleCommand("ttt_order_equipment", choice.id)
- frame:Close()
- end
- function buttonFav:OnMousePressed()
- if buttonFav:GetDisabled() then return end
- local pnl
- if showUncatagorised then
- pnl = eqMenuUncatagorised.SelectedPanel
- else
- pnl = activeCatagory.SelectedPanel
- end
- if not pnl or not pnl.item then return end
- local choice = pnl.item
- local isInFavourites = false
- for i = 1, #favourites do
- if favourites[i] == choice.id then
- table.remove(favourites, i)
- isInFavourites = true
- break
- end
- end
- if isInFavourites then
- buttonFav:SetText("+FAV")
- else
- table.insert(favourites, choice.id)
- buttonFav:SetText("-FAV")
- end
- local out = ""
- for i = 1, #favourites do
- out = out .. ":" .. favourites[i]
- end
- ply:SetPData("eqMenuFavourites", out)
- end
- -- wepsCategory = {
- -- "weapon_ttt_sipistol",
- -- "weapon_ttt_knife",
- -- "weapon_ttt_flaregun",
- -- "weapon_ttt_phammer",
- -- "weapon_ttt_push",
- -- "melon_gtx2ttt",
- -- "ttt_harpoon",
- -- "weapon_ttt_p90",
- -- "weapon_ttt_ak47",
- -- "weapon_ttt_awp",
- -- "weapon_ttt_revolver",
- -- "weapon_ttt_slim4a1",
- -- "weapon_ttt_poisiondart",
- -- "weapon_ttt_shurikens",
- -- "weapon_ttt_siltmp",
- -- "weapon_ttt_stungun",
- -- "weapon_ttt_silm4a1",
- -- "stungun",
- -- "weapon_ttt_poisondart"
- -- }
- -- explosivesCategory = {
- -- "melonlauncher", --melon launcher
- -- "weapon_ttt_c4", --C4
- -- "weapon_ttt_rsb", --RSB
- -- "weapon_ttt_rsb_diffuser", --RSB
- -- "weapon_ttt_slam", --S.L.A.M
- -- "weapon_ttt_turtlenade", --turtle grenade
- -- "weapon_ttt_frag", --frag grenade
- -- "weapon_ttt_holyhandgrenade", --holy hand grenade
- -- "weapon_ttt_chickennade", --chicken
- -- "weapon_ttt_jihad", --jihad
- -- "weapon_ttt_bananabomb", --banana bomb
- -- "weapon_ttt_bomb_station", --bomb station
- -- "weapon_ttt_flashbang", --Flashbang
- -- "weapon_sh_flashbang", --flashbang
- -- "weapon_ttt_homingpigeon" --Homing pigeon
- -- }
- --Terrible programming but nobody has to know ;)
- function GetCatagoryForItem(item)
- if showUncatagorised then
- return equipSelect
- elseif --==WEAPONS==
- item.id == "weapon_ttt_sipistol" or --silenced pistol
- item.id == "weapon_ttt_knife" or --knife
- item.id == "weapon_ttt_flaregun" or --flare gun
- item.id == "weapon_ttt_phammer" or --poltergiest
- item.id == "weapon_ttt_push" or --newton launcher
- item.id == "melon_gtx2ttt" or --melon launcher
- item.id == "ttt_harpoon" or --harpoon
- item.id == "weapon_ttt_p90" or --P90
- item.id == "weapon_ttt_ak47" or --AK47
- item.id == "weapon_ttt_awp" or --AWP
- item.id == "weapon_ttt_revolver" or --SW500
- item.id == "weapon_ttt_slim4a1" or --silenced m4a1
- item.id == "weapon_ttt_poisiondart" or --poision dart gun
- item.id == "weapon_ttt_shurikens" or --shuriken
- item.id == "weapon_ttt_siltmp" or --siltmp
- item.id == "weapon_ttt_stungun" or --disorientation gun
- item.id == "weapon_ttt_m4a1_s" or --Sil m4
- item.id == "weapon_ttt_tmp_s" or --Silenced fox
- item.id == "rotgun" or
- item.id == "weapon_ttt_goldengun" or
- item.id == "magnum (Garrys mod own item)" or
- item.id == "nc_ttt_nighthawk" or
- item.id == "weapon_ttt_tflippy_si-g3sg1" or
- item.id == "genji_melee" or
- item.id == "weapon_ttt_peacekeeper" or
- item.id == "weapon_ttt_tigers" or
- item.id == "weapon_minigun" or
- item.id == "weapon_predator_blade" or
- item.id == "stungun" or --stungun
- item.id == "weapon_ttt_poisondart" --poison dart
- then return weaponEquipSelect elseif --==EXPLOSIVES==
- item.id == "melonlauncher" or --melon launcher
- item.id == "weapon_ttt_c4" or --C4
- item.id == "weapon_ttt_rsb" or --RSB
- item.id == "weapon_ttt_rsb_diffuser" or --RSB
- item.id == "weapon_ttt_slam" or --S.L.A.M
- item.id == "weapon_ttt_turtlenade" or --turtle grenade
- item.id == "weapon_ttt_frag" or --frag grenade
- item.id == "weapon_ttt_holyhandgrenade" or --holy hand grenade
- item.id == "weapon_ttt_chickennade" or --chicken
- item.id == "weapon_ttt_jihad" or --jihad
- item.id == "weapon_ttt_bananabomb" or --banana bomb
- item.id == "weapon_ttt_bomb_station" or --bomb station
- item.id == "weapon_ttt_flashbang" or --Flashbang
- item.id == "weapon_sh_flashbang" or --flashbang
- item.id == "weapon_ttt_gimnade" or
- item.id == "weapon_ttt_confgrenade_s" or
- item.id == "weapon_boombody" or
- item.id == "melonlauncher" or
- item.id == "weapon_ttt_expmicrowave" or
- item.id == "fp" or
- item.id == "weapon_ttt_lemlauncher" or
- item.id == "weapon_ttt_lemnade" or
- item.id == "weapon_ttt_doorbuster" or
- item.id == "weapon_ttt_homingpigeon" --Homing pigeon
- then return explosivesEquipSelect elseif --==SPECIALS==
- item.id == "weapon_ttt_decoy" or --decoy
- item.id == "weapon_ttt_teleport" or --teleporter
- item.id == "weapon_ttt_health_station" or --health station
- item.id == "weapon_ttt_radio" or --radio
- item.id == "weapon_ttt_cse" or --visualizer
- item.id == "weapon_ttt_detective_camera" or --camera
- item.id == "weapon_ttt_defuser" or --defuser
- item.id == "weapon_ttt_binoculars" or --binoculars
- item.id == "weapon_ttt_basscannon" or --bass cannon
- item.id == "weapon_ttt_prophide" or --prop disguiser
- item.id == "weapon_prophide" or --prop disguiser
- item.id == "weapon_ttt_defib_traitor" or --defib
- item.id == "weapon_ttt_bodyspawn" or --defib(?) possibly tazer?
- item.id == "weapon_ttt_beacon" or --beacon(?)
- item.id == "weapon_ttt_briefcase" or --Briefcase
- item.id == "weapon_peace_maker" or --peace sentry
- item.id == "weapon_ttt_bblauncher" or --Bounce Ball
- item.id == "weapon_ttt_teargas" or --Tear Gas
- item.id == "weapon_gh_checker" --wep checker
- then return specialEquipSelect elseif --==PASSIVE==
- item.id == 1 or --body armor
- item.id == "ttt_a_second_chance" or
- item.id == "ttt_hermesboots_detective " or
- item.id == "ttt_hermesboots_traitor" or
- item.id == "ttt_luckyhorseshoe_detective" or
- item.id == "ttt_luckyhorseshoe_traitor" or
- item.id == "zombies_perk_phd" or
- item.id == "ttt_martyr_proj" or
- item.id == "weapon_ttt_mirrorfate" or
- item.id == 2 --radar
- then return passiveEquipSelect elseif --==ACTIVE==
- item.id == 4 or --disguiser
- item.id == "weapon_ttt_adv_disguiser" or --advanced disguiser
- item.id == "weapon_ttt_cloakingdevice" or --advanced disguiser
- item.id == "sh_slowmotion" or
- item.id == "ttt_thelittlehelper" or
- item.id == 16 --iron boots
- then return activeEquipSelect else
- local swep = weapons.GetStored(item.id)
- if not swep then return specialEquipSelect end
- if not swep.Kind then return specialEquipSelect end
- if swep.Kind == WEAPON_EQUIP1 or swep.Kind == WEAPON_EQUIP2 then
- return specialEquipSelect
- elseif swep.Kind == WEAPON_HEAVY or swep.Kind == WEAPON_PISTOL then
- return weaponEquipSelect
- elseif swep.Kind == WEAPON_NADE then
- return explosivesEquipSelect
- elseif swep.Kind == WEAPON_ROLE then
- return activeEquipSelect
- end
- print("Warning: No catagory for "..item.id.." (Kind "..swep.Kind..")")
- -- WEAPON_CARRY 5
- -- WEAPON_PISTOL 2
- -- WEAPON_HEAVY 3
- -- WEAPON_NADE 4
- -- WEAPON_EQUIP1 6
- -- WEAPON_EQUIP2 7
- -- WEAPON_ROLE 8
- -- WEAPON_MELEE 1
- return specialEquipSelect
- end
- end
- if ply:GetPData("eqMenuMemoryWindow", false) == "true" then --god damn typing
- local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
- SwitchCatagory(menuType.menu, menuType.button)
- else
- SwitchCatagory(passiveEquipSelect, buttonPassive)
- end
- local owned_ids = {}
- for _, wep in pairs(ply:GetWeapons()) do
- if IsValid(wep) and wep["IsEquipment"] and wep:IsEquipment() then
- table.insert(owned_ids, wep:GetClass())
- end
- end
- function createItemIcon(item, equipMenu, isInFavourites)
- local ic = nil
- if item.material then
- if item.custom then
- -- Custom marker icon
- ic = vgui.Create("LayeredIcon", equipMenu)
- local marker = vgui.Create("DImage")
- marker:SetImage("vgui/ttt/custom_marker")
- marker.PerformLayout = function(s)
- s:AlignBottom(2)
- s:AlignRight(2)
- s:SetSize(16, 16)
- end
- marker:SetTooltip(GetTranslation("equip_custom"))
- ic:AddLayer(marker)
- ic:EnableMousePassthrough(marker)
- -- elseif not ItemIsWeapon(item) then
- -- ic = vgui.Create("LayeredIcon", equipMenu)
- else
- ic = vgui.Create("LayeredIcon", equipMenu)
- end
- if isInFavourites then
- local marker = vgui.Create("DImage")
- marker:SetImage("icon16/star.png")
- marker.PerformLayout = function(s)
- if item.custom then
- s:AlignRight(20)
- else
- s:AlignRight(2)
- end
- s:AlignBottom(2)
- s:SetSize(16, 16)
- end
- marker:SetTooltip(LANG.GetRawTranslation("eqmenu_favourited"))
- ic:AddLayer(marker)
- ic:EnableMousePassthrough(marker)
- end
- -- Slot marker icon
- if ItemIsWeapon(item) then
- local slot = vgui.Create("SimpleIconLabelled")
- slot:SetIcon("vgui/ttt/slotcap")
- slot:SetIconColor(color_slot[ply:GetRole()] or COLOR_GREY)
- slot:SetIconSize(16)
- slot:SetIconText(item.slot)
- slot:SetIconProperties(COLOR_WHITE,
- "DefaultBold",
- { opacity = 220, offset = 1 },
- { 10, 8 })
- ic:AddLayer(slot)
- ic:EnableMousePassthrough(slot)
- end
- ic:SetIconSize(64)
- ic:SetIcon(item.material)
- elseif item.model then
- ic = vgui.Create("SpawnIcon", equipMenu)
- ic:SetModel(item.model)
- else
- ErrorNoHalt("Equipment item does not have model or material specified: " .. tostring(item) .. "\n")
- end
- -- If we cannot order this item, darken it
- if ((not can_order) or
- -- already owned
- table.HasValue(owned_ids, item.id) or
- (tonumber(item.id) and ply:HasEquipmentItem(tonumber(item.id))) or
- -- already carrying a weapon for this slot
- (ItemIsWeapon(item) and (not CanCarryWeapon(item))) or
- -- already bought the item before
- (item.limited and ply:HasBought(tostring(item.id)))) then
- ic:SetIconColor(color_darkened)
- end
- ic.item = item
- return ic
- end
- local items = GetEquipmentForRole(ply:GetRole())
- local to_select = nil
- for k, item in pairs(items) do
- local isInFavourites = false
- for i = 1, #favourites do
- if favourites[i] == item.id then
- isInFavourites = true
- break
- end
- end
- if not (item.custom and hideCustoms) then
- local equipMenu = GetCatagoryForItem(item)
- equipMenu:AddPanel(createItemIcon(item, equipMenu, isInFavourites))
- end
- if isInFavourites then
- favouritesEquipSelect:AddPanel(createItemIcon(item, favouritesEquipSelect, isInFavourites))
- end
- end
- function textSearch:OnChange()
- if (string.len(textSearch:GetText()) > 0) then
- if (textSearch:GetText():lower() == "memes") then
- searchEquipSelect:Hide()
- easterEgg:Show()
- else
- easterEgg:Hide()
- searchEquipSelect:Show()
- searchEquipSelect:Clear()
- for k, item in pairs(items) do
- if (string.match(item.name:lower(), textSearch:GetText():lower()) or string.match(item.id, textSearch:GetText():lower())) then
- searchEquipSelect:AddPanel(createItemIcon(item, searchEquipSelect, false))
- end
- end
- end
- else
- if ply:GetPData("eqMenuMemoryWindow", memoryWindowDefault) == "true" then --god damn typing
- local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
- SwitchCatagory(menuType.menu, menuType.button)
- else
- SwitchCatagory(passiveEquipSelect, buttonPassive)
- end
- end
- end
- eqframe = frame
- function paintPrimaryOutlinedBox(w, h)
- surface.SetDrawColor(Color(57, 57, 57, 255))
- surface.DrawRect(0, 0, w, h)
- surface.SetDrawColor(Color(0, 7, 10, 255))
- surface.DrawOutlinedRect(0, 0, w, h)
- surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
- end
- function paintSecondaryOutlinedBox(w, h)
- surface.SetDrawColor(Color(35, 35, 35, 255))
- surface.DrawRect(0, 0, w, h - 2)
- surface.SetDrawColor(Color(0, 7, 10, 255))
- surface.DrawOutlinedRect(0, 0, w, h)
- surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
- end
- function paintButton(w, h, button)
- if (button:GetDisabled()) then
- surface.SetDrawColor(color_button_disabled[ply:GetRole()] or COLOR_GREY)
- else
- surface.SetDrawColor(color_button_normal[ply:GetRole()] or COLOR_GREY)
- end
- surface.DrawRect(0, 0, w - 2, h)
- surface.SetDrawColor(Color(0, 7, 10, 255))
- surface.DrawOutlinedRect(0, 0, w - 2, h)
- surface.DrawOutlinedRect(1, 1, w - 3, h - 2)
- surface.SetFont("DermaDefaultBold")
- if (button.Selected) then
- surface.SetTextColor(255, 255, 255, 255)
- else
- surface.SetTextColor(0, 0, 0, 255)
- end
- surface.SetTextPos((w - surface.GetTextSize(button:GetText())) / 2, 8)
- surface.DrawText(button:GetText())
- return true
- end
- function paintCheckBox(w, h, checkBox)
- surface.SetDrawColor(color_button_normal[ply:GetRole()] or COLOR_GREY)
- surface.DrawRect(0, 0, w, h)
- surface.SetDrawColor(Color(0, 7, 10, 255))
- surface.DrawOutlinedRect(0, 0, w, h)
- surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
- if checkBox:GetChecked() then
- surface.SetFont("Marlett")
- surface.SetTextColor(0, 0, 0, 255)
- surface.SetTextPos(0, 0)
- surface.DrawText("a")
- end
- return true
- end
- function panel:Paint(w, h)
- paintPrimaryOutlinedBox(w, h)
- return true
- end
- function panelCatagories:Paint(w, h)
- paintSecondaryOutlinedBox(w, h)
- return true
- end
- function panelSettings:Paint(w, h)
- paintPrimaryOutlinedBox(w, h)
- return true
- end
- function panelBuy:Paint(w, h)
- paintPrimaryOutlinedBox(w, h)
- return true
- end
- function scrollPane:Paint(w, h)
- paintSecondaryOutlinedBox(w, h)
- return true
- end
- function panelItemDesc:Paint(w, h)
- paintPrimaryOutlinedBox(w, h)
- return true
- end
- function textSearch:Paint(w, h)
- paintPrimaryOutlinedBox(w, h)
- surface.SetFont("DermaDefault")
- surface.SetTextColor(255, 255, 255, 255)
- surface.SetTextPos(15, 10)
- surface.DrawText(textSearch:GetText())
- return true
- end
- function checkUncatagorised:Paint(w, h)
- return paintCheckBox(w, h, checkUncatagorised)
- end
- function checkMemoryWindow:Paint(w, h)
- return paintCheckBox(w, h, checkMemoryWindow)
- end
- function checkHideCustoms:Paint(w, h)
- return paintCheckBox(w, h, checkHideCustoms)
- end
- function buttonWeapon:Paint(w, h)
- return paintButton(w, h, buttonWeapon)
- end
- function buttonSpecial:Paint(w, h)
- return paintButton(w, h, buttonSpecial)
- end
- function buttonExplosives:Paint(w, h)
- return paintButton(w, h, buttonExplosives)
- end
- function buttonBuy:Paint(w, h)
- return paintButton(w, h, buttonBuy)
- end
- function buttonActive:Paint(w, h)
- return paintButton(w, h, buttonActive)
- end
- function buttonPassive:Paint(w, h)
- return paintButton(w, h, buttonPassive)
- end
- function buttonFavourites:Paint(w, h)
- return paintButton(w, h, buttonFavourites)
- end
- function buttonRadar:Paint(w, h)
- return paintButton(w, h, buttonRadar)
- end
- function buttonRadio:Paint(w, h)
- return paintButton(w, h, buttonRadio)
- end
- function buttonClose:Paint(w, h)
- return paintButton(w, h, buttonClose)
- end
- function buttonTransfer:Paint(w, h)
- return paintButton(w, h, buttonTransfer)
- end
- function buttonItems:Paint(w, h)
- return paintButton(w, h, buttonItems)
- end
- function buttonDisguise:Paint(w, h)
- return paintButton(w, h, buttonDisguise)
- end
- function buttonToggleDisguiser:Paint(w, h)
- return paintButton(w, h, buttonToggleDisguiser)
- end
- function buttonFav:Paint(w, h)
- return paintButton(w, h, buttonFav)
- end
- function buttonCloseSearch:Paint(w, h)
- return paintButton(w, h, buttonCloseSearch)
- end
- function buttonRadarScan:Paint(w, h)
- return paintButton(w, h, buttonRadarScan)
- end
- function buttonMemes:Paint(w, h)
- return paintButton(w, h, buttonMemes)
- end
- return
- end
- concommand.Add("ttt_cl_traitorpopup", TraitorMenuPopup)
- local function ForceCloseTraitorMenu(ply, cmd, args)
- if IsValid(eqframe) then
- eqframe:Close()
- end
- end
- concommand.Add("ttt_cl_traitorpopup_close", ForceCloseTraitorMenu)
- concommand.Add("noclip", function()
- local r = GetRoundState()
- if r == ROUND_ACTIVE and not (LocalPlayer():GetTraitor() or LocalPlayer():GetDetective()) then
- return
- elseif r == ROUND_POST or r == ROUND_PREP then
- CLSCORE:Reopen()
- return
- end
- if IsValid(eqframe) then
- eqframe:Close()
- else
- RunConsoleCommand("ttt_cl_traitorpopup")
- end
- end)
- local function ReceiveEquipment()
- local ply = LocalPlayer()
- if not IsValid(ply) then return end
- ply.equipment_items = net.ReadUInt(16)
- end
- net.Receive("TTT_Equipment", ReceiveEquipment)
- local function ReceiveCredits()
- local ply = LocalPlayer()
- if not IsValid(ply) then return end
- ply.equipment_credits = net.ReadUInt(8)
- end
- net.Receive("TTT_Credits", ReceiveCredits)
- local r = 0
- local function ReceiveBought()
- local ply = LocalPlayer()
- if not IsValid(ply) then return end
- ply.bought = {}
- local num = net.ReadUInt(8)
- for i = 1, num do
- local s = net.ReadString()
- if s != "" then
- table.insert(ply.bought, s)
- end
- end
- -- This usermessage sometimes fails to contain the last weapon that was
- -- bought, even though resending then works perfectly. Possibly a bug in
- -- bf_read. Anyway, this hack is a workaround: we just request a new umsg.
- if num != #ply.bought and r < 10 then -- r is an infinite loop guard
- RunConsoleCommand("ttt_resend_bought")
- r = r + 1
- else
- r = 0
- end
- end
- net.Receive("TTT_Bought", ReceiveBought)
- -- Player received the item he has just bought, so run clientside init
- local function ReceiveBoughtItem()
- local is_item = net.ReadBit() == 1
- local id = is_item and net.ReadUInt(16) or net.ReadString()
- -- I can imagine custom equipment wanting this, so making a hook
- hook.Run("TTTBoughtItem", is_item, id)
- end
- net.Receive("TTT_BoughtItem", ReceiveBoughtItem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement