diff --git a/entities/entities/nut_item.lua b/entities/entities/nut_item.lua index 9630103a..6e81c9c3 100644 --- a/entities/entities/nut_item.lua +++ b/entities/entities/nut_item.lua @@ -47,15 +47,17 @@ if (SERVER) then local model = itemTable.onGetDropModel and itemTable:onGetDropModel(self) - or itemTable.model + or itemTable:getModel() or itemTable.model if (itemTable.worldModel) then model = itemTable.worldModel == true and "models/props_junk/cardboard_box004a.mdl" or itemTable.worldModel end - self:SetSkin(itemTable.skin or 0) self:SetModel(model) + self:SetSkin(itemTable.skin or 0) + self:SetMaterial(itemTable.material or "") + self:SetColor(itemTable.color or Color(255,255,255)) self:PhysicsInit(SOLID_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) self:setNetVar("id", itemTable.uniqueID) diff --git a/gamemode/config/sh_config.lua b/gamemode/config/sh_config.lua index 4a73606e..91a6b232 100644 --- a/gamemode/config/sh_config.lua +++ b/gamemode/config/sh_config.lua @@ -55,6 +55,11 @@ nut.config.add("oocDelay", 10, "The delay before a player can use OOC chat again category = "chat" }) +nut.config.add("oocLimit", 0, "Character limit per OOC message. 0 means no limit", nil, { + data = {min = 0, max = 1000}, + category = "chat" +}) + nut.config.add("oocDelayAdmin", false, "Whether or not OOC chat delay is enabled for admins.", nil, { category = "chat" }) diff --git a/gamemode/core/libs/sh_chatbox.lua b/gamemode/core/libs/sh_chatbox.lua index 8efd7614..4ddb183e 100644 --- a/gamemode/core/libs/sh_chatbox.lua +++ b/gamemode/core/libs/sh_chatbox.lua @@ -301,7 +301,6 @@ do return false end end - -- Save the last time they spoke in OOC. speaker.nutLastOOC = CurTime() end @@ -331,6 +330,9 @@ do icon = "icon16/heart.png" end + if (nut.config.get("oocLimit", 0) ~= 0) and (#text > nut.config.get("oocLimit", 0)) then + text = string.sub(text, 1, nut.config.get("oocLimit", 0)) .. "..." + end icon = Material(hook.Run("GetPlayerIcon", speaker) or icon) chat.AddText(icon, nut.chat.timestamp(true), Color(255, 50, 50), " [OOC] ", speaker, color_white, ": " .. text) @@ -361,6 +363,9 @@ do speaker.nutLastLOOC = CurTime() end, onChatAdd = function(speaker, text) + if (nut.config.get("oocLimit", 0) ~= 0) and (#text > nut.config.get("oocLimit", 0)) then + text = string.sub(text, 1, nut.config.get("oocLimit", 0)) .. "..." + end chat.AddText(nut.chat.timestamp(false), Color(255, 50, 50), "[LOOC] ", nut.config.get("chatColor"), speaker:Name() .. ": " .. text) end, radius = function() diff --git a/gamemode/core/libs/sh_player.lua b/gamemode/core/libs/sh_player.lua index 22753891..90f49505 100644 --- a/gamemode/core/libs/sh_player.lua +++ b/gamemode/core/libs/sh_player.lua @@ -42,7 +42,7 @@ do end -- Whitelist networking information here. -do +do function playerMeta:hasWhitelist(faction) local data = nut.faction.indices[faction] diff --git a/gamemode/core/libs/thirdparty/cl_ikon.lua b/gamemode/core/libs/thirdparty/cl_ikon.lua index 1e560f7a..c6243ce9 100644 --- a/gamemode/core/libs/thirdparty/cl_ikon.lua +++ b/gamemode/core/libs/thirdparty/cl_ikon.lua @@ -21,18 +21,18 @@ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + TL;DR: https://tldrlegal.com/license/mit-license - OK - + OK - Commercial Use Modify Distribute Sublicense Private Use - + NOT OK - Hold Liable - + MUST - Include Copyright Include License @@ -58,7 +58,7 @@ function ikon:init() hook.Add("HUDPaint", "ikon_dev2", ikon.showResult) else hook.Remove("HUDPaint", "ikon_dev2") - end + end /* Being good at gmod is knowing all of stinky hacks @@ -101,7 +101,7 @@ local TEXTURE_FLAGS_CLAMP_T = 0x0008 ikon.max = ikon.maxSize * 64 ikon.RT = GetRenderTargetEx("nsIconRendered", ikon.max, - ikon.max, + ikon.max, RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_SHARED, bit.bor(TEXTURE_FLAGS_CLAMP_S, TEXTURE_FLAGS_CLAMP_T), @@ -133,10 +133,10 @@ function ikon:renderHook() local w, h = ikon.curWidth * 64, ikon.curHeight * 64 local x, y = 0, 0 - + local tab if (ikon.info) then - tab = + tab = { origin = ikon.info.pos, angles = ikon.info.ang, @@ -183,24 +183,24 @@ function ikon:renderHook() render.SetStencilPassOperation(STENCILOPERATION_REPLACE) render.SetStencilFailOperation(STENCILOPERATION_REPLACE) end - + /* Add more effects on the Models! */ if (tab.drawHook) then tab.drawHook(ikon.renderEntity, w, h) end - - - cam.Start3D(tab.origin, tab.angles, tab.fov, 0, 0, w, h) + + + cam.Start3D(tab.origin, tab.angles, tab.fov, 0, 0, w, h) if (tab.entAng) then ikon.renderEntity:SetAngles(tab.entAng) else ikon.renderEntity:SetAngles(Angle()) end - + render.SetBlend(1) - ikon.renderEntity:DrawModel() + ikon.renderEntity:DrawModel() cam.End3D() if (tab.drawPostHook) then @@ -208,7 +208,7 @@ function ikon:renderHook() tab.drawPostHook(ikon.renderEntity, w, h) end - + if (tab.outline) then render.PushRenderTarget( tex_effect ) @@ -217,7 +217,7 @@ function ikon:renderHook() cam.Start2D() cam.Start3D(tab.origin, tab.angles, tab.fov, 0, 0, w, h) render.SetBlend(0) - ikon.renderEntity:DrawModel() + ikon.renderEntity:DrawModel() render.SetStencilWriteMask(138) -- could you please? render.SetStencilTestMask(1) @@ -232,10 +232,10 @@ function ikon:renderHook() cam.End3D() cam.End2D() render.PopRenderTarget() - + render.SetBlend(1) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_NOTEQUAL) - + /* Thanks for Noiwex NxServ.eu @@ -250,7 +250,7 @@ function ikon:renderHook() render.SetStencilEnable(false) end - + render.SuppressEngineLighting( false ) render.SetWriteDepthToDestAlpha( true ) end, function(rrer) print(rrer) end) @@ -293,7 +293,7 @@ function ikon:renderIcon(name, w, h, mdl, camInfo, updateCache) local w, h = ikon.curWidth * 64, ikon.curHeight * 64 local sw, sh = ScrW(), ScrH() - + if (ikon.renderModel) then if (!IsValid(ikon.renderEntity)) then ikon.renderEntity = ClientsideModel(ikon.renderModel, RENDERGROUP_BOTH) @@ -304,7 +304,7 @@ function ikon:renderIcon(name, w, h, mdl, camInfo, updateCache) ikon.renderEntity:SetModel(ikon.renderModel) local oldRT = render.GetRenderTarget() render.PushRenderTarget(ikon.RT) - + ikon.rendering = true ikon:renderHook() ikon.rendering = nil @@ -320,7 +320,7 @@ function ikon:renderIcon(name, w, h, mdl, camInfo, updateCache) file.Write("nsIcon/" .. schemaName .. "/" .. name .. ".png", capturedIcon) ikon.info = nil render.PopRenderTarget() - + if (updateCache) then local iconString = tostring(os.time()) file.Write(iconString .. ".png", capturedIcon) @@ -348,7 +348,7 @@ function ikon:getIcon(name) if (file.Exists("nsIcon/" .. schemaName .. "/" .. name .. ".png", "DATA")) then ikon.cache[name] = Material("../data/nsIcon/" .. schemaName .. "/".. name ..".png") - return ikon.cache[name] -- yeah return cache + return ikon.cache[name] -- yeah return cache else return false -- retryd end @@ -359,7 +359,7 @@ end concommand.Add("nut_flushicon", function() ikon.cache = {} local caf = "nsIcon/" .. schemaName .. "/*.png" - + for k, v in ipairs(file.Find(caf, "DATA")) do file.Delete("nsIcon/" .. schemaName .. "/" .. v) end diff --git a/gamemode/core/meta/item/sv_item.lua b/gamemode/core/meta/item/sv_item.lua index 950c1074..a2ded7a5 100644 --- a/gamemode/core/meta/item/sv_item.lua +++ b/gamemode/core/meta/item/sv_item.lua @@ -112,7 +112,7 @@ function ITEM:transfer(newInventory,bBypass) :next(function() newInventory:add(self) end) - + return true end diff --git a/gamemode/core/meta/sh_base_inventory.lua b/gamemode/core/meta/sh_base_inventory.lua index 338f69c2..80e35773 100644 --- a/gamemode/core/meta/sh_base_inventory.lua +++ b/gamemode/core/meta/sh_base_inventory.lua @@ -167,7 +167,7 @@ end function Inventory:getItemCount(itemType) local count = 0 for _, item in pairs(self:getItems()) do - if (item.uniqueID == itemType) then + if (itemType and item.uniqueID == itemType or true) then count = count + item:getQuantity() end end diff --git a/gamemode/core/sh_util.lua b/gamemode/core/sh_util.lua index 61201589..24598565 100644 --- a/gamemode/core/sh_util.lua +++ b/gamemode/core/sh_util.lua @@ -177,7 +177,7 @@ do local vectorLength2D = FindMetaTable("Vector").Length2D function playerMeta:isRunning() - return vectorLength2D(self.GetVelocity(self)) > (self.GetWalkSpeed(self) + 10) + return vectorLength2D(self:GetVelocity()) > (self:GetWalkSpeed() + 10) end -- Checks if the player has a female model. diff --git a/gamemode/items/base/sh_ammo.lua b/gamemode/items/base/sh_ammo.lua index eb97bbfa..03047848 100644 --- a/gamemode/items/base/sh_ammo.lua +++ b/gamemode/items/base/sh_ammo.lua @@ -14,7 +14,7 @@ end function ITEM:paintOver(item, w, h) local quantity = item:getQuantity() - + nut.util.drawText(quantity, 8, 5, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, "nutChatFont") end diff --git a/gamemode/items/base/sh_pacoutfit.lua b/gamemode/items/base/sh_pacoutfit.lua index ee6da84d..fc070026 100644 --- a/gamemode/items/base/sh_pacoutfit.lua +++ b/gamemode/items/base/sh_pacoutfit.lua @@ -50,7 +50,7 @@ end function ITEM:removePart(client) local char = client:getChar() - + self:setData("equip", false) if (client.removePart) then @@ -116,7 +116,7 @@ ITEM.functions.Equip = { char:addBoost(item.uniqueID, attribute, boost) end end - + return false end, onCanRun = function(item) diff --git a/gamemode/items/base/sh_weapons.lua b/gamemode/items/base/sh_weapons.lua index edc2e10b..deb9f53d 100644 --- a/gamemode/items/base/sh_weapons.lua +++ b/gamemode/items/base/sh_weapons.lua @@ -50,12 +50,12 @@ ITEM.functions.EquipUn = { -- sorry, for name order. local weapon = item.player.carryWeapons[item.weaponCategory] if (!weapon or !IsValid(weapon)) then - weapon = item.player:GetWeapon(item.class) + weapon = item.player:GetWeapon(item.class) end if (weapon and weapon:IsValid()) then item:setData("ammo", weapon:Clip1()) - + item.player:StripWeapon(item.class) else print(Format("[Nutscript] Weapon %s does not exist!", item.class)) @@ -101,7 +101,7 @@ ITEM.functions.Equip = { end end end - + if (client:HasWeapon(item.class)) then client:StripWeapon(item.class) end diff --git a/plugins/_disabled/simpleinv/plugins/listinvui/derma/cl_list_inventory_panel.lua b/plugins/_disabled/simpleinv/plugins/listinvui/derma/cl_list_inventory_panel.lua index e5261d8b..fbc6252f 100644 --- a/plugins/_disabled/simpleinv/plugins/listinvui/derma/cl_list_inventory_panel.lua +++ b/plugins/_disabled/simpleinv/plugins/listinvui/derma/cl_list_inventory_panel.lua @@ -23,7 +23,7 @@ function PANEL:Init() self.weightBar:Dock(FILL) self.weightBar:DockMargin(PADDING, PADDING, PADDING, PADDING) self.weightBar.Paint = function(this, w, h) self:paintWeightBar(w, h) end - + self.weightLabel = self.weight:Add("DLabel") self.weightLabel:SetText("WEIGHT: 0/10KG") self.weightLabel:SetFont("nutChatFont") @@ -122,7 +122,7 @@ end function PANEL:Center() local parent = self:GetParent() local centerX, centerY = ScrW() * 0.5, ScrH() * 0.5 - + self:SetPos( centerX - (self:GetWide() * 0.5), centerY - (self:GetTall() * 0.5) diff --git a/plugins/_disabled/simpleinv/plugins/listinvui/sh_plugin.lua b/plugins/_disabled/simpleinv/plugins/listinvui/sh_plugin.lua index 23398557..f27423a5 100644 --- a/plugins/_disabled/simpleinv/plugins/listinvui/sh_plugin.lua +++ b/plugins/_disabled/simpleinv/plugins/listinvui/sh_plugin.lua @@ -13,7 +13,7 @@ if (CLIENT) then local panel = parent:Add("nutListInventory") panel:setInventory(inventory) panel:Center() - + return panel end diff --git a/plugins/gridinv/items/base/sh_bags.lua b/plugins/gridinv/items/base/sh_bags.lua index 33815f55..1e05c709 100644 --- a/plugins/gridinv/items/base/sh_bags.lua +++ b/plugins/gridinv/items/base/sh_bags.lua @@ -6,6 +6,8 @@ ITEM.model = "models/props_c17/suitcase001a.mdl" ITEM.category = "Storage" ITEM.isBag = true +local SOUND_BAG_RESPONSE = {"physics/cardboard/cardboard_box_impact_soft2.wav", 50} + -- The size of the inventory held by this item. ITEM.invWidth = 2 ITEM.invHeight = 2 diff --git a/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua b/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua index 3b5d8d53..440d342f 100644 --- a/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua +++ b/plugins/gridinv/plugins/gridinvui/derma/cl_grid_inventory_panel.lua @@ -153,7 +153,7 @@ function PANEL:drawHeldItemRectangle() local trimX, trimY local maxOffsetY = (item.height or 1) - 1 local maxOffsetX = (item.width or 1) - 1 - local drawTarget = nil + local drawTarget = nil for itemID, invItem in pairs(self.inventory.items) do if (item:getID() == itemID) then continue end @@ -162,7 +162,7 @@ function PANEL:drawHeldItemRectangle() if ( x + (item.width - 1) >= targetX and x <= targetX + targetW and - y + (item.height - 1) >= targetY and y <= targetY + targetH and + y + (item.height - 1) >= targetY and y <= targetY + targetH and (invItem.onCombine or item.onCombineTo) ) then drawTarget = { @@ -221,7 +221,7 @@ end function PANEL:Center() local parent = self:GetParent() local centerX, centerY = ScrW() * 0.5, ScrH() * 0.5 - + self:SetPos( centerX - (self:GetWide() * 0.5), centerY - (self:GetTall() * 0.5) diff --git a/plugins/gridinv/sh_grid_inv.lua b/plugins/gridinv/sh_grid_inv.lua index 69440480..5f127074 100644 --- a/plugins/gridinv/sh_grid_inv.lua +++ b/plugins/gridinv/sh_grid_inv.lua @@ -5,7 +5,7 @@ local GridInv = nut.Inventory:extend("GridInv") -- Useful access rules: local function CanAccessInventoryIfCharacterIsOwner(inventory, action, context) - if (inventory.virtual) then return (action == "transfer") end + if (inventory.virtual) then return (action == "transfer") end local ownerID = inventory:getData("char") local client = context.client @@ -19,7 +19,7 @@ local function CanNotAddItemIfNoSpace(inventory, action, context) return end - if (inventory.virtual) then return true end + if (inventory.virtual) then return true end local x, y = context.x, context.y if (not x or not y) then return false, "noFit" end @@ -195,7 +195,7 @@ if (SERVER) then if (not item) then return d:reject("invalid item type") end - + local targetInventory = self if (not x or not y) then x, y = self:findFreePosition(item) @@ -210,7 +210,7 @@ if (SERVER) then break end end - end + end end end @@ -223,23 +223,23 @@ if (SERVER) then if (isStackCommand) then local items = targetInventory:getItemsOfType(itemTypeOrItem) - + if (items) then for _, targetItem in pairs(items) do - if (remainingQuantity == 0) then -- nothing to fill. - break + if (remainingQuantity == 0) then -- nothing to fill. + break end local freeSpace = targetItem.maxQuantity - targetItem:getQuantity() - + if (freeSpace > 0) then local filler = freeSpace - remainingQuantity if (filler > 0) then - targetAssignments[targetItem] = remainingQuantity + targetAssignments[targetItem] = remainingQuantity remainingQuantity = 0 else - targetAssignments[targetItem] = freeSpace + targetAssignments[targetItem] = freeSpace remainingQuantity = math.abs(filler) end end @@ -304,7 +304,7 @@ if (SERVER) then for targetItem, assignedQuantity in pairs(targetAssignments) do targetItem:addQuantity(assignedQuantity) end - + local overStacks = math.ceil(remainingQuantity/item.maxQuantity) - 1 if (overStacks > 0) then @@ -318,7 +318,7 @@ if (SERVER) then item:setQuantity(remainingQuantity - (item.maxQuantity * overStacks)) targetInventory:addItem(item) - + return d:resolve(items) else item:setQuantity(remainingQuantity) @@ -367,7 +367,7 @@ else ) then destinationID = nil end - + net.Start("nutTransferItem") net.WriteUInt(itemID, 32) net.WriteUInt(x, 32) diff --git a/plugins/mapscene.lua b/plugins/mapscene.lua index 6004f725..f7d9e227 100644 --- a/plugins/mapscene.lua +++ b/plugins/mapscene.lua @@ -52,7 +52,7 @@ if (CLIENT) then if (fraction >= 1) then self.startTime = curTime self.finishTime = curTime + 30 - + if (ordered) then self.orderedIndex = self.orderedIndex + 1 @@ -92,13 +92,13 @@ if (CLIENT) then local HIDE_WEAPON = Vector(0, 0, -100000) local HIDE_ANGLE = Angle(0, 0, 0) - + function PLUGIN:CalcViewModelView(weapon, viewModel, oldEyePos, oldEyeAngles, eyePos, eyeAngles) local scenes = self.scenes if (IsValid(nut.gui.character)) then return HIDE_WEAPON, HIDE_ANGLE - end + end end local PLUGIN = PLUGIN diff --git a/plugins/multichar/plugins/charselect/derma/cl_character.lua b/plugins/multichar/plugins/charselect/derma/cl_character.lua index 4b66b974..9e801eb9 100644 --- a/plugins/multichar/plugins/charselect/derma/cl_character.lua +++ b/plugins/multichar/plugins/charselect/derma/cl_character.lua @@ -187,7 +187,7 @@ function PANEL:Init() self.tabs:DockMargin(64, 32, 64, 0) self.tabs:SetTall(48) self.tabs:SetPaintBackground(false) - + self.content = self:Add("DPanel") self.content:Dock(FILL) self.content:DockMargin(64, 0, 64, 64) diff --git a/plugins/multichar/plugins/charselect/derma/cl_creation.lua b/plugins/multichar/plugins/charselect/derma/cl_creation.lua index 85ad0f04..5231b193 100644 --- a/plugins/multichar/plugins/charselect/derma/cl_creation.lua +++ b/plugins/multichar/plugins/charselect/derma/cl_creation.lua @@ -6,6 +6,15 @@ function PANEL:configureSteps() self:addStep(vgui.Create("nutCharacterModel")) self:addStep(vgui.Create("nutCharacterBiography")) hook.Run("ConfigureCharacterCreationSteps", self) + + local stepKeys = table.GetKeys(self.steps) + table.sort(stepKeys, function(a, b) return a < b end) + local stepsCopy = table.Copy(self.steps) + self.steps = {} + + for newKey, oldKey in pairs(stepKeys) do + self.steps[newKey] = stepsCopy[oldKey] + end end -- If the faction and model character data has been set, updates the @@ -176,7 +185,7 @@ function PANEL:addStep(step, priority) assert(IsValid(step), "Invalid panel for step") assert(step.isCharCreateStep, "Panel must inherit nutCharacterCreateStep") if (isnumber(priority)) then - table.insert(self.steps, math.min(priority, #self.steps + 1), step) + table.insert(self.steps, priority, step) else self.steps[#self.steps + 1] = step end @@ -343,14 +352,14 @@ function PANEL:Init() self.prev = self.buttons:Add("nutCharButton") self.prev:SetText(L("back"):upper()) self.prev:Dock(LEFT) - self.prev:SetWide(96) + self.prev:SizeToContents() self.prev.DoClick = function(prev) self:previousStep() end self.prev:SetAlpha(0) self.next = self.buttons:Add("nutCharButton") self.next:SetText(L("next"):upper()) self.next:Dock(RIGHT) - self.next:SetWide(96) + self.next:SizeToContents() self.next.DoClick = function(next) self:nextStep() end self.cancel = self.buttons:Add("nutCharButton") diff --git a/plugins/observer.lua b/plugins/observer.lua index f40ee69f..02081cae 100644 --- a/plugins/observer.lua +++ b/plugins/observer.lua @@ -14,7 +14,7 @@ if (CLIENT) then client = LocalPlayer() if (client:IsAdmin() and client:GetMoveType() == MOVETYPE_NOCLIP and !client:InVehicle() and NUT_CVAR_ADMINESP:GetBool()) then - sx, sy = surface.ScreenWidth(), surface.ScreenHeight() + sx, sy = ScrW(), ScrH() for k, v in ipairs(player.GetAll()) do if (v == client) then continue end diff --git a/plugins/vendor/sv_hooks.lua b/plugins/vendor/sv_hooks.lua index 873397b3..dfe2d766 100644 --- a/plugins/vendor/sv_hooks.lua +++ b/plugins/vendor/sv_hooks.lua @@ -96,14 +96,14 @@ function PLUGIN:VendorTradeAttempt( return end - client.vendorTransaction = true + client.vendorTransaction = true client.vendorTimeout = RealTime() + .1 -- Then, transfer the money and item. if (isSellingToVendor) then local inventory = character:getInv() local item = inventory:getFirstItemOfType(itemType) - + if (item) then local context = { client = client, @@ -121,7 +121,7 @@ function PLUGIN:VendorTradeAttempt( local canTransferItem, reason = hook.Run("CanItemBeTransfered", item, inventory, VENDOR_INVENTORY_MEASURE, client) if (canTransferItem == false) then client:notifyLocalized(reason or "vendorError") - + return end