diff --git a/gamemodes/benny/entities/weapons/benny/sh_inv.lua b/gamemodes/benny/entities/weapons/benny/sh_inv.lua index a4a8a21..bba14f1 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_inv.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_inv.lua @@ -48,7 +48,8 @@ function SWEP:BDeploy( hand, id ) assert( isbool(hand), "You forgot the hand." ) assert( isstring(id), "You forgot the ID." ) if self:D_GetID( hand ) == id then - return -- PROTO: If you're in the middle of holstering, cancel it + -- This breaks prediction somewhat!! + -- return -- PROTO: If you're in the middle of holstering, cancel it elseif self:D_GetID( hand ) != "" then self:BHolster( hand ) end @@ -88,5 +89,6 @@ function SWEP:BHolster( hand ) end self:D_SetID( hand, "" ) + self:D_SetMagID( hand, 0 ) self:D_SetClip( hand, 0 ) end \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/player/cl_hud.lua b/gamemodes/benny/gamemode/modules/player/cl_hud.lua index 81576a9..14a125e 100644 --- a/gamemodes/benny/gamemode/modules/player/cl_hud.lua +++ b/gamemodes/benny/gamemode/modules/player/cl_hud.lua @@ -234,7 +234,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() local b = ss(20) local p = LocalPlayer() -- PROTO: Make sure this is the 'benny' weapon. - local wep = p:GetActiveWeapon() + local wep = p:BennyCheck() local active = GetConVar("benny_hud_tempactive"):GetString() local scheme = schemes[active] @@ -287,7 +287,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() end end - if p:BennyCheck() then -- Weapon + if wep then -- Weapon local inv = p:INV_Get() local wep1 = wep:BTable( false ) local wep1c = wep:BClass( false ) @@ -309,7 +309,9 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() surface.SetDrawColor( scheme["fg"] ) surface.DrawRect( p_x+pb, p_y+pb, p_w-pb2, t_h ) - draw.SimpleText( wep1c.Name, "Benny_16", p_x+ss(6), p_y+ss(5), scheme["bg"], TEXT_ALIGN_TOP, TEXT_ALIGN_LEFT ) + draw.SimpleText( wep1c.Name, "Benny_16", p_x+ss(6), p_y+ss(5), scheme["bg"], TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP ) + + draw.SimpleText( wep:D_GetID( false ), "Benny_10", p_x+p_w-pb2, p_y+ss(7), scheme["bg"], TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP ) if wep:BClass( false ).Firemodes then -- Firemode surface.SetDrawColor( scheme["fg"] ) @@ -444,7 +446,19 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() local bump = 0 -- PROTO: Maybe check this every 10hz instead + do + -- local flipped = table.Flip( Entity(1):INV_ListFromBuckets() ) + -- local id = flipped[ Entity(1):GetActiveWeapon():D_GetID( false ) ] + for n, bucket in ipairs( inventorylist ) do + for i, v in ipairs( bucket ) do + if v == wep:D_GetID( false ) then + bucket_selected = n + item_selected = i + end + end + end + end for i, bucket in ipairs( inventorylist ) do surface.SetDrawColor( scheme["bg"] ) @@ -476,7 +490,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function() else for d, item in ipairs( bucket ) do local idata = WEAPONS[inv[item].Class] - local sel = d==item_selected + local sel = item==wep:D_GetID( false )--d==item_selected surface.SetDrawColor( scheme["bg"] ) surface.DrawRect( bump + b, (item_start+ybump) + b, size_textx, (sel and size_texty_sel or size_texty) ) if sel then @@ -678,7 +692,9 @@ do local ply = LocalPlayer() local buckets = ply:INV_Buckets() if buckets[bucket_selected] and buckets[bucket_selected][item_selected] then - RunConsoleCommand( "benny_inv_equip", buckets[bucket_selected][item_selected] ) + ply.CLIENTDESIRE = buckets[bucket_selected][item_selected] + + --RunConsoleCommand( "benny_inv_equip", buckets[bucket_selected][item_selected] ) end end local function Locate( ply, buckets, id ) diff --git a/gamemodes/benny/gamemode/modules/player/sh_checker.lua b/gamemodes/benny/gamemode/modules/player/sh_checker.lua index 123080d..3ec47f1 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_checker.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_checker.lua @@ -83,9 +83,9 @@ if SERVER then table.insert( regenlist, id ) else -- Punish - print( "The item the client requested didn't exist. Malicious? Not supporting for 30 seconds." ) - ply.CheckerRequestBan = CurTime() + 30 - return + print( ply, "The item the client requested, '" .. tostring(id) .."' didn't exist. Malicious?") -- Matters in public servers!! -- Not supporting for 5 seconds." ) + -- ply.CheckerRequestBan = CurTime() + 5 + -- return end end diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement.lua b/gamemodes/benny/gamemode/modules/player/sh_movement.lua index d38b4f4..5aaa180 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_movement.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_movement.lua @@ -61,7 +61,7 @@ hook.Add( "CreateMove", "Benny_CreateMove", function( cmd ) -- ad:Normalize() -- ad:Mul(320) - cmd:ClearMovement() + --cmd:ClearMovement() cmd:SetForwardMove( ad.x ) cmd:SetSideMove( ad.y ) @@ -132,7 +132,7 @@ hook.Add( "CreateMove", "Benny_CreateMove", function( cmd ) moveintent:Rotate( fixang ) - cmd:ClearMovement() + -- cmd:ClearMovement() cmd:SetForwardMove( moveintent.x ) cmd:SetSideMove( moveintent.y ) end diff --git a/gamemodes/benny/gamemode/modules/player/sh_player.lua b/gamemodes/benny/gamemode/modules/player/sh_player.lua index 175fbc4..d01a29f 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_player.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_player.lua @@ -21,7 +21,7 @@ local PT = FindMetaTable( "Player" ) function PT:BennyCheck() local wep = self:GetActiveWeapon() - return ( wep:IsValid() and wep:GetClass() == "benny" and wep.GetUserAim ) + return ( wep:IsValid() and wep:GetClass() == "benny" and wep.GetUserAim ) and wep or false end function PT:CamSpot( ang ) @@ -136,4 +136,56 @@ do end return inventorylist end -end \ No newline at end of file + -- PROTO: I am on an outdated version of GMod. + function table.Flip( tab ) + local res = {} + + for k, v in pairs( tab ) do + res[ v ] = k + end + + return res + end + function PT:INV_ListFromBuckets() + local buckets = self:INV_Buckets() + + local complete = {} + for n, bucket in ipairs( buckets ) do + for i, v in ipairs( bucket ) do + table.insert( complete, v ) + end + end + + return complete + end +end + +-- weapon select + +hook.Add("StartCommand", "Benny_INV_StartCommand", function( ply, cmd ) + local wep = ply:BennyCheck() + if wep then + local inv = ply:INV_Get() + local inv_bucketlist = ply:INV_ListFromBuckets() + local inv_bucketlist_flipped = table.Flip( inv_bucketlist ) + if CLIENT and ply.CLIENTDESIRE and inv[ply.CLIENTDESIRE ] and inv_bucketlist_flipped[ ply.CLIENTDESIRE ] then + cmd:SetUpMove( inv_bucketlist_flipped[ ply.CLIENTDESIRE ] ) + end + local id = cmd:GetUpMove() + + if id > 0 and inv_bucketlist[id] and inv[inv_bucketlist[id]] then + wep:BDeploy( false, inv_bucketlist[ id ] ) + if CLIENT and IsFirstTimePredicted() and wep:D_GetID( false ) == inv_bucketlist[ply.CLIENTDESIRE] then + ply.CLIENTDESIRE = 0 + end + end + + end +end) + + +-- cmd:KeyDown( IN_WEAPON1 ) +-- cmd:KeyDown( IN_WEAPON2 ) +-- cmd:KeyDown( IN_BULLRUSH ) +-- cmd:KeyDown( IN_GRENADE1 ) +-- cmd:KeyDown( IN_GRENADE2 ) \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua index be83b8e..75b5d55 100644 --- a/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua +++ b/gamemodes/benny/gamemode/modules/weapons/sh_weapons.lua @@ -929,7 +929,10 @@ do -- Grenades, nothing here is guaranteed. if SERVER then GrenadeCreate( self, data ) end local id = self:D_GetID( false ) self:BHolster( false ) - p:INV_Discard( id ) + + if SERVER or (CLIENT and IsFirstTimePredicted()) then + p:INV_Discard( id ) + end local subsequent = p:INV_Find( data.Class )[1] if subsequent then