Fixed weapons in hands

This commit is contained in:
Fesiug 2024-03-08 20:10:47 -05:00
parent 7de193a68e
commit bf36cb7d24
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
5 changed files with 88 additions and 10 deletions

View File

@ -129,7 +129,8 @@ function SWEP:EquipItem( ent )
print("Pick up", ent)
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:AddEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
ent:AddEffects( EF_BONEMERGE )
ent:SetMoveType( MOVETYPE_NONE )
ent:SetParent( p )
ent:SetOwner( p )
ent:SetPos( vector_origin )
@ -155,16 +156,18 @@ function SWEP:DropItem()
local ent = self:GetActiveR()
if ent:IsValid() then
if CLIENT then print("DropItem called on CLIENT but certain things aren't finished yet.") return end
self:Deactive()
ent:SetParent( NULL )
ent:SetOwner( NULL )
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:RemoveEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL )
ent:RemoveEffects( EF_BONEMERGE )
ent:SetMoveType( MOVETYPE_VPHYSICS )
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
self:Deactive()
local inv = p:GetInventory()
inv[ent] = nil
@ -187,7 +190,9 @@ function SWEP:Think()
if p:IsValid() then
if self:ItemR() then
self:ItemR("Think")
end
self:SetHoldType( self:ItemR() and "revolver" or "normal" )
else
print( self, "Thinking without an owner." )
end

View File

@ -0,0 +1,58 @@
---------------------
-- Your Name is Benny
---------------------
if SERVER then
util.AddNetworkString( "Benny_DebugMenuSpawn" )
net.Receive( "Benny_DebugMenuSpawn", function( len, ply )
if !ply:IsAdmin() then return end
local ent = ents.Create( "b-item_" .. net.ReadString() )
ent:SetPos( ply:GetEyeTrace().HitPos )
ent:Spawn()
end)
return
end
local function dospawn( self )
net.Start( "Benny_DebugMenuSpawn" )
net.WriteString( self.iName )
net.SendToServer()
end
local function OpenDebugMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end
DebugMenu = vgui.Create("DFrame")
DebugMenu:SetSize( 400, 300 )
DebugMenu:Center()
DebugMenu:MakePopup()
local opt = DebugMenu:Add("DCollapsibleCategory")
opt:Dock( TOP )
local plist = DebugMenu:Add("DScrollPanel")
opt:SetContents( plist )
for iname, idata in SortedPairs( ITEMS ) do
local button = plist:Add("DButton")
button:Dock( TOP )
button:DockMargin( 4, 4, 4, 0 )
button:SetText( l8( idata.PrintName ) )
button.iName = iname
button.iData = idata
button.DoClick = dospawn
end
end
hook.Add("PlayerButtonDown", "PlayerButtonDown_DebugMenu", function( ply, button )
if button == KEY_F1 then
OpenDebugMenu()
end
end)
hook.Add("PlayerButtonUp", "PlayerButtonUp_DebugMenu", function( ply, button )
if button == KEY_F1 then
--if IsValid(DebugMenu) then DebugMenu:Remove() end
end
end)

View File

@ -87,6 +87,7 @@ local COLOR_MAIN = Color( 160, 160, 240 )
function GM:HUDPaint()
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
local handler = p:BennyCheck()
stack = util.Stack()
S_Push( 20, 20 )
@ -107,10 +108,10 @@ function GM:HUDPaint()
S_Push( 20, h - 60 - 20 )
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
hCol( COLOR_DARK )
hCol( v == handler:GetActiveR() and COLOR_BRIGHT or COLOR_DARK )
hRect( 0, 0, 120, 60 )
local x, y = hXY( 0, 0 )
draw.SimpleText( l8( v.Class.PrintName ), "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( l8( v.Class.PrintName ) .. "(" .. v:GetClip() .. "/" .. v.Class.ClipSize .. ")", "HUD_24", x + 120/2, y + 60/2, COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
S_Pop()

View File

@ -105,6 +105,18 @@ AddItem( "base_firearm", {
print( class, "Initialized a firearm" )
end,
["Attack"] = function( class, ent, handler )
if ent:GetClip() <= 0 then return end
if ent:GetDelay() > CurTime() then return end
ent:SetClip( ent:GetClip() - 1 )
ent:SetDelay( CurTime() + class.Delay )
end,
["Reload"] = function( class, ent, handler )
ent:SetClip( class.ClipSize )
end,
})
AddItem( "mk23", {
@ -113,7 +125,7 @@ AddItem( "mk23", {
Category = "pistol",
Base = "base_firearm",
Model = "models/weapons/w_smg1.mdl",
Model = "models/weapons/w_pist_elite_single.mdl",
ClipSize = 12,
Delay = (60/300),

View File

@ -8,6 +8,8 @@ BENNY = {}
local AC, IN = AddCSLuaFile, include
local CL = SERVER and AddCSLuaFile or include
AC("language.lua")
IN("language.lua")
AC("camera.lua")
@ -21,7 +23,7 @@ IN("player_class.lua")
AC("inventory.lua")
IN("inventory.lua")
AC("hud.lua")
if CLIENT then
IN("hud.lua")
end
AC("debugmenu.lua")
IN("debugmenu.lua")
CL("hud.lua")