mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
Upload
This commit is contained in:
6
gamemodes/helix/gamemode/items/ammo/sh_357ammo.txt
Normal file
6
gamemodes/helix/gamemode/items/ammo/sh_357ammo.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
ITEM.name = ".357 Ammo"
|
||||
ITEM.model = "models/items/357ammo.mdl"
|
||||
ITEM.ammo = "357" -- type of the ammo
|
||||
ITEM.ammoAmount = 12 -- amount of the ammo
|
||||
ITEM.description = "A Box that contains %s of .357 Ammo"
|
||||
ITEM.price = 10
|
||||
5
gamemodes/helix/gamemode/items/ammo/sh_ar2ammo.txt
Normal file
5
gamemodes/helix/gamemode/items/ammo/sh_ar2ammo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
ITEM.name = "AR2 Cartridge"
|
||||
ITEM.model = "models/Items/combine_rifle_cartridge01.mdl"
|
||||
ITEM.ammo = "ar2" -- type of the ammo
|
||||
ITEM.ammoAmount = 30 -- amount of the ammo
|
||||
ITEM.description = "A Cartridge that contains %s of AR2 Ammo"
|
||||
5
gamemodes/helix/gamemode/items/ammo/sh_crossbowammo.txt
Normal file
5
gamemodes/helix/gamemode/items/ammo/sh_crossbowammo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
ITEM.name = "Crossbow Bolts"
|
||||
ITEM.model = "models/Items/BoxBuckshot.mdl"
|
||||
ITEM.ammo = "XBowRounds" -- type of the ammo
|
||||
ITEM.ammoAmount = 5 -- amount of the ammo
|
||||
ITEM.description = "A Bundle of %s Crossbow Bolts"
|
||||
5
gamemodes/helix/gamemode/items/ammo/sh_pistolammo.txt
Normal file
5
gamemodes/helix/gamemode/items/ammo/sh_pistolammo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
ITEM.name = "Pistol Ammo"
|
||||
ITEM.model = "models/items/357ammo.mdl"
|
||||
ITEM.ammo = "pistol" -- type of the ammo
|
||||
ITEM.ammoAmount = 30 -- amount of the ammo
|
||||
ITEM.description = "A Box that contains %s of Pistol Ammo"
|
||||
11
gamemodes/helix/gamemode/items/ammo/sh_rocketammo.txt
Normal file
11
gamemodes/helix/gamemode/items/ammo/sh_rocketammo.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
ITEM.name = "A Rocket"
|
||||
ITEM.model = "models/weapons/w_missile_closed.mdl"
|
||||
ITEM.ammo = "rpg_round" -- type of the ammo
|
||||
ITEM.ammoAmount = 1 -- amount of the ammo
|
||||
ITEM.width = 2
|
||||
ITEM.description = "A Package of %s Rockets"
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(-0.70499622821808, 268.25439453125, 0),
|
||||
fov = 12.085652091515,
|
||||
pos = Vector(7, 200, -2)
|
||||
}
|
||||
5
gamemodes/helix/gamemode/items/ammo/sh_shotgunammo.txt
Normal file
5
gamemodes/helix/gamemode/items/ammo/sh_shotgunammo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
ITEM.name = "Shotgun Shells"
|
||||
ITEM.model = "models/Items/BoxBuckshot.mdl"
|
||||
ITEM.ammo = "buckshot" -- type of the ammo
|
||||
ITEM.ammoAmount = 15 -- amount of the ammo
|
||||
ITEM.description = "A Box of %s Shotgun Shells"
|
||||
5
gamemodes/helix/gamemode/items/ammo/sh_smg1ammo.txt
Normal file
5
gamemodes/helix/gamemode/items/ammo/sh_smg1ammo.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
ITEM.name = "Sub Machine Gun Ammo"
|
||||
ITEM.model = "models/Items/BoxSRounds.mdl"
|
||||
ITEM.ammo = "smg1" -- type of the ammo
|
||||
ITEM.ammoAmount = 45 -- amount of the ammo
|
||||
ITEM.description = "A Box that contains %s of SMG Ammo"
|
||||
4
gamemodes/helix/gamemode/items/bags/sh_large.txt
Normal file
4
gamemodes/helix/gamemode/items/bags/sh_large.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
ITEM.name = "Big Bag"
|
||||
ITEM.description = "A big bag."
|
||||
ITEM.invWidth = 6
|
||||
ITEM.invHeight = 4
|
||||
2
gamemodes/helix/gamemode/items/bags/sh_small.txt
Normal file
2
gamemodes/helix/gamemode/items/bags/sh_small.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
ITEM.name = "Small Bag"
|
||||
ITEM.description = "A small bag."
|
||||
58
gamemodes/helix/gamemode/items/base/sh_ammo.lua
Normal file
58
gamemodes/helix/gamemode/items/base/sh_ammo.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
--[[
|
||||
| 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 = "Ammo Base"
|
||||
ITEM.model = "models/Items/BoxSRounds.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.ammo = "pistol" -- type of the ammo
|
||||
ITEM.ammoAmount = 30 -- amount of the ammo
|
||||
ITEM.description = "A Box that contains %s of Pistol Ammo"
|
||||
ITEM.category = "Ammunition"
|
||||
ITEM.useSound = "items/ammo_pickup.wav"
|
||||
|
||||
function ITEM:GetDescription()
|
||||
local rounds = self:GetData("rounds", self.ammoAmount)
|
||||
return L(self.description, rounds)
|
||||
end
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
draw.SimpleText(
|
||||
item:GetData("rounds", item.ammoAmount), "DermaDefault", w - 5, h - 5,
|
||||
color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM, 1, color_black
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
-- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item.
|
||||
ITEM.functions.use = {
|
||||
name = "Load",
|
||||
tip = "useTip",
|
||||
icon = "icon16/add.png",
|
||||
OnRun = function(item)
|
||||
local rounds = item:GetData("rounds", item.ammoAmount)
|
||||
|
||||
item.player:GiveAmmo(rounds, item.ammo)
|
||||
if (ix.config.Get("equipSoundEnabled")) then
|
||||
item.player:EmitSound(item.useSound, ix.config.Get("equipSoundLevel", 60))
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
}
|
||||
|
||||
-- Called after the item is registered into the item tables.
|
||||
function ITEM:OnRegistered()
|
||||
if (ix.ammo) then
|
||||
ix.ammo.Register(self.ammo)
|
||||
end
|
||||
end
|
||||
350
gamemodes/helix/gamemode/items/base/sh_bags.lua
Normal file
350
gamemodes/helix/gamemode/items/base/sh_bags.lua
Normal file
@@ -0,0 +1,350 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
if (SERVER) then
|
||||
util.AddNetworkString("ixBagDrop")
|
||||
end
|
||||
|
||||
ITEM.name = "Bag"
|
||||
ITEM.description = "A bag to hold items."
|
||||
ITEM.model = "models/props_c17/suitcase001a.mdl"
|
||||
ITEM.category = "Storage"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.invWidth = 4
|
||||
ITEM.invHeight = 2
|
||||
ITEM.isBag = true
|
||||
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.name == "Bavul") 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.name == "Bavul" 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.name != "Bavul" 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
|
||||
}
|
||||
ITEM.functions.combine = {
|
||||
OnRun = function(item, data)
|
||||
ix.item.instances[data[1]]:Transfer(item:GetData("id"))
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item, data)
|
||||
local index = item:GetData("id", "")
|
||||
|
||||
if (index) then
|
||||
local inventory = ix.item.inventories[index]
|
||||
|
||||
if (inventory) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
}
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("equip")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when a new instance of this item has been made.
|
||||
function ITEM:OnInstanced(invID, x, y)
|
||||
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
|
||||
self:SetData("id", inv:GetID())
|
||||
|
||||
if (IsValid(client)) then
|
||||
inv:AddReceiver(client)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ITEM:GetInventory()
|
||||
local index = self:GetData("id")
|
||||
|
||||
if (index) then
|
||||
return ix.item.inventories[index]
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.GetInv = ITEM.GetInventory
|
||||
|
||||
-- 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: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: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
|
||||
ix.inventory.New(self.player:GetCharacter():GetID(), self.uniqueID, function(inv)
|
||||
self:SetData("id", inv:GetID())
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.postHooks.drop = function(item, result)
|
||||
local index = item:GetData("id")
|
||||
local inventory = ix.item.inventories[index]
|
||||
|
||||
-- don't allow transferring items within bag that are in use
|
||||
if (inventory) then
|
||||
for _, v in pairs(inventory:GetItems()) do
|
||||
if (v:GetData("equip") == true) then
|
||||
local owner = item.player
|
||||
|
||||
if (owner and IsValid(owner)) then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local query = mysql:Update("ix_inventories")
|
||||
query:Update("character_id", 0)
|
||||
query:Where("inventory_id", index)
|
||||
query:Execute()
|
||||
|
||||
net.Start("ixBagDrop")
|
||||
net.WriteUInt(index, 32)
|
||||
net.Send(item.player)
|
||||
|
||||
if item.name != "Bavul" and item:GetData("equip", false) then
|
||||
local bodyGroupIndex = item.player:FindBodygroupByName(item.bodygroup)
|
||||
local client = item.player
|
||||
local char = client:GetCharacter()
|
||||
local groups = char:GetData("groups", {})
|
||||
|
||||
if (bodyGroupIndex > -1) then
|
||||
groups[bodyGroupIndex] = 0
|
||||
char:SetData("groups", groups)
|
||||
item.player:SetBodygroup(bodyGroupIndex, 0)
|
||||
|
||||
item:SetData("equip", false)
|
||||
netstream.Start(client, "ItemEquipBodygroups", bodyGroupIndex, 0)
|
||||
end
|
||||
end
|
||||
|
||||
net.Start("ixSyncBagSlots")
|
||||
net.Send(item.player)
|
||||
end
|
||||
|
||||
if (CLIENT) then
|
||||
net.Receive("ixBagDrop", function()
|
||||
local index = net.ReadUInt(32)
|
||||
local panel = ix.gui["inv"..index]
|
||||
if (panel and panel:IsVisible() and string.find(tostring(panel:GetParent()), "DFrame")) then
|
||||
panel:GetParent():Close()
|
||||
return
|
||||
end
|
||||
|
||||
if panel and panel:IsVisible() and string.find(tostring(panel), "Panel") then
|
||||
panel:Remove()
|
||||
return
|
||||
end
|
||||
|
||||
if (panel and panel:IsVisible()) then
|
||||
panel:Close()
|
||||
return
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Called before the item is permanently deleted.
|
||||
function ITEM:OnRemoved()
|
||||
local index = self:GetData("id")
|
||||
|
||||
if (index) then
|
||||
local query = mysql:Delete("ix_items")
|
||||
query:Where("inventory_id", index)
|
||||
query:Execute()
|
||||
|
||||
query = mysql:Delete("ix_inventories")
|
||||
query:Where("inventory_id", index)
|
||||
query:Execute()
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when the item should tell whether or not it can be transfered between inventories.
|
||||
function ITEM:CanTransfer(oldInventory, newInventory)
|
||||
local index = self:GetData("id")
|
||||
|
||||
if (newInventory) then
|
||||
if (newInventory.vars and newInventory.vars.isBag) then
|
||||
return false
|
||||
end
|
||||
|
||||
local index2 = newInventory:GetID()
|
||||
|
||||
if (index == index2) then
|
||||
return false
|
||||
end
|
||||
|
||||
for _, v in pairs(self:GetInventory():GetItems()) do
|
||||
if (v:GetData("id") == index2) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if index2 and newInventory.vars then
|
||||
for _, v in pairs(newInventory:GetItems()) do
|
||||
if v.name == self.name then
|
||||
if newInventory:GetOwner() then
|
||||
if v.name == "Bavul" then
|
||||
newInventory:GetOwner():NotifyLocalized("Birden fazla bavul taşıyamazsınız!")
|
||||
else
|
||||
newInventory:GetOwner():NotifyLocalized("Bu çantadan birden fazla taşıyamazsınız!")
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return !newInventory or newInventory:GetID() != oldInventory:GetID() or newInventory.vars.isBag
|
||||
end
|
||||
|
||||
function ITEM:OnTransferred(curInv, inventory)
|
||||
local bagInventory = self:GetInventory()
|
||||
|
||||
if (isfunction(curInv.GetOwner)) then
|
||||
local owner = curInv:GetOwner()
|
||||
|
||||
if (IsValid(owner)) then
|
||||
bagInventory:RemoveReceiver(owner)
|
||||
end
|
||||
end
|
||||
|
||||
if (isfunction(inventory.GetOwner)) then
|
||||
local owner = inventory:GetOwner()
|
||||
|
||||
if (IsValid(owner)) then
|
||||
bagInventory:AddReceiver(owner)
|
||||
bagInventory:SetOwner(owner)
|
||||
end
|
||||
else
|
||||
-- it's not in a valid inventory so nobody owns this bag
|
||||
bagInventory:SetOwner(nil)
|
||||
end
|
||||
|
||||
hook.Run("OnBagItemTransferred", self, curInv, inventory)
|
||||
end
|
||||
|
||||
-- Called after the item is registered into the item tables.
|
||||
function ITEM:OnRegistered()
|
||||
ix.inventory.Register(self.uniqueID, self.invWidth, self.invHeight, true)
|
||||
end
|
||||
383
gamemodes/helix/gamemode/items/base/sh_outfit.lua
Normal file
383
gamemodes/helix/gamemode/items/base/sh_outfit.lua
Normal file
@@ -0,0 +1,383 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
if (SERVER) then
|
||||
util.AddNetworkString("ixRefreshBodygroupsInventoryModel")
|
||||
else
|
||||
net.Receive("ixRefreshBodygroupsInventoryModel", function()
|
||||
local replacements = net.ReadString()
|
||||
local skin = net.ReadUInt(5)
|
||||
local bodygroups = net.ReadTable()
|
||||
|
||||
if ix.gui.inventoryModel and IsValid(ix.gui.inventoryModel) then
|
||||
ix.gui.inventoryModel:SetModel(replacements, skin, false)
|
||||
|
||||
if ix.gui.inventoryModel.Entity and ix.gui.inventoryModel.Entity.SetBodygroup then
|
||||
for _, v in ipairs(bodygroups or {}) do
|
||||
ix.gui.inventoryModel.Entity:SetBodygroup(v.id, LocalPlayer():GetBodygroup(v.id))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
ITEM.name = "Outfit"
|
||||
ITEM.description = "A Outfit Base."
|
||||
ITEM.category = "Outfit"
|
||||
ITEM.model = "models/Gibs/HGIBS.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.outfitCategory = "model"
|
||||
ITEM.pacData = {}
|
||||
|
||||
--[[
|
||||
-- This will change a player's skin after changing the model. Keep in mind it starts at 0.
|
||||
ITEM.newSkin = 1
|
||||
-- This will change a certain part of the model.
|
||||
ITEM.replacements = {"group01", "group02"}
|
||||
-- This will change the player's model completely.
|
||||
ITEM.replacements = "models/manhack.mdl"
|
||||
-- This will have multiple replacements.
|
||||
ITEM.replacements = {
|
||||
{"male", "female"},
|
||||
{"group01", "group02"}
|
||||
}
|
||||
|
||||
-- This will apply body groups.
|
||||
ITEM.bodyGroups = {
|
||||
["blade"] = 1,
|
||||
["bladeblur"] = 1
|
||||
}
|
||||
]]--
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("equip")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:AddOutfit(client)
|
||||
local character = client:GetCharacter()
|
||||
|
||||
self:SetData("equip", true)
|
||||
|
||||
local groups = character:GetData("groups", {})
|
||||
|
||||
-- remove original bodygroups
|
||||
if (!table.IsEmpty(groups)) then
|
||||
character:SetData("oldGroups" .. self.outfitCategory, groups)
|
||||
character:SetData("groups", {})
|
||||
|
||||
client:ResetBodygroups()
|
||||
end
|
||||
|
||||
if (isfunction(self.OnGetReplacement)) then
|
||||
character:SetData("oldModel" .. self.outfitCategory,
|
||||
character:GetData("oldModel" .. self.outfitCategory, client:GetModel()))
|
||||
character:SetModel(self:OnGetReplacement(client))
|
||||
elseif (self.replacement or self.replacements) then
|
||||
character:SetData("oldModel" .. self.outfitCategory,
|
||||
character:GetData("oldModel" .. self.outfitCategory, client:GetModel()))
|
||||
|
||||
if (istable(self.replacements)) then
|
||||
if (#self.replacements == 2 and isstring(self.replacements[1])) then
|
||||
character:SetModel(client:GetModel():gsub(self.replacements[1], self.replacements[2]))
|
||||
else
|
||||
for _, v in ipairs(self.replacements) do
|
||||
character:SetModel(client:GetModel():gsub(v[1], v[2]))
|
||||
end
|
||||
end
|
||||
else
|
||||
character:SetModel(self.replacement or self.replacements)
|
||||
end
|
||||
end
|
||||
|
||||
if (self.newSkin) then
|
||||
character:SetData("oldSkin" .. self.outfitCategory, client:GetSkin())
|
||||
client:SetSkin(self.newSkin)
|
||||
end
|
||||
|
||||
-- get outfit saved bodygroups
|
||||
groups = self:GetData("groups", {})
|
||||
|
||||
-- restore bodygroups saved to the item
|
||||
if (!table.IsEmpty(groups) and self:ShouldRestoreBodygroups()) then
|
||||
for k, v in pairs(groups) do
|
||||
client:SetBodygroup(k, v)
|
||||
end
|
||||
-- apply default item bodygroups if none are saved
|
||||
elseif (istable(self.bodyGroups)) then
|
||||
for k, v in pairs(self.bodyGroups) do
|
||||
local index = client:FindBodygroupByName(k)
|
||||
|
||||
if (index > -1) then
|
||||
client:SetBodygroup(index, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local materials = self:GetData("submaterial", {})
|
||||
|
||||
if (!table.IsEmpty(materials) and self:ShouldRestoreSubMaterials()) then
|
||||
for k, v in pairs(materials) do
|
||||
if (!isnumber(k) or !isstring(v)) then
|
||||
continue
|
||||
end
|
||||
|
||||
client:SetSubMaterial(k - 1, v)
|
||||
end
|
||||
end
|
||||
|
||||
if (istable(self.attribBoosts)) then
|
||||
for k, v in pairs(self.attribBoosts) do
|
||||
character:AddBoost(self.uniqueID, k, v)
|
||||
end
|
||||
end
|
||||
|
||||
self:OnEquipped(client)
|
||||
end
|
||||
|
||||
local function ResetSubMaterials(client)
|
||||
for k, _ in ipairs(client:GetMaterials()) do
|
||||
if (client:GetSubMaterial(k - 1) != "") then
|
||||
client:SetSubMaterial(k - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:RemoveOutfit(client)
|
||||
local character = client:GetCharacter()
|
||||
|
||||
self:SetData("equip", false)
|
||||
|
||||
local materials = {}
|
||||
|
||||
for k, _ in ipairs(client:GetMaterials()) do
|
||||
if (client:GetSubMaterial(k - 1) != "") then
|
||||
materials[k] = client:GetSubMaterial(k - 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- save outfit submaterials
|
||||
if (!table.IsEmpty(materials)) then
|
||||
self:SetData("submaterial", materials)
|
||||
end
|
||||
|
||||
-- remove outfit submaterials
|
||||
ResetSubMaterials(client)
|
||||
|
||||
local groups = {}
|
||||
|
||||
for i = 0, (client:GetNumBodyGroups() - 1) do
|
||||
local bodygroup = client:GetBodygroup(i)
|
||||
|
||||
if (bodygroup > 0) then
|
||||
groups[i] = bodygroup
|
||||
end
|
||||
end
|
||||
|
||||
-- save outfit bodygroups
|
||||
if (!table.IsEmpty(groups)) then
|
||||
self:SetData("groups", groups)
|
||||
end
|
||||
|
||||
-- remove outfit bodygroups
|
||||
client:ResetBodygroups()
|
||||
|
||||
-- restore the original player model
|
||||
if (character:GetData("oldModel" .. self.outfitCategory)) then
|
||||
character:SetModel(character:GetData("oldModel" .. self.outfitCategory))
|
||||
character:SetData("oldModel" .. self.outfitCategory, nil)
|
||||
end
|
||||
|
||||
-- restore the original player model skin
|
||||
if (self.newSkin) then
|
||||
if (character:GetData("oldSkin" .. self.outfitCategory)) then
|
||||
client:SetSkin(character:GetData("oldSkin" .. self.outfitCategory))
|
||||
character:SetData("oldSkin" .. self.outfitCategory, nil)
|
||||
else
|
||||
client:SetSkin(0)
|
||||
end
|
||||
end
|
||||
|
||||
-- get character original bodygroups
|
||||
groups = character:GetData("oldGroups" .. self.outfitCategory, {})
|
||||
|
||||
-- restore original bodygroups
|
||||
if (!table.IsEmpty(groups)) then
|
||||
for k, v in pairs(groups) do
|
||||
client:SetBodygroup(k, v)
|
||||
end
|
||||
|
||||
character:SetData("groups", character:GetData("oldGroups" .. self.outfitCategory, {}))
|
||||
character:SetData("oldGroups" .. self.outfitCategory, nil)
|
||||
end
|
||||
|
||||
if (istable(self.attribBoosts)) then
|
||||
for k, _ in pairs(self.attribBoosts) do
|
||||
character:RemoveBoost(self.uniqueID, k)
|
||||
end
|
||||
end
|
||||
|
||||
for k, _ in pairs(self:GetData("outfitAttachments", {})) do
|
||||
self:RemoveAttachment(k, client)
|
||||
end
|
||||
|
||||
self:OnUnequipped(client)
|
||||
end
|
||||
|
||||
-- makes another outfit depend on this outfit in terms of requiring this item to be equipped in order to equip the attachment
|
||||
-- also unequips the attachment if this item is dropped
|
||||
function ITEM:AddAttachment(id)
|
||||
local attachments = self:GetData("outfitAttachments", {})
|
||||
attachments[id] = true
|
||||
|
||||
self:SetData("outfitAttachments", attachments)
|
||||
end
|
||||
|
||||
function ITEM:RemoveAttachment(id, client)
|
||||
local item = ix.item.instances[id]
|
||||
local attachments = self:GetData("outfitAttachments", {})
|
||||
|
||||
if (item and attachments[id]) then
|
||||
item:OnDetached(client)
|
||||
end
|
||||
|
||||
attachments[id] = nil
|
||||
self:SetData("outfitAttachments", attachments)
|
||||
end
|
||||
|
||||
ITEM:Hook("drop", function(item)
|
||||
local character = ix.char.loaded[item.owner]
|
||||
local client = character and character:GetPlayer() or item:GetOwner()
|
||||
|
||||
if hook.Run("CanPlayerUnequipItem", client, item) == false then
|
||||
return
|
||||
end
|
||||
|
||||
if (item:GetData("equip")) then
|
||||
item.player = client
|
||||
item:RemoveOutfit(item:GetOwner())
|
||||
end
|
||||
end)
|
||||
|
||||
ITEM.functions.EquipUn = { -- sorry, for name order.
|
||||
name = "Unequip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/cross.png",
|
||||
OnRun = function(item, creationClient)
|
||||
local client = item.player or creationClient
|
||||
|
||||
item:RemoveOutfit(client)
|
||||
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
|
||||
}
|
||||
|
||||
ITEM.functions.Equip = {
|
||||
name = "Equip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/tick.png",
|
||||
OnRun = function(item, creationClient)
|
||||
local client = item.player or creationClient
|
||||
local char = client:GetCharacter()
|
||||
local items = char:GetInventory():GetItems()
|
||||
|
||||
for _, v in pairs(items) do
|
||||
if (v.id != item.id) then
|
||||
local itemTable = ix.item.instances[v.id]
|
||||
|
||||
if (itemTable.pacData and v.outfitCategory == item.outfitCategory and itemTable:GetData("equip")) then
|
||||
client:NotifyLocalized(item.equippedNotify or "outfitAlreadyEquipped")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
item:AddOutfit(client)
|
||||
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 item:CanEquipOutfit(client) and
|
||||
hook.Run("CanPlayerEquipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:CanTransfer(oldInventory, newInventory)
|
||||
if (hook.Run("CanTransferBGClothes", oldInventory, newInventory) != false) then
|
||||
return true
|
||||
end
|
||||
|
||||
if (newInventory and self:GetData("equip")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
if (self.invID != 0 and self:GetData("equip")) then
|
||||
self.player = self:GetOwner()
|
||||
self:RemoveOutfit(self.player)
|
||||
self.player = nil
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnEquipped(client)
|
||||
if client and IsValid(client) then
|
||||
local replacements = self.replacement or client:GetModel()
|
||||
local skin = self.newSkin or client:GetSkin()
|
||||
local bodygroups = client:GetBodyGroups()
|
||||
|
||||
net.Start("ixRefreshBodygroupsInventoryModel")
|
||||
net.WriteString(replacements)
|
||||
net.WriteUInt(skin, 5)
|
||||
net.WriteTable(bodygroups)
|
||||
net.Send(client)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnUnequipped(client)
|
||||
if client and IsValid(client) then
|
||||
local replacements = client:GetModel()
|
||||
local skin = client:GetSkin()
|
||||
local bodygroups = client:GetBodyGroups()
|
||||
|
||||
net.Start("ixRefreshBodygroupsInventoryModel")
|
||||
net.WriteString(replacements)
|
||||
net.WriteUInt(skin, 5)
|
||||
net.WriteTable(bodygroups)
|
||||
net.Send(client)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:CanEquipOutfit()
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:ShouldRestoreBodygroups()
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:ShouldRestoreSubMaterials()
|
||||
return true
|
||||
end
|
||||
182
gamemodes/helix/gamemode/items/base/sh_pacoutfit.lua
Normal file
182
gamemodes/helix/gamemode/items/base/sh_pacoutfit.lua
Normal file
@@ -0,0 +1,182 @@
|
||||
--[[
|
||||
| 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 = "PAC Outfit"
|
||||
ITEM.description = "A PAC Outfit Base."
|
||||
ITEM.category = "Outfit"
|
||||
ITEM.model = "models/Gibs/HGIBS.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.outfitCategory = "hat"
|
||||
ITEM.pacData = {}
|
||||
|
||||
--[[
|
||||
ITEM.pacData = {
|
||||
[1] = {
|
||||
["children"] = {
|
||||
[1] = {
|
||||
["children"] = {
|
||||
},
|
||||
["self"] = {
|
||||
["Angles"] = Angle(12.919322967529, 6.5696062847564e-006, -1.0949343050015e-005),
|
||||
["Position"] = Vector(-2.099609375, 0.019973754882813, 1.0180969238281),
|
||||
["UniqueID"] = "4249811628",
|
||||
["Size"] = 1.25,
|
||||
["Bone"] = "eyes",
|
||||
["Model"] = "models/Gibs/HGIBS.mdl",
|
||||
["ClassName"] = "model",
|
||||
},
|
||||
},
|
||||
},
|
||||
["self"] = {
|
||||
["ClassName"] = "group",
|
||||
["UniqueID"] = "907159817",
|
||||
["EditorExpand"] = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- This will change a player's skin after changing the model. Keep in mind it starts at 0.
|
||||
ITEM.newSkin = 1
|
||||
-- This will change a certain part of the model.
|
||||
ITEM.replacements = {"group01", "group02"}
|
||||
-- This will change the player's model completely.
|
||||
ITEM.replacements = "models/manhack.mdl"
|
||||
-- This will have multiple replacements.
|
||||
ITEM.replacements = {
|
||||
{"male", "female"},
|
||||
{"group01", "group02"}
|
||||
}
|
||||
|
||||
-- This will apply body groups.
|
||||
ITEM.bodyGroups = {
|
||||
["blade"] = 1,
|
||||
["bladeblur"] = 1
|
||||
}
|
||||
|
||||
--]]
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
-- Draw camo if it is available.
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("equip")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawRect(w - 14, h - 14, 8, 8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:RemovePart(client)
|
||||
local char = client:GetCharacter()
|
||||
|
||||
self:SetData("equip", false)
|
||||
client:RemovePart(self.uniqueID)
|
||||
|
||||
if (self.attribBoosts) then
|
||||
for k, _ in pairs(self.attribBoosts) do
|
||||
char:RemoveBoost(self.uniqueID, k)
|
||||
end
|
||||
end
|
||||
|
||||
self:OnUnequipped()
|
||||
end
|
||||
|
||||
-- On item is dropped, Remove a weapon from the player and keep the ammo in the item.
|
||||
ITEM:Hook("drop", function(item)
|
||||
if (item:GetData("equip")) then
|
||||
item:RemovePart(item:GetOwner())
|
||||
end
|
||||
end)
|
||||
|
||||
-- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item.
|
||||
ITEM.functions.EquipUn = { -- sorry, for name order.
|
||||
name = "Unequip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/cross.png",
|
||||
OnRun = function(item)
|
||||
item:RemovePart(item.player)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") == true and
|
||||
hook.Run("CanPlayerUnequipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
-- On player eqipped the item, Gives a weapon to player and load the ammo data from the item.
|
||||
ITEM.functions.Equip = {
|
||||
name = "Equip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/tick.png",
|
||||
OnRun = function(item)
|
||||
local char = item.player:GetCharacter()
|
||||
local items = char:GetInventory():GetItems()
|
||||
|
||||
for _, v in pairs(items) do
|
||||
if (v.id != item.id) then
|
||||
local itemTable = ix.item.instances[v.id]
|
||||
|
||||
if (itemTable.pacData and v.outfitCategory == item.outfitCategory and itemTable:GetData("equip")) then
|
||||
item.player:NotifyLocalized(item.equippedNotify or "outfitAlreadyEquipped")
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
item:SetData("equip", true)
|
||||
item.player:AddPart(item.uniqueID, item)
|
||||
|
||||
if (item.attribBoosts) then
|
||||
for k, v in pairs(item.attribBoosts) do
|
||||
char:AddBoost(item.uniqueID, k, v)
|
||||
end
|
||||
end
|
||||
|
||||
item:OnEquipped()
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") != true and
|
||||
hook.Run("CanPlayerEquipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:CanTransfer(oldInventory, newInventory)
|
||||
if (newInventory and self:GetData("equip")) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
local inventory = ix.item.inventories[self.invID]
|
||||
local owner = inventory.GetOwner and inventory:GetOwner()
|
||||
|
||||
if (IsValid(owner) and owner:IsPlayer()) then
|
||||
if (self:GetData("equip")) then
|
||||
self:RemovePart(owner)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnEquipped()
|
||||
end
|
||||
|
||||
function ITEM:OnUnequipped()
|
||||
end
|
||||
232
gamemodes/helix/gamemode/items/base/sh_stackable.lua
Normal file
232
gamemodes/helix/gamemode/items/base/sh_stackable.lua
Normal file
@@ -0,0 +1,232 @@
|
||||
--[[
|
||||
| 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 = "Stackable Base"
|
||||
ITEM.description = "Makes items stackable."
|
||||
ITEM.category = "Base"
|
||||
|
||||
ITEM.maxStackSize = 1
|
||||
ITEM.bInstanceMaxstack = false
|
||||
ITEM.bNoSplit = false
|
||||
|
||||
do
|
||||
local META = ix.meta.inventory
|
||||
function META:GetItemCount(uniqueID, onlyMain)
|
||||
local i = 0
|
||||
|
||||
for _, v in pairs(self:GetItems(onlyMain)) do
|
||||
if (v.uniqueID == uniqueID) then
|
||||
i = i + v:GetStackSize()
|
||||
end
|
||||
end
|
||||
|
||||
return i
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
-- Define this on all items to make life easier
|
||||
local ITEM = ix.meta.item or {}
|
||||
function ITEM:GetStackSize()
|
||||
return self:GetData("stack", self.bInstanceMaxstack and self.maxStackSize or 1)
|
||||
end
|
||||
|
||||
function ITEM:IsSingleItem()
|
||||
return self:GetStackSize() <= 1
|
||||
end
|
||||
|
||||
function ITEM:IsFullStack()
|
||||
return self:GetStackSize() == (self.maxStackSize or 1)
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("CanPlayerInteractItem", "ixStackableItemBase", function(client, action, item, data)
|
||||
if (!isentity(item) or !IsValid(item)) then return end
|
||||
|
||||
if (action == "take") then return end
|
||||
|
||||
local itemID = item.ixItemID
|
||||
if (!itemID) then return end
|
||||
|
||||
item = ix.item.instances[itemID]
|
||||
if (!item) then
|
||||
return
|
||||
end
|
||||
|
||||
if (item and item.maxStackSize and item.maxStackSize > 1 and !item:IsSingleItem()) then
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("InventoryItemAdded", "ixStackableItemInvAdd", function(oldInv, newInv, item)
|
||||
if (oldInv != nil or !item.maxStackSize or item.maxStackSize == 1) then return end
|
||||
if (item:IsFullStack() or item:GetData("bIsSplit")) then
|
||||
item:SetData("bIsSplit", nil)
|
||||
return
|
||||
end
|
||||
|
||||
local items = newInv:GetItemsByUniqueID(item.uniqueID, true)
|
||||
local id = item:GetID()
|
||||
for _, v in ipairs(items) do
|
||||
if (v:GetID() == id) then continue end
|
||||
|
||||
local totalSize = item:GetStackSize()
|
||||
if (v:GetStackSize() < v.maxStackSize) then
|
||||
local toMove = math.min(v.maxStackSize - v:GetStackSize(), totalSize)
|
||||
v:AddStack(toMove)
|
||||
totalSize = totalSize - toMove
|
||||
|
||||
if (totalSize == 0) then
|
||||
return ix.meta.item.Remove(item)
|
||||
end
|
||||
end
|
||||
|
||||
item:SetData("stack", totalSize)
|
||||
end
|
||||
end)
|
||||
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (!item:IsSingleItem()) then
|
||||
draw.SimpleText(
|
||||
item:GetStackSize(), "DermaDefault", w - 5, h - 5,
|
||||
color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM, 1, color_black
|
||||
)
|
||||
end
|
||||
|
||||
if (item.outlineColor) then
|
||||
surface.SetDrawColor(item.outlineColor)
|
||||
surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
|
||||
end
|
||||
end
|
||||
else
|
||||
function ITEM:Remove(bNoReplication, bNoDelete)
|
||||
return self:RemoveStack(1, bNoReplication, bNoDelete)
|
||||
end
|
||||
|
||||
function ITEM:AddStack(amount)
|
||||
local stack = self:GetData("stack")
|
||||
if (stack) then
|
||||
return self:SetStack(stack + amount)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:RemoveStack(amount, bNoReplication, bNoDelete)
|
||||
local stack = self:GetData("stack")
|
||||
if (stack) then
|
||||
return self:SetStack(stack - amount)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:SetStack(amount, bNoReplication, bNoDelete)
|
||||
self:SetData("stack", math.Clamp(amount, 0, self.maxStackSize))
|
||||
if (self:GetStackSize() == 0) then
|
||||
return ix.meta.item.Remove(self, bNoReplication, bNoDelete)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnInstanced()
|
||||
if (!self:GetData("stack")) then
|
||||
self:SetStack(self:GetStackSize())
|
||||
end
|
||||
end
|
||||
|
||||
ITEM.functions.combine = {
|
||||
OnRun = function(item, data)
|
||||
local other = ix.item.instances[data[1]]
|
||||
if (other:GetStackSize() + item:GetStackSize() > item.maxStackSize) then
|
||||
local added = item.maxStackSize - item:GetStackSize()
|
||||
item:AddStack(added) -- set to max stack size
|
||||
other:RemoveStack(added)
|
||||
else
|
||||
item:AddStack(other:GetStackSize())
|
||||
other:RemoveStack(other:GetStackSize())
|
||||
if (item.junk) then
|
||||
if (!item.player:GetCharacter():GetInventory():Add(item.junk)) then
|
||||
ix.item.Spawn(item.junk, item.player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item, data)
|
||||
if (!item.maxStackSize or item.maxStackSize < 2) then return false end
|
||||
|
||||
local other = ix.item.instances[data[1]]
|
||||
if (!other or other.uniqueID != item.uniqueID) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
ITEM.functions.split = {
|
||||
name = "Split Stack",
|
||||
isMulti = true,
|
||||
multiOptions = function(item, player)
|
||||
local options = {{name = "1", data = {1}}}
|
||||
|
||||
for i = 5, item:GetStackSize() - 1, 5 do
|
||||
options[#options + 1] = {name = tostring(i), data = {i}}
|
||||
end
|
||||
|
||||
if (item:GetStackSize() > 2) then
|
||||
options[#options + 1] = {name = "other", data = {-1}, OnClick = function(itemTable)
|
||||
Derma_StringRequest("Split Stack", "How many items do you wish to move to a new stack?", LocalPlayer().ixLastStackSize or "", function(text)
|
||||
local amount = tonumber(text)
|
||||
if (!amount or amount <= 0 or amount >= itemTable:GetStackSize()) then return end
|
||||
|
||||
LocalPlayer().ixLastStackSize = amount
|
||||
|
||||
net.Start("ixInventoryAction")
|
||||
net.WriteString("split")
|
||||
net.WriteUInt(itemTable.id, 32)
|
||||
net.WriteUInt(itemTable.invID, 32)
|
||||
net.WriteTable({amount})
|
||||
net.SendToServer()
|
||||
end)
|
||||
|
||||
return false
|
||||
end}
|
||||
end
|
||||
|
||||
return options
|
||||
end,
|
||||
OnRun = function(item, data)
|
||||
local amount = math.floor(tonumber(data and data[1] or 1) or 0)
|
||||
if (!amount or amount <= 0 or amount >= item:GetStackSize()) then return false end
|
||||
|
||||
local inventory = ix.item.inventories[item.invID]
|
||||
if (item.junk) then
|
||||
local junk = inventory:HasItem(item.junk)
|
||||
if (junk) then
|
||||
junk:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
inventory:Add(item.uniqueID, 1, {stack = amount, bIsSplit = true})
|
||||
item:RemoveStack(amount)
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
if (IsValid(item.entity)) then return false end
|
||||
|
||||
if (!item.maxStackSize or item.maxStackSize < 2 or item.bNoSplit == true) then return false end
|
||||
|
||||
local inventory = ix.item.inventories[item.invID]
|
||||
if (item.junk and !inventory:HasItem(item.junk)) then return false end
|
||||
|
||||
return !IsValid(item.entity) and !item:IsSingleItem() and inventory:FindEmptySlot(item.width, item.height) != nil
|
||||
end
|
||||
}
|
||||
333
gamemodes/helix/gamemode/items/base/sh_weapons.lua
Normal file
333
gamemodes/helix/gamemode/items/base/sh_weapons.lua
Normal file
@@ -0,0 +1,333 @@
|
||||
--[[
|
||||
| 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 = "Weapon"
|
||||
ITEM.description = "A Weapon."
|
||||
ITEM.category = "Weapons"
|
||||
ITEM.model = "models/weapons/w_pistol.mdl"
|
||||
ITEM.class = "weapon_pistol"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 2
|
||||
ITEM.isWeapon = true
|
||||
ITEM.isGrenade = false
|
||||
ITEM.weaponCategory = "sidearm"
|
||||
ITEM.useSound = "items/ammo_pickup.wav"
|
||||
|
||||
-- Inventory drawing
|
||||
if (CLIENT) then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
if (item:GetData("equip")) then
|
||||
surface.SetDrawColor(110, 255, 110, 100)
|
||||
surface.DrawRect(w - 14, h - 14, 8, 8)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:PopulateTooltip(tooltip)
|
||||
if (self:GetData("equip")) then
|
||||
local name = tooltip:GetRow("name")
|
||||
name:SetBackgroundColor(derma.GetColor("Success", tooltip))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- On item is dropped, Remove a weapon from the player and keep the ammo in the item.
|
||||
ITEM:Hook("drop", function(item)
|
||||
local inventory = ix.item.inventories[item.invID]
|
||||
|
||||
if (!inventory) then
|
||||
return
|
||||
end
|
||||
|
||||
-- the item could have been dropped by someone else (i.e someone searching this player), so we find the real owner
|
||||
local owner
|
||||
|
||||
for client, character in ix.util.GetCharacters() do
|
||||
if (character:GetID() == inventory.owner) then
|
||||
owner = client
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if (!IsValid(owner)) then
|
||||
return
|
||||
end
|
||||
|
||||
if (item:GetData("equip")) then
|
||||
item:SetData("equip", nil)
|
||||
|
||||
owner.carryWeapons = owner.carryWeapons or {}
|
||||
|
||||
local weapon = owner.carryWeapons[item.weaponCategory]
|
||||
|
||||
if (!IsValid(weapon)) then
|
||||
weapon = owner:GetWeapon(item.class)
|
||||
end
|
||||
|
||||
if (IsValid(weapon)) then
|
||||
item:SetData("ammo", weapon:Clip1())
|
||||
|
||||
owner:StripWeapon(item.class)
|
||||
owner.carryWeapons[item.weaponCategory] = nil
|
||||
if (ix.config.Get("equipSoundEnabled", true)) then
|
||||
owner:EmitSound(item.useSound, ix.config.Get("equipSoundLevel", 60))
|
||||
end
|
||||
end
|
||||
|
||||
item:RemovePAC(owner)
|
||||
end
|
||||
end)
|
||||
|
||||
-- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item.
|
||||
ITEM.functions.EquipUn = { -- sorry, for name order.
|
||||
name = "Unequip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/cross.png",
|
||||
OnRun = function(item)
|
||||
item:Unequip(item.player, true)
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") == true and
|
||||
hook.Run("CanPlayerUnequipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
-- On player eqipped the item, Gives a weapon to player and load the ammo data from the item.
|
||||
ITEM.functions.Equip = {
|
||||
name = "Equip",
|
||||
tip = "equipTip",
|
||||
icon = "icon16/tick.png",
|
||||
OnRun = function(item)
|
||||
item:Equip(item.player)
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
return !IsValid(item.entity) and IsValid(client) and item:GetData("equip") != true and
|
||||
hook.Run("CanPlayerEquipItem", client, item) != false
|
||||
end
|
||||
}
|
||||
|
||||
function ITEM:WearPAC(client)
|
||||
if (ix.pac and self.pacData) then
|
||||
client:AddPart(self.uniqueID, self)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:RemovePAC(client)
|
||||
if (ix.pac and self.pacData) then
|
||||
client:RemovePart(self.uniqueID)
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:Equip(client, bNoSelect, bNoSound)
|
||||
local items = client:GetCharacter():GetInventory():GetItems()
|
||||
|
||||
client.carryWeapons = client.carryWeapons or {}
|
||||
|
||||
for _, v in pairs(items) do
|
||||
if (v.id != self.id) then
|
||||
local itemTable = ix.item.instances[v.id]
|
||||
|
||||
if (!itemTable) then
|
||||
client:NotifyLocalized("tellAdmin", "wid!xt")
|
||||
|
||||
return false
|
||||
else
|
||||
if (itemTable.isWeapon and client.carryWeapons[self.weaponCategory] and itemTable:GetData("equip")) then
|
||||
client:NotifyLocalized("weaponSlotFilled", self.weaponCategory)
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (client:HasWeapon(self.class)) then
|
||||
client:StripWeapon(self.class)
|
||||
end
|
||||
|
||||
local weapon = client:Give(self.class, !self.isGrenade)
|
||||
|
||||
if (IsValid(weapon)) then
|
||||
local ammoType = weapon:GetPrimaryAmmoType()
|
||||
|
||||
client.carryWeapons[self.weaponCategory] = weapon
|
||||
|
||||
if (!bNoSelect) then
|
||||
client:SelectWeapon(weapon:GetClass())
|
||||
end
|
||||
|
||||
if (!bNoSound) then
|
||||
if (ix.config.Get("equipSoundEnabled")) then
|
||||
client:EmitSound(self.useSound, ix.config.Get("equipSoundLevel", 60))
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove default given ammo.
|
||||
if (client:GetAmmoCount(ammoType) == weapon:Clip1() and self:GetData("ammo", 0) == 0) then
|
||||
client:RemoveAmmo(weapon:Clip1(), ammoType)
|
||||
end
|
||||
|
||||
-- assume that a weapon with -1 clip1 and clip2 would be a throwable (i.e hl2 grenade)
|
||||
-- TODO: figure out if this interferes with any other weapons
|
||||
if (weapon:GetMaxClip1() == -1 and weapon:GetMaxClip2() == -1 and client:GetAmmoCount(ammoType) == 0) then
|
||||
client:SetAmmo(1, ammoType)
|
||||
end
|
||||
|
||||
self:SetData("equip", true)
|
||||
|
||||
if (self.isGrenade) then
|
||||
weapon:SetClip1(1)
|
||||
client:SetAmmo(0, ammoType)
|
||||
else
|
||||
weapon:SetClip1(self:GetData("ammo", 0))
|
||||
end
|
||||
|
||||
weapon.ixItem = self
|
||||
|
||||
if (self.OnEquipWeapon) then
|
||||
self:OnEquipWeapon(client, weapon)
|
||||
end
|
||||
else
|
||||
print(Format("[Helix] Cannot equip weapon - %s does not exist!", self.class))
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:Unequip(client, bPlaySound, bRemoveItem)
|
||||
client.carryWeapons = client.carryWeapons or {}
|
||||
|
||||
local weapon = client.carryWeapons[self.weaponCategory]
|
||||
|
||||
if (!IsValid(weapon)) then
|
||||
weapon = client:GetWeapon(self.class)
|
||||
end
|
||||
|
||||
if (IsValid(weapon)) then
|
||||
weapon.ixItem = nil
|
||||
|
||||
self:SetData("ammo", weapon:Clip1())
|
||||
client:StripWeapon(self.class)
|
||||
else
|
||||
print(Format("[Helix] Cannot unequip weapon - %s does not exist!", self.class))
|
||||
end
|
||||
|
||||
if (bPlaySound and ix.config.Get("equipSoundEnabled")) then
|
||||
client:EmitSound(self.useSound, ix.config.Get("equipSoundLevel", 60))
|
||||
end
|
||||
|
||||
client.carryWeapons[self.weaponCategory] = nil
|
||||
self:SetData("equip", nil)
|
||||
self:RemovePAC(client)
|
||||
|
||||
if (self.OnUnequipWeapon) then
|
||||
self:OnUnequipWeapon(client, weapon)
|
||||
end
|
||||
|
||||
if (bRemoveItem) then
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:CanTransfer(oldInventory, newInventory)
|
||||
if (newInventory and self:GetData("equip")) then
|
||||
local owner = self:GetOwner()
|
||||
|
||||
if (IsValid(owner)) then
|
||||
owner:NotifyLocalized("equippedWeapon")
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ITEM:OnLoadout()
|
||||
if (self:GetData("equip")) then
|
||||
local client = self.player
|
||||
client.carryWeapons = client.carryWeapons or {}
|
||||
|
||||
local weapon = client:Give(self.class, true)
|
||||
|
||||
if (IsValid(weapon)) then
|
||||
client:RemoveAmmo(weapon:Clip1(), weapon:GetPrimaryAmmoType())
|
||||
client.carryWeapons[self.weaponCategory] = weapon
|
||||
|
||||
weapon.ixItem = self
|
||||
weapon:SetClip1(self:GetData("ammo", 0))
|
||||
|
||||
if (self.OnEquipWeapon) then
|
||||
self:OnEquipWeapon(client, weapon)
|
||||
end
|
||||
else
|
||||
print(Format("[Helix] Cannot give weapon - %s does not exist!", self.class))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnSave()
|
||||
local weapon = self.player:GetWeapon(self.class)
|
||||
|
||||
if (IsValid(weapon) and weapon.ixItem == self and self:GetData("equip")) then
|
||||
self:SetData("ammo", weapon:Clip1())
|
||||
end
|
||||
end
|
||||
|
||||
function ITEM:OnRemoved()
|
||||
local inventory = ix.item.inventories[self.invID]
|
||||
local owner = inventory.GetOwner and inventory:GetOwner()
|
||||
|
||||
if (IsValid(owner) and owner:IsPlayer()) then
|
||||
local weapon = owner:GetWeapon(self.class)
|
||||
|
||||
if (IsValid(weapon)) then
|
||||
weapon:Remove()
|
||||
end
|
||||
|
||||
self:RemovePAC(owner)
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("PlayerDeath", "ixStripClip", function(client)
|
||||
client.carryWeapons = {}
|
||||
if (!client:GetCharacter()) then return end
|
||||
|
||||
for _, v in pairs(client:GetCharacter():GetInventory():GetItems()) do
|
||||
if (v.isWeapon and v:GetData("equip")) then
|
||||
v:SetData("ammo", nil)
|
||||
v:SetData("equip", nil)
|
||||
|
||||
if (v.pacData) then
|
||||
v:RemovePAC(client)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("EntityRemoved", "ixRemoveGrenade", function(entity)
|
||||
-- hack to remove hl2 grenades after they've all been thrown
|
||||
if (entity:GetClass() == "weapon_frag") then
|
||||
local client = entity:GetOwner()
|
||||
|
||||
if (IsValid(client) and client:IsPlayer() and client:GetCharacter()) then
|
||||
local ammoName = game.GetAmmoName(entity:GetPrimaryAmmoType())
|
||||
|
||||
if (isstring(ammoName) and ammoName:lower() == "grenade" and client:GetAmmoCount(ammoName) < 1
|
||||
and entity.ixItem and entity.ixItem.Unequip) then
|
||||
entity.ixItem:Unequip(client, false, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
30
gamemodes/helix/gamemode/items/pacoutfit/sh_skullmask.txt
Normal file
30
gamemodes/helix/gamemode/items/pacoutfit/sh_skullmask.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
ITEM.name = "Skull Mask"
|
||||
ITEM.description = "It's a skull mask."
|
||||
ITEM.model = "models/Gibs/HGIBS.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.outfitCategory = "hat"
|
||||
ITEM.pacData = {
|
||||
[1] = {
|
||||
["children"] = {
|
||||
[1] = {
|
||||
["children"] = {
|
||||
},
|
||||
["self"] = {
|
||||
["Angles"] = Angle(12.919322967529, 6.5696062847564e-006, -1.0949343050015e-005),
|
||||
["Position"] = Vector(-2.099609375, 0.019973754882813, 1.3180969238281),
|
||||
["UniqueID"] = "4249811628",
|
||||
["Size"] = 1.25,
|
||||
["Bone"] = "eyes",
|
||||
["Model"] = "models/Gibs/HGIBS.mdl",
|
||||
["ClassName"] = "model",
|
||||
},
|
||||
},
|
||||
},
|
||||
["self"] = {
|
||||
["ClassName"] = "group",
|
||||
["UniqueID"] = "907159817",
|
||||
["EditorExpand"] = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
3
gamemodes/helix/gamemode/items/sh_defaultitem.txt
Normal file
3
gamemodes/helix/gamemode/items/sh_defaultitem.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
ITEM.name = "Test Item"
|
||||
ITEM.description = "A test item!"
|
||||
ITEM.model = "models/props_c17/oildrum001.mdl"
|
||||
12
gamemodes/helix/gamemode/items/weapons/sh_357.txt
Normal file
12
gamemodes/helix/gamemode/items/weapons/sh_357.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
ITEM.name = "357"
|
||||
ITEM.description = "A sidearm utilising .357 Caliber ammunition."
|
||||
ITEM.model = "models/weapons/w_357.mdl"
|
||||
ITEM.class = "weapon_357"
|
||||
ITEM.weaponCategory = "sidearm"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 1
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(-17.581502914429, 250.7974395752, 0),
|
||||
fov = 5.412494001838,
|
||||
pos = Vector(57.109928131104, 181.7945098877, -60.738327026367)
|
||||
}
|
||||
12
gamemodes/helix/gamemode/items/weapons/sh_ar2.txt
Normal file
12
gamemodes/helix/gamemode/items/weapons/sh_ar2.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
ITEM.name = "AR2"
|
||||
ITEM.description = "A Weapon."
|
||||
ITEM.model = "models/weapons/w_IRifle.mdl"
|
||||
ITEM.class = "weapon_ar2"
|
||||
ITEM.weaponCategory = "primary"
|
||||
ITEM.width = 4
|
||||
ITEM.height = 2
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(-0.70499622821808, 268.25439453125, 0),
|
||||
fov = 12.085652091515,
|
||||
pos = Vector(0, 200, 0)
|
||||
}
|
||||
12
gamemodes/helix/gamemode/items/weapons/sh_crowbar.txt
Normal file
12
gamemodes/helix/gamemode/items/weapons/sh_crowbar.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
ITEM.name = "Crowbar"
|
||||
ITEM.description = "A slightly rusty looking crowbar."
|
||||
ITEM.model = "models/weapons/w_crowbar.mdl"
|
||||
ITEM.class = "weapon_crowbar"
|
||||
ITEM.weaponCategory = "melee"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 1
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(-0.23955784738064, 270.44906616211, 0),
|
||||
fov = 10.780103254469,
|
||||
pos = Vector(0, 200, 0)
|
||||
}
|
||||
12
gamemodes/helix/gamemode/items/weapons/sh_pistol.txt
Normal file
12
gamemodes/helix/gamemode/items/weapons/sh_pistol.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
ITEM.name = "9MM Pistol"
|
||||
ITEM.description = "A sidearm utilising 9mm Ammunition."
|
||||
ITEM.model = "models/weapons/w_pistol.mdl"
|
||||
ITEM.class = "weapon_pistol"
|
||||
ITEM.weaponCategory = "sidearm"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 1
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(0.33879372477531, 270.15808105469, 0),
|
||||
fov = 5.0470897275697,
|
||||
pos = Vector(0, 200, -1)
|
||||
}
|
||||
12
gamemodes/helix/gamemode/items/weapons/sh_smg1.txt
Normal file
12
gamemodes/helix/gamemode/items/weapons/sh_smg1.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
ITEM.name = "Sub Machine Gun"
|
||||
ITEM.description = "A Weapon."
|
||||
ITEM.model = "models/weapons/w_smg1.mdl"
|
||||
ITEM.class = "weapon_smg1"
|
||||
ITEM.weaponCategory = "primary"
|
||||
ITEM.width = 3
|
||||
ITEM.height = 2
|
||||
ITEM.iconCam = {
|
||||
ang = Angle(-0.020070368424058, 270.40155029297, 0),
|
||||
fov = 7.2253324508038,
|
||||
pos = Vector(0, 200, -1)
|
||||
}
|
||||
Reference in New Issue
Block a user