Began work on Dynamic Networking with Intcode

master
AlmTech Software 5 years ago
parent f2084d9321
commit e7041e6f13
  1. 6
      gamemode/engine/core/client/cl_inventory_net.lua
  2. 13
      gamemode/engine/lib/server/sv_networking.lua
  3. 2
      gamemode/settings/sh_items.lua
  4. 11
      gamemode/shared.lua

@ -0,0 +1,6 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/

@ -8,6 +8,7 @@
Quantum.Net = {} Quantum.Net = {}
util.AddNetworkString( "quantum_menu_net" ) util.AddNetworkString( "quantum_menu_net" )
util.AddNetworkString( "quantum_menu_button_net" ) util.AddNetworkString( "quantum_menu_button_net" )
util.AddNetworkString( "quantum_item_action" )
local function checkCacheTable( ply, cache_id, dt ) local function checkCacheTable( ply, cache_id, dt )
Quantum.Debug( "Checking cache tables (" .. tostring(ply) .. " | " .. tostring(cache_id) .. " | " .. tostring(dt) .. ")" ) Quantum.Debug( "Checking cache tables (" .. tostring(ply) .. " | " .. tostring(cache_id) .. " | " .. tostring(dt) .. ")" )
@ -114,3 +115,15 @@ net.Receive( "quantum_menu_button_net", function( len, pl )
local args = net.ReadTable() local args = net.ReadTable()
runNetFunc( pl, funcid, args ) runNetFunc( pl, funcid, args )
end) end)
Quantum.Net.Inventory = {}
local function WriteIntcode( intcode ) net.WriteInt( intcode, Quantum.IntCode.BIT_SIZE ) end
function Quantum.Net.Inventory.SendItem( pl, index, itemid, amount ) -- sends a item to the client with amount of it, this is a DYNAMIC networking solution
net.Start( "quantum_item_action" )
WriteIntcode( Quantum.IntCode.SEND_ITEM )
net.WriteInt( index, 8 )
net.Send( pl )
end

@ -11,7 +11,7 @@ Quantum.Item.Create( "test", {
model = "models/props_phx/gears/bevel12.mdl", model = "models/props_phx/gears/bevel12.mdl",
soulbound = true, soulbound = true,
equipable = false, equipable = false,
rarity = Quantum.Rarity.Legendary, rarity = Quantum.Rarity.Rare,
usefunction = function() print( "Test!" ) end, usefunction = function() print( "Test!" ) end,
consumefunction = function() print( "Test 2!" ) end consumefunction = function() print( "Test 2!" ) end
} ) } )

@ -18,3 +18,14 @@ Quantum.EmptyFunction = function() end
include( "engine/sh_debug.lua" ) -- add the debug functions and stuff include( "engine/sh_debug.lua" ) -- add the debug functions and stuff
include( "settings/sh_settings.lua" ) include( "settings/sh_settings.lua" )
Quantum.IntCode = {
SEND_ITEM = 0,
DROP_ITEM = 1,
USE_ITEM = 2,
EAT_ITEM = 3,
EQUIP_ITEM = 4,
DESTROY_ITEM = 5,
BIT_SIZE = 3
}

Loading…
Cancel
Save