This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent 9f505a0646
commit c6d9b6f580
8044 changed files with 1853472 additions and 21 deletions

View File

@@ -0,0 +1,295 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.base = "base_bags"
ITEM.allowNesting = false -- Whether to allow this bag to be stored inside other bags.
ITEM.restriction = {} -- List of item IDs allowed to be put inside this bag. Supports item bases.
ITEM.noOpen = false -- Whether to disallow this bag from being opened through right click or not.
ITEM.noEquip = false -- Whether to disallow this bag from being 'equipped' by the player.
ITEM.functions.View = {
icon = "icon16/briefcase.png",
OnClick = function(item)
local index = item:GetData("id", "")
if (index) then
local panel = ix.gui["inv"..index]
local inventory = ix.item.inventories[index]
local parent
local iconSize = SScaleMin(90 / 3)
if ix.gui.menuInventoryParent then
if IsValid(ix.gui.menuInventoryParent.backpacks) then
parent = IsValid(ix.gui.menuInventoryParent.backpacks) and ix.gui.menuInventoryParent.backpacks
else
parent = ix.gui.openedStorage
end
else
parent = ix.gui.openedStorage
end
if (IsValid(panel)) then
panel:Remove()
end
if (inventory and inventory.slots) then
panel = vgui.Create("ixInventory", IsValid(parent) and parent or nil)
panel:SetInventory(inventory)
panel:Dock(LEFT)
panel:DockMargin(0, SScaleMin(30 / 3), 0, 0)
if (parent == ix.gui.openedStorage or !item.noOpen) then
if (panel) then
panel:Remove()
end
local DFrame = vgui.Create("DFrame", IsValid(parent) and parent or nil)
-- 4 and 30 are accounting for the size of DFrame borders here
DFrame:SetSize(
item.invWidth * (iconSize + 2) + SScaleMin(4 / 3),
item.invHeight * (iconSize + SScaleMin(2 / 3)) + SScaleMin(30 / 3)
)
DFrame:SetTitle(item.GetName and item:GetName() or L(item.name))
DFrame:SetDraggable(true)
DFrame:MoveToFront()
if (!item.noOpen and (ix.gui.menu and parent != ix.gui.openedStorage)) then
DFrame:SetParent(ix.gui.menuInventoryParent)
else
DFrame:MakePopup()
end
DFrameFixer(DFrame, true, true)
parent.bagFrame = DFrame
panel = vgui.Create("ixInventory", DFrame)
panel:Dock(TOP)
panel:SetInventory(inventory)
DFrame:SetPos(input.GetCursorPos())
else
panel:MoveToFront()
end
ix.gui["inv"..index] = panel
else
ErrorNoHalt("[Helix] Attempt to view an uninitialized inventory '"..index.."'\n")
end
end
return false
end,
OnCanRun = function(item)
if (CLIENT) and item.noOpen and
(!ix.gui.openedStorage or ix.gui.openedStorage and !IsValid(ix.gui.openedStorage)) then return false end
return !IsValid(item.entity) and item:GetData("id") and !IsValid(ix.gui["inv" .. item:GetData("id", "")])
end
}
-- Allows bags to be opened from the world.
ITEM.functions.ViewAlt = {
name = "View",
OnRun = function(item)
local inventory = item:GetInventory()
if (inventory) then
ix.storage.Open(item.player, inventory, {
name = item.name,
entity = item.entity,
searchTime = 0
})
end
return false
end,
OnCanRun = function(item)
return IsValid(item.entity)
end
}
ITEM.functions.Equip = {
OnRun = function(item, data)
local owner = item:GetOwner()
if (owner) then
local index = owner:FindBodygroupByName(item.uniqueID == "largebag" and owner:GetActiveCombineSuit() and "cp_Bag" or item.bodygroup)
local groups = owner:GetCharacter():GetData("groups", {})
if (index > -1) then
groups[index] = 1
owner:GetCharacter():SetData("groups", groups)
owner:SetBodygroup(index, 1)
netstream.Start(owner, "ItemEquipBodygroups", index, 1)
end
item:SetData("equip", true)
end
return false
end,
OnCanRun = function(item, creationClient)
local client = item.player or creationClient
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") != true and hook.Run("CanPlayerEquipItem", client, item) != false and !item.noEquip
end
}
ITEM.functions.EquipUn = { -- sorry, for name order.
name = "Unequip",
tip = "unequipTip",
icon = "icon16/cross.png",
OnRun = function(item, creationClient)
local client = item.player or creationClient
if (client) then
local index = client:FindBodygroupByName(item.uniqueID == "largebag" and client:GetActiveCombineSuit() and "cp_Bag" or item.bodygroup)
local groups = client:GetCharacter():GetData("groups", {})
if (index > -1) then
groups[index] = 0
client:GetCharacter():SetData("groups", groups)
client:SetBodygroup(index, 0)
netstream.Start(client, "ItemEquipBodygroups", index, 0)
end
item:SetData("equip", false)
end
return false
end,
OnCanRun = function(item, creationClient)
local client = item.player or creationClient
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") == true and
hook.Run("CanPlayerUnequipItem", client, item) != false
end
}
-- Called when the item should tell whether or not it can be transfered between inventories.
-- Allows bags to be put inside containers.
function ITEM:CanTransfer(oldInventory, newInventory)
local index = self:GetData("id")
if (newInventory) then
if (newInventory.vars and newInventory.vars.isBag and !newInventory.vars.isContainer and !self.allowNesting) then
return false
end
local index2 = newInventory:GetID()
if (index == index2) then
return false
end
local curInv = self.GetInventory and self:GetInventory()
local curInvItems = curInv and curInv.GetItems and curInv:GetItems()
if curInvItems then
for _, v in pairs(curInvItems) do
if (v:GetData("id") == index2) then
return false
end
end
end
end
return !newInventory or newInventory:GetID() != oldInventory:GetID() or newInventory.vars.isBag
end
-- Called when a new instance of this item has been made.
function ITEM:OnInstanced(invID, x, y)
if (self.invBeingMade) then return end
self.invBeingMade = true
local inventory = ix.item.inventories[invID]
ix.inventory.New(inventory and inventory.owner or 0, self.uniqueID, function(inv)
local client = inv:GetOwner()
inv.vars.isBag = self.uniqueID
inv.vars.allowNesting = self.allowNesting
inv.vars.restriction = self.restriction
inv.vars.noEquipInv = true
self:SetData("id", inv:GetID())
if (IsValid(client)) then
inv:AddReceiver(client)
end
if (self.OnBagInitialized) then
self:OnBagInitialized(inv)
end
end)
end
-- Called when the item first appears for a client.
function ITEM:OnSendData()
local index = self:GetData("id")
if (index) then
local inventory = ix.item.inventories[index]
if (inventory) then
inventory.vars.isBag = self.uniqueID
inventory.vars.allowNesting = self.allowNesting
inventory.vars.restriction = self.restriction
inventory.vars.noEquipInv = true
inventory:Sync(self.player)
inventory:AddReceiver(self.player)
else
local owner = self.player:GetCharacter():GetID()
ix.inventory.Restore(self:GetData("id"), self.invWidth, self.invHeight, function(inv)
inv.vars.isBag = self.uniqueID
inv.vars.allowNesting = self.allowNesting
inv.vars.restriction = self.restriction
inv.vars.noEquipInv = true
inv:SetOwner(owner, true)
if (!inv.owner) then
return
end
for client, character in ix.util.GetCharacters() do
if (character:GetID() == inv.owner) then
inv:AddReceiver(client)
break
end
end
end)
end
else
if (self.invBeingMade) then return end
self.invBeingMade = true
ix.inventory.New(self.player:GetCharacter():GetID(), self.uniqueID, function(inv)
local client = inv:GetOwner()
inv.vars.isBag = self.uniqueID
inv.vars.allowNesting = self.allowNesting
inv.vars.restriction = self.restriction
inv.vars.noEquipInv = true
self:SetData("id", inv:GetID())
if (IsValid(client)) then
inv:AddReceiver(client)
end
if (self.OnBagInitialized) then
self:OnBagInitialized(inv)
end
end)
end
end

View File

@@ -0,0 +1,29 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Ammunition Pouch"
ITEM.description = "A pouch which can hold lotsa bullets."
ITEM.model = Model("models/willardnetworks/clothingitems/backpack.mdl")
ITEM.noOpen = false
ITEM.noEquip = true
ITEM.invWidth = 4
ITEM.invHeight = 2
ITEM.width = 2
ITEM.height = 1
ITEM.restriction = { -- ammo is base_stackable, and thats kinda too broad for this so gotta list it manually
"bullets_357",
"bullets_assaultrifle",
"bullets_buckshot",
"bullets_heavypulse",
"bullets_pistol",
"bullets_pulse",
"bullets_smg1",
"bullets_sniper"
}

View File

@@ -0,0 +1,31 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Large Bag"
ITEM.description = "A backpack with the Combine insignia upon it."
ITEM.invWidth = 4
ITEM.invHeight = 4
ITEM.bodygroup = "bag"
ITEM.model = Model("models/willardnetworks/clothingitems/backpack.mdl")
ITEM.outfitCategory = "Bag"
ITEM.noOpen = true
ITEM.hooks.View = function(item, data)
local client = item.player
local inventory = client:GetCharacter():GetInventory()
local items = inventory:GetItemsByUniqueID(item.uniqueID)
if (#items > 1) then
table.SortByMember(items, "id", true)
if (items[1].id != item.id) then
return false
end
end
end

View File

@@ -0,0 +1,18 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Magazine Pouch"
ITEM.description = "A pouch which you can stack magazines inside of."
ITEM.model = Model("models/willardnetworks/clothingitems/satchel.mdl")
ITEM.noOpen = false
ITEM.noEquip = true
ITEM.invWidth = 4
ITEM.invHeight = 1
ITEM.restriction = {"base_arccwmag"}

View File

@@ -0,0 +1,26 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Medical Pouch"
ITEM.description = "A pouch in which you can store all your medical items"
ITEM.model = Model("models/willardnetworks/clothingitems/satchel.mdl")
ITEM.noOpen = false
ITEM.noEquip = true
ITEM.invWidth = 2
ITEM.invHeight = 6
ITEM.restriction = {
"base_medical",
"drink_saline",
"comp_antidote",
"comp_bloodsyringe",
"comp_syringe",
"drug_amph_a",
"drug_amph_b",
}

View File

@@ -0,0 +1,19 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Small Bag"
ITEM.description = "A small satchel that rests on your hip."
ITEM.invWidth = 3
ITEM.invHeight = 4
ITEM.bodygroup = "satchel"
ITEM.model = Model("models/willardnetworks/clothingitems/satchel.mdl")
ITEM.outfitCategory = "Satchel"
ITEM.noOpen = true

View File

@@ -0,0 +1,78 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- Called to check if an item can be transferred.
-- Allows inventories to be nested inside containers. NOTE: Also needs custom bag base.
function PLUGIN:CanTransferItem(itemObject, curInv, inventory)
if (SERVER) then
local client = itemObject.GetOwner and itemObject:GetOwner() or nil
if (IsValid(client) and curInv.GetReceivers) then
local bAuthorized = false
for _, v in ipairs(curInv:GetReceivers()) do
if (client == v) then
bAuthorized = true
break
end
end
if (!bAuthorized) then
return false
end
end
end
-- don't allow bags to be put inside bags
if (inventory.id != 0 and curInv.id != inventory.id) then
if (inventory.vars and inventory.vars.isBag and !inventory.vars.isContainer and !itemObject.allowNesting and itemObject.isBag) then
local owner = itemObject:GetOwner()
if (IsValid(owner)) then
owner:NotifyLocalized("nestedBags")
end
return false
end
if (inventory.vars and inventory.vars.restriction and #inventory.vars.restriction > 0) then
if (!table.HasValue(inventory.vars.restriction, itemObject.uniqueID) and !table.HasValue(inventory.vars.restriction, itemObject.base)) then
local owner = itemObject:GetOwner()
if (IsValid(owner)) then
owner:NotifyLocalized("restrictedBag")
end
return false
end
end
elseif (inventory.id != 0 and curInv.id == inventory.id) then
-- we are simply moving items around if we're transferring to the same inventory
return
end
inventory = ix.item.inventories[itemObject:GetData("id")]
-- don't allow transferring items that are in use
if (inventory) then
for _, v in pairs(inventory:GetItems()) do
if (v:GetData("equip") == true) then
local owner = itemObject:GetOwner()
if (owner and IsValid(owner)) then
owner:NotifyLocalized("equippedBag")
end
return false
end
end
end
end

View File

@@ -0,0 +1,21 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
PLUGIN.name = "Bag System"
PLUGIN.author = "Fruity & Aspect™"
PLUGIN.description = "A simple bag system."
ix.util.Include("sh_hooks.lua")
ix.util.Include("sv_plugin.lua")
ix.lang.AddTable("english", {
restrictedBag = "This inventory cannot hold this type of item!"
})

View File

@@ -0,0 +1,21 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
function PLUGIN:CanPlayerTradeWithVendor(client, entity, uniqueID, isSellingToVendor)
if (isSellingToVendor) then return end
if (uniqueID == "smallbag" or uniqueID == "largebag") then
if (client:GetCharacter():GetInventory():HasItem(uniqueID)) then
return false
end
end
end