Initial commit

This commit is contained in:
2026-03-15 14:54:49 +03:00
commit 64f8029c06
4027 changed files with 254888 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
ENT.Type = "anim"
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
ENT.PrintName = "Банк"
ENT.Category = "Scora"
ENT.Spawnable = true
ENT.AdminOnly = true
if SERVER then
AddCSLuaFile()
function ENT:Initialize()
self:SetModel( "models/props_lab/reciever_cart.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
self:GetPhysicsObject():EnableMotion( false )
end
function ENT:SpawnFunction( pl, trace, class )
local ent = ents.Create( class )
ent:SetPos( trace.HitPos + trace.HitNormal * 16 )
ent:Spawn()
return ent
end
function ENT:Use( pl )
if not IsValid( pl ) then return end
pl.Bank:Sync()
pl:OpenContainer( pl.Bank:GetID(), itemstore.Translate( "bank" ) )
end
concommand.Add( "itemstore_savebanks", function( pl )
if not game.SinglePlayer() and IsValid( pl ) then return end
local banks = {}
for _, ent in ipairs( ents.FindByClass( "itemstore_bank" ) ) do
table.insert( banks, {
Position = ent:GetPos(),
Angles = ent:GetAngles()
} )
end
file.Write( "itemstore/banks/" .. game.GetMap() .. ".txt", util.TableToJSON( banks ) )
print( "Banks for map " .. game.GetMap() .. " saved." )
end )
hook.Add( "InitPostEntity", "ItemStoreSpawnBanks", function()
local banks = util.JSONToTable( file.Read( "itemstore/banks/" .. game.GetMap() .. ".txt", "DATA" ) or "" ) or {}
for _, data in ipairs( banks ) do
local bank = ents.Create( "itemstore_bank" )
bank:SetPos( data.Position )
bank:SetAngles( data.Angles )
bank:Spawn()
end
end )
else
function ENT:DrawTranslucent()
self:DrawModel()
local text = itemstore.Translate( "bank" )
local font = "DermaLarge"
surface.SetFont( font )
local textw, texth = surface.GetTextSize( text )
local w = 5 + textw + 5
local h = 2 + texth + 2
local x, y = -w / 2, -h / 2
cam.Start3D2D( self:GetPos() + self:GetAngles():Up() * 50, Angle( 0, CurTime() * 45, 90 ), 0.35 )
surface.SetDrawColor( Color( 0, 0, 0, 200 ) )
surface.DrawRect( x, y, w, h )
draw.SimpleTextOutlined( text, font, 0, 0, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color( 0, 0, 0 ) )
cam.End3D2D()
end
end

View File

@@ -0,0 +1,95 @@
ENT.Type = "anim"
ENT.PrintName = "Маленькая Коробочка"
ENT.Category = "Scora"
ENT.Spawnable = true
ENT.AdminOnly = true
function ENT:SetupDataTables()
self:NetworkVar( "Entity", 0, "owning_ent" ) -- i feel really stupid.
end
if SERVER then
AddCSLuaFile()
ENT.Model = "models/props/cs_office/Cardboard_box02.mdl"
ENT.ContainerWidth = 4
ENT.ContainerHeight = 3
ENT.ContainerPages = 1
function ENT:Initialize()
self:SetModel( self.Model )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
self:GetPhysicsObject():Wake()
self.Container = itemstore.Container( self.ContainerWidth, self.ContainerHeight, self.ContainerPages )
self.Container:SetOwner( self )
if self.Items then
for _, item in ipairs( self.Items ) do
self.Container:AddItem( item:Copy() )
end
end
local function callback( con, pl )
if not IsValid( pl ) then return end
if pl:GetPos():Distance( self:GetPos() ) < 250 then
return true
end
return false
end
self.Container:AddCallback( "read", callback )
self.Container:AddCallback( "write", callback )
self:SetHealth( itemstore.config.BoxHealth )
end
function ENT:SpawnFunction( pl, trace, class )
local ent = ents.Create( class )
ent:SetPos( trace.HitPos + trace.HitNormal * 16 )
ent:Spawn()
return ent
end
function ENT:Use( pl )
self.Container:Sync()
pl:OpenContainer( self.Container:GetID(), "Box" )
end
function ENT:Break()
local effect = EffectData()
effect:SetOrigin( self:GetPos() )
util.Effect( "Explosion", effect, true, true )
for _, item in pairs( self.Container.Items ) do
item:CreateEntity( self:GetPos() )
end
self:Remove()
end
function ENT:OnTakeDamage( dmg )
if not itemstore.config.BoxBreakable then return end
self:SetHealth( self:Health() - dmg:GetDamage() )
if self:Health() <= 0 then
self:Break()
end
end
function ENT:OnRemove()
self.Container:Remove()
end
end

View File

@@ -0,0 +1,18 @@
ENT.Type = "anim"
ENT.Base = "itemstore_box"
ENT.PrintName = "Огромная Коробка"
ENT.Category = "Scora"
ENT.Spawnable = true
ENT.AdminOnly = true
if SERVER then
AddCSLuaFile()
ENT.Model = "models/props_junk/wood_crate001a_damaged.mdl"
ENT.ContainerWidth = 8
ENT.ContainerHeight = 4
ENT.ContainerPages = 2
end

View File

@@ -0,0 +1,18 @@
ENT.Type = "anim"
ENT.Base = "itemstore_box"
ENT.PrintName = "Большая Коробка"
ENT.Category = "Scora"
ENT.Spawnable = true
ENT.AdminOnly = true
if SERVER then
AddCSLuaFile()
ENT.Model = "models/props/cs_office/cardboard_box01.mdl"
ENT.ContainerWidth = 5
ENT.ContainerHeight = 4
ENT.ContainerPages = 1
end

View File

@@ -0,0 +1,24 @@
ENT.Type = "anim"
ENT.Base = "itemstore_box"
ENT.PrintName = "Смертельная Добыча"
ENT.Category = "Scora"
ENT.Spawnable = false
ENT.AdminOnly = false
if SERVER then
AddCSLuaFile()
ENT.Model = "models/props_junk/garbage_bag001a.mdl"
ENT.ContainerWidth = 5
ENT.ContainerHeight = 5
ENT.ContainerPages = 2
ENT.Timeout = 0
function ENT:Think()
if self.Timeout < CurTime() then self:Remove() end
end
end

View File

@@ -0,0 +1,106 @@
ENT.Type = "anim"
ENT.RenderGroup = RENDERGROUP_TRANSLUCENT
function ENT:SetItem( item )
self.Item = item
if SERVER then
self:Sync()
end
end
function ENT:GetItem()
return self.Item
end
if SERVER then
AddCSLuaFile()
function ENT:Initialize()
local item = self:GetItem()
if not item then self:Remove() end
self:SetModel( item:GetModel() )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self:SetUseType( SIMPLE_USE )
self:SetColor( item:GetColor() or color_white )
self:SetMaterial( item:GetMaterial() )
local phys = self:GetPhysicsObject()
if not IsValid( phys ) then
self:PhysicsInitSphere( 16, "default" )
phys = self:GetPhysicsObject()
end
phys:Wake()
end
function ENT:Use( pl )
if not IsValid( pl ) then return end
local item = self:GetItem()
if not item then return end
if pl.Inventory:AddItem( item ) then
pl:EmitSound( "items/itempickup.wav" )
self:Remove()
else
pl:SendError( "Ваш инвентарь полон." )
end
end
function ENT:Sync( pl )
local item = self:GetItem()
if not item then return end
net.Start( "ItemStoreSyncItem" )
net.WriteEntity( self )
net.WriteString( item.Class )
net.WriteTable( item.Data )
net.Send( pl or player.GetAll() )
end
util.AddNetworkString( "ItemStoreSyncItem" )
net.Receive( "ItemStoreSyncItem", function( len, pl )
if pl.ItemStoreTimeout and pl.ItemStoreTimeout > CurTime() then return end
local ent = net.ReadEntity()
if not IsValid( ent ) or ent:GetClass() ~= "itemstore_item" then return end
ent:Sync( pl )
pl.ItemStoreTimeout = CurTime() + ITEMSTORE_TIMEOUT
end )
else
function ENT:Initialize()
net.Start( "ItemStoreSyncItem" )
net.WriteEntity( self )
net.SendToServer()
end
function ENT:DrawTranslucent()
local item = self:GetItem()
if not item then return end
item:PreRender( self )
self:DrawModel()
item:PostRender( self )
end
net.Receive( "ItemStoreSyncItem", function()
local ent = net.ReadEntity()
if not IsValid( ent ) then return end
if not ent.SetItem then return end
local class = net.ReadString()
local data = net.ReadTable()
ent:SetItem( itemstore.Item( class, data ) )
end )
end