From 7667e9ed9e73d45bec39dc171c9f83e741378ee6 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Fri, 3 Jan 2020 21:04:39 +0100 Subject: [PATCH] Fixed item model bug --- entities/entities/q_item/init.lua | 10 +++++++++- gamemode/engine/core/sh_player_binds.lua | 4 ++++ gamemode/engine/derma/menus/menu_charinfo.lua | 2 +- gamemode/engine/lib/server/sv_inventory.lua | 6 +++--- gamemode/engine/lib/server/sv_networking.lua | 3 --- gamemode/settings/sh_items.lua | 12 +++++++++++- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/entities/entities/q_item/init.lua b/entities/entities/q_item/init.lua index 5e6298d..35bb4e9 100644 --- a/entities/entities/q_item/init.lua +++ b/entities/entities/q_item/init.lua @@ -12,7 +12,6 @@ include( "shared.lua" ) function ENT:Initialize() - self:SetModel( "models/props_phx/gears/bevel12.mdl" ) self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) @@ -34,3 +33,12 @@ function ENT:Use( activator, caller ) end end end + +function ENT:InitializeItem( itemid, amount ) + self:SetModel( Quantum.Item.Get( itemid).model ) + self.itemid = itemid + self.amount = amount + + self:SetNWString( "q_item_id", itemid ) + self:SetNWInt( "q_item_amount", amount ) +end \ No newline at end of file diff --git a/gamemode/engine/core/sh_player_binds.lua b/gamemode/engine/core/sh_player_binds.lua index 3703d86..3498b80 100644 --- a/gamemode/engine/core/sh_player_binds.lua +++ b/gamemode/engine/core/sh_player_binds.lua @@ -17,5 +17,9 @@ if SERVER then function GM:KeyRelease( ply, key ) if( keyfuncs[key] ) then keyfuncs[key]( ply ) end end + + function GM:ShowHelp( ply ) + keyfuncs["mainMenu"]( ply ) + end end \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_charinfo.lua b/gamemode/engine/derma/menus/menu_charinfo.lua index d907977..0028e44 100644 --- a/gamemode/engine/derma/menus/menu_charinfo.lua +++ b/gamemode/engine/derma/menus/menu_charinfo.lua @@ -276,7 +276,7 @@ function menu.open( dt ) end end -hook.Add("ScoreboardShow", "Quantum_Menu_CharInfo_Open", function() --Quantum.Server.Inventory.GiveItem( Entity(1), "test2", 21 ) +hook.Add("ScoreboardShow", "Quantum_Menu_CharInfo_Open", function() -- if( InventoryStartTime == nil ) then -- InventoryStartTime = CurTime() -- end diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index 70fa40e..b2c2cef 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -221,10 +221,9 @@ function Quantum.Server.Inventory.DropItem( pl, index, amount ) -- Quantum.Serve -- spawn the item infront of the player local itemEnt = ents.Create( "q_item" ) if( IsValid( itemEnt ) ) then - itemEnt:SetModel( item.model ) + itemEnt:SetPos( pl:GetPos() + ( pl:GetForward() * 40 ) + Vector( 0, 0, 40 ) ) - itemEnt.amount = amount - itemEnt.itemid = itemid + itemEnt:InitializeItem( itemid, amount ) itemEnt:Spawn() timer.Simple( math.Clamp( Quantum.Server.Settings.ItemDespawnTimer, 1, 600 ), function() @@ -233,6 +232,7 @@ function Quantum.Server.Inventory.DropItem( pl, index, amount ) -- Quantum.Serve itemEnt:Remove() end end) + end end else diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 06be891..30602a0 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -165,9 +165,6 @@ end) local function UpdateAllPlayers() for i, pl in pairs( player.GetHumans() ) do - pl.isloaded = false - pl:KillSilent() - pl:Spawn() Quantum.Net.Inventory.Update( pl ) end end diff --git a/gamemode/settings/sh_items.lua b/gamemode/settings/sh_items.lua index 65ec8cc..f973932 100644 --- a/gamemode/settings/sh_items.lua +++ b/gamemode/settings/sh_items.lua @@ -20,7 +20,7 @@ Quantum.Item.Create( "test2", { name = "Trash Item Test", desc = "This is literall trash\nLine breaker test :D\n\nTest :D", model = "models/props_phx/gears/bevel12.mdl", - stack = 10, --wrong change later to 10 or something + stack = 10, soulbound = false, equipable = false, rarity = Quantum.Rarity.Trash, @@ -28,4 +28,14 @@ Quantum.Item.Create( "test2", { user:Kill() user:PrintChat( "You consumed trash and died!" ) end +} ) + +Quantum.Item.Create( "bomb", { + name = "WW2 Bomb", + desc = "Not a real item but okay.", + model = "models/props_phx/ww2bomb.mdl", + stack = 2, + soulbound = false, + equipable = false, + rarity = Quantum.Rarity.Epic } ) \ No newline at end of file