Ammo crate... and all that comes with it
This commit is contained in:
parent
c6feef0797
commit
fbff152e78
|
@ -0,0 +1,28 @@
|
||||||
|
AddCSLuaFile()
|
||||||
|
|
||||||
|
ENT.Type = "anim"
|
||||||
|
|
||||||
|
function ENT:Initialize()
|
||||||
|
self:SetModel( "models/items/boxsrounds.mdl" )
|
||||||
|
if SERVER then
|
||||||
|
self:SetUseType( SIMPLE_USE )
|
||||||
|
|
||||||
|
self:PhysicsInit(SOLID_VPHYSICS)
|
||||||
|
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||||
|
self:SetSolid(SOLID_VPHYSICS)
|
||||||
|
self:SetCollisionGroup(COLLISION_GROUP_WEAPON)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ENT:Use( activator )
|
||||||
|
if ( activator:IsPlayer() ) then
|
||||||
|
local wep = activator:GetActiveWeapon()
|
||||||
|
local bt, bc = wep:BTable(), wep:BClass()
|
||||||
|
for i=1, 3 do
|
||||||
|
if bt["Ammo" .. i] and bt.Loaded != i then
|
||||||
|
bt["Ammo" .. i] = bc.Ammo
|
||||||
|
wep:BSend( { "Ammo" .. i, false, bc.Ammo } )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
util.AddNetworkString( "Benny_StatRegen" )
|
||||||
|
function SWEP:BSend( ... )
|
||||||
|
net.Start( "Benny_StatRegen" )
|
||||||
|
net.WriteUInt( #{ ... }, 4 )
|
||||||
|
for i, v in ipairs( { ... } ) do
|
||||||
|
net.WriteString( v[1] )
|
||||||
|
net.WriteBool( v[2] )
|
||||||
|
if v[2] then
|
||||||
|
net.WriteString( v[3] )
|
||||||
|
else
|
||||||
|
net.WriteDouble( v[3] )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
net.Send( self:GetOwner() )
|
||||||
|
end
|
||||||
|
else
|
||||||
|
net.Receive( "Benny_StatRegen", function( len, ply )
|
||||||
|
local count = net.ReadUInt( 4 )
|
||||||
|
|
||||||
|
for i=1, count do
|
||||||
|
local stat = net.ReadString()
|
||||||
|
local str = net.ReadBool()
|
||||||
|
local data
|
||||||
|
if str then
|
||||||
|
data = net.ReadString()
|
||||||
|
else
|
||||||
|
data = net.ReadDouble()
|
||||||
|
end
|
||||||
|
LocalPlayer():GetActiveWeapon():BTable()[stat] = data
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
|
@ -19,6 +19,9 @@ SWEP.Secondary.DefaultClip = 0
|
||||||
SWEP.Secondary.Automatic = true
|
SWEP.Secondary.Automatic = true
|
||||||
SWEP.Secondary.Ammo = "none"
|
SWEP.Secondary.Ammo = "none"
|
||||||
|
|
||||||
|
AddCSLuaFile( "sh_statregen.lua" )
|
||||||
|
include ( "sh_statregen.lua" )
|
||||||
|
|
||||||
function SWEP:SetupDataTables()
|
function SWEP:SetupDataTables()
|
||||||
self:NetworkVar( "Float", 0, "Aim" )
|
self:NetworkVar( "Float", 0, "Aim" )
|
||||||
self:NetworkVar( "Float", 1, "Delay1" )
|
self:NetworkVar( "Float", 1, "Delay1" )
|
|
@ -134,10 +134,10 @@ WEAPONS["toolgun"] = {
|
||||||
|
|
||||||
local tr = p:GetEyeTrace()
|
local tr = p:GetEyeTrace()
|
||||||
if SERVER then
|
if SERVER then
|
||||||
local summon = ents.Create( "bnpc_human" )
|
local summon = ents.Create( "bitem_ammo" )
|
||||||
-- summon:SetModel( "models/props_junk/cardboard_box001a.mdl" )
|
-- summon:SetModel( "models/props_junk/cardboard_box001a.mdl" )
|
||||||
-- summon:Give( "weapon_stunstick")
|
-- summon:Give( "weapon_stunstick")
|
||||||
summon:SetPos( tr.HitPos )
|
summon:SetPos( tr.HitPos + tr.HitNormal )
|
||||||
summon:Spawn()
|
summon:Spawn()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue