diff --git a/gamemodes/benny/entities/entities/bitem_ammo.lua b/gamemodes/benny/entities/entities/bitem_ammo.lua new file mode 100644 index 0000000..627dd75 --- /dev/null +++ b/gamemodes/benny/entities/entities/bitem_ammo.lua @@ -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 \ No newline at end of file diff --git a/gamemodes/benny/entities/weapons/benny/sh_statregen.lua b/gamemodes/benny/entities/weapons/benny/sh_statregen.lua new file mode 100644 index 0000000..6085926 --- /dev/null +++ b/gamemodes/benny/entities/weapons/benny/sh_statregen.lua @@ -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 \ No newline at end of file diff --git a/gamemodes/benny/entities/weapons/benny.lua b/gamemodes/benny/entities/weapons/benny/shared.lua similarity index 99% rename from gamemodes/benny/entities/weapons/benny.lua rename to gamemodes/benny/entities/weapons/benny/shared.lua index 6b1a59c..e5419aa 100644 --- a/gamemodes/benny/entities/weapons/benny.lua +++ b/gamemodes/benny/entities/weapons/benny/shared.lua @@ -19,6 +19,9 @@ SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Automatic = true SWEP.Secondary.Ammo = "none" +AddCSLuaFile( "sh_statregen.lua" ) +include ( "sh_statregen.lua" ) + function SWEP:SetupDataTables() self:NetworkVar( "Float", 0, "Aim" ) self:NetworkVar( "Float", 1, "Delay1" ) diff --git a/gamemodes/benny/gamemode/modules/player/sh_inventory.lua b/gamemodes/benny/gamemode/modules/player/sh_player.lua similarity index 100% rename from gamemodes/benny/gamemode/modules/player/sh_inventory.lua rename to gamemodes/benny/gamemode/modules/player/sh_player.lua diff --git a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua index 07cde5f..3575ef8 100644 --- a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua +++ b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua @@ -134,10 +134,10 @@ WEAPONS["toolgun"] = { local tr = p:GetEyeTrace() if SERVER then - local summon = ents.Create( "bnpc_human" ) + local summon = ents.Create( "bitem_ammo" ) -- summon:SetModel( "models/props_junk/cardboard_box001a.mdl" ) -- summon:Give( "weapon_stunstick") - summon:SetPos( tr.HitPos ) + summon:SetPos( tr.HitPos + tr.HitNormal ) summon:Spawn() end