diff --git a/entities/entities/q_crafting_station/init.lua b/entities/entities/q_crafting_station/init.lua index 6387de5..6d2b951 100644 --- a/entities/entities/q_crafting_station/init.lua +++ b/entities/entities/q_crafting_station/init.lua @@ -24,14 +24,6 @@ function ENT:Initialize() end -function ENT:Use( activator, caller ) - -- if( activator:IsPlayer() ) then - -- if( activator.isloaded ) then - -- Quantum.Net.OpenMenu( activator, "crafting" ) - -- end - -- end -end - function ENT:InitializeStation( stationid, pos, ang ) if( pos == nil || ang == nil ) then return end diff --git a/gamemode/engine/core/server/sv_player_damage.lua b/gamemode/engine/core/server/sv_player_damage.lua index 42bcce7..25bf8dc 100644 --- a/gamemode/engine/core/server/sv_player_damage.lua +++ b/gamemode/engine/core/server/sv_player_damage.lua @@ -17,11 +17,11 @@ local damagescales = { function GM:ScalePlayerDamage( pl, hitgroup, dmginfo ) -- This is used for getting shot etc if( damagescales[hitgroup] ~= nil ) then dmginfo:ScaleDamage( damagescales[hitgroup] ) end - Quantum.Debug( tostring(pl) .. " got damaged ( " .. tostring(hitgroup) .. " : " .. tostring( math.Round( dmginfo:GetDamage() ) ) .. " )" ) + Quantum.Debug( Quantum.PrintPlayer( pl ) .. " got damaged ( " .. tostring(hitgroup) .. " : " .. tostring( math.Round( dmginfo:GetDamage() ) ) .. " )" ) end function GM:GetFallDamage( pl, vel ) - Quantum.Debug( tostring(pl) .. " got damaged ( Fall Damage : " .. tostring( math.Round( vel / 8 ) ) .. " )" ) + Quantum.Debug( Quantum.PrintPlayer( pl ) .. " got damaged ( Fall Damage : " .. tostring( math.Round( vel / 8 ) ) .. " )" ) return vel / 8 -- Makes the player take more "realistic" fall damage end diff --git a/gamemode/engine/core/server/sv_player_init.lua b/gamemode/engine/core/server/sv_player_init.lua index f94bf5d..1a903e6 100644 --- a/gamemode/engine/core/server/sv_player_init.lua +++ b/gamemode/engine/core/server/sv_player_init.lua @@ -48,7 +48,7 @@ local function setUpPlayer( ply ) ply:Give( "quantum_hands" ) ply:SelectWeapon( "quantum_hands" ) - Quantum.Debug( tostring( ply ) .. charnametxt ) + Quantum.Debug( Quantum.PrintPlayer( pl ) .. charnametxt ) end function GM:PlayerSpawn( ply ) diff --git a/gamemode/engine/lib/server/sv_character.lua b/gamemode/engine/lib/server/sv_character.lua index 9545c0f..6648013 100644 --- a/gamemode/engine/lib/server/sv_character.lua +++ b/gamemode/engine/lib/server/sv_character.lua @@ -64,7 +64,7 @@ function Quantum.Server.Char.Remove( pl, index ) end function Quantum.Server.Char.GetCurrentCharacter( pl ) - if( pl.character == nil ) then Quantum.Error( tostring( pl ) .. " doesn't have a character! Unable to get current character table." ) end + if( pl.character == nil ) then Quantum.Error( Quantum.PrintPlayer( pl ) .. " doesn't have a character! Unable to get current character table." ) end return pl.character end diff --git a/gamemode/engine/lib/server/sv_inventory.lua b/gamemode/engine/lib/server/sv_inventory.lua index bf2c91f..8a5f40cd 100644 --- a/gamemode/engine/lib/server/sv_inventory.lua +++ b/gamemode/engine/lib/server/sv_inventory.lua @@ -367,7 +367,7 @@ function Quantum.Server.Inventory.DropItem( pl, index, amount ) -- Quantum.Serve Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) end else - Quantum.Error( "Player " .. tostring( pl ) .. " tried to drop a something from index=" .. tostring(index) .. " where there exists no item." ) + Quantum.Error( "Player " .. Quantum.PrintPlayer( pl ) .. " tried to drop a something from index=" .. tostring(index) .. " where there exists no item." ) end end diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 26c283a..820e2a3 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -18,26 +18,27 @@ local function checkCacheTable( ply, cache_id, dt ) Quantum.Error( tostring(ply) .. " does not have a cache table, creating..." ) ply.cache = {} if( ply.cache ~= nil ) then Quantum.Debug( "Success! Created cache table for " .. tostring(ply) ) end - else - if( ply.cache[cache_id] == nil ) then - Quantum.Debug( tostring(ply) .. " does not have a cache for '" .. tostring(cache_id) .. "'. Creating..." ) - ply.cache[cache_id] = { - id = cache_id, - cache = datatable - } - if( ply.cache[cache_id] ~= nil && table.Count( ply.cache[cache_id] ) >= 1 ) then - Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." ) - if( ply.cache[cache_id].count == nil ) then - ply.cache[cache_id].count = 1 - else - ply.cache[cache_id].count = ply.cache[cache_id].count + 1 -- keep count - end - else - Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." ) - ply.cache[cache_id] = nil -- remove the cache since it is "broken" - end + end + + if( ply.cache[cache_id] == nil ) then + Quantum.Debug( tostring(ply) .. " does not have a cache for '" .. tostring(cache_id) .. "'. Creating..." ) + ply.cache[cache_id] = { + id = cache_id, + cache = datatable + } + if( ply.cache[cache_id] ~= nil ) then + Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." ) + if( ply.cache[cache_id].count == nil ) then + ply.cache[cache_id].count = 1 + else + ply.cache[cache_id].count = ply.cache[cache_id].count + 1 -- keep count + end + else + Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." ) + ply.cache[cache_id] = nil -- remove the cache since it is "broken" end end + return ply.cache[cache_id] end @@ -45,7 +46,6 @@ local function CacheDatatableMethod( id, datatable, ply ) ply.cache[id] = checkCacheTable( ply, id, datatable ) -- check caching tables etc Quantum.Debug( "(" .. tostring(ply) .. " | " .. tostring(id) .. ") Removing known data in cache from datatable..." ) if( ply.cache[id] ~= nil ) then - PrintTable(ply.cache[id]) if( ply.cache[id].count > 1 ) then -- dont want to filter out data if this is the first time. for k, v in pairs( datatable ) do -- loop through the datatable for k2, v2 in pairs( table.GetKeys( ply.cache[id].cache ) ) do -- check each key with each key from the record cache @@ -79,7 +79,7 @@ local function SendDatatableToClient( client, dt, type ) net.WriteTable( datatable ) -- send the data to the player end net.Send( client ) - Quantum.Debug("Net message sent.") + Quantum.Debug("Net message sent.\n") end function Quantum.Net.OpenMenu( pl, type, dt ) @@ -95,10 +95,10 @@ local netfuncs = { createChar = function( pl, args ) pl.charcount = Quantum.Server.Char.GetCharCount( pl ) if( #args.name > 16 ) then - Quantum.Debug( "Player " .. tostring( pl ) .. " character name too long. Unable to create." ) + Quantum.Debug( "Player " .. Quantum.PrintPlayer( pl ) .. " character name too long. Unable to create." ) return elseif( pl.charcount + 1 > Quantum.CharacterLimit ) then -- character limit - Quantum.Debug( "Player " .. tostring( pl ) .. " tried to exceed their character limit." ) + Quantum.Debug( "Player " .. Quantum.PrintPlayer( pl ) .. " tried to exceed their character limit." ) return end Quantum.Server.Char.Load( pl, pl.charcount + 1, args ) diff --git a/gamemode/engine/vars/sh_vars.lua b/gamemode/engine/vars/sh_vars.lua index 852482d..8db976e 100644 --- a/gamemode/engine/vars/sh_vars.lua +++ b/gamemode/engine/vars/sh_vars.lua @@ -51,4 +51,8 @@ function Quantum.calculateNeededBits( n ) return math.ceil( math.log( n, 2 ) ) e function Quantum.WriteIntcode( intcode ) net.WriteInt( intcode, Quantum.IntCode.BIT_SIZE ) +end + +function Quantum.PrintPlayer( pl ) + return pl:Nick() .. " | " .. pl:SteamID() end \ No newline at end of file