• Server frequent Crashes and lag
    6 replies, posted
Normally my server would run and then crash every now and then. But its been getting worse everyday for the past two weeks.Its at the point very loyal members of my server aren't playing on it anymore. In addition to teh crashes there have been many lag-waves I say waves because they can take up to a minute. And in addition I run a TTT server witth a ragdoll removing addon and a prop spamming removal addon. If I need to show additional information I will but I don't think it'll be necessary. Please leave your experience with lag-waves and crashes in the comments. It would be more appreciated if you can tell me a solution or where to go for the best solution (a.k.a. a different site) I need to know if its my error(Bad addon, etc.) or If its the host's error
Bump
bump
I don't have any solution, my server crashed like 6 times in 2 days.
Mine is doing a lot worse, I need some kind of option.
To find out if it's a bad addon: Remove all addons, and add them back one by one, starting the server after each addition and seeing if it crashes. If it crashes as often as you say it does, this shouldn't be a problem. If that doesn't yield any promise (eg, server crashes with no addons), then it's the host's error or your config. If the above fails, could you post an edited version of your config file (removing sensitive information such as rcon passwrod), and the specifications for your server.
Try adding this into your server, It may help. garrysmod/lua/autorun/server/ make a folder called networkvars.lua and add this code into it. [QUOTE]AddCSLuaFile() local ENTITY = FindMetaTable("Entity"); if(!NWVarsIndexes) then NWVarsIndexes = {} end if(!NWVarsIntIndexes) then NWVarsIntIndexes = {} end if(!NWVarsEntityValues) then NWVarsEntityValues = {} end if(!NWVarsEntityTypes) then NWVarsEntityTypes = {} end if(!NWVarsEntityReferences) then NWVarsEntityReferences = {} end CurrentNWVarsIndex = 1 local function creatEntityReference(entIndex) local reference = {EntIndex = entIndex, IsEntReference = true} if(!NWVarsEntityReferences[entIndex]) then NWVarsEntityReferences[entIndex] = {} end table.insert(NWVarsEntityReferences[entIndex], reference) return reference end local function invalidateEntityReferences(entIndex) if(!NWVarsEntityReferences[entIndex]) then return end if(!NWVarsEntityReferences[-1]) then NWVarsEntityReferences[-1] = {} end for k,v in pairs(NWVarsEntityReferences[entIndex]) do v.EntIndex = -1 table.insert(NWVarsEntityReferences[-1], v) end NWVarsEntityReferences[entIndex] = nil end local noConverter = function(arg) return arg end local entityConverter = function(arg) local argType = type(arg) if(argType == "number") then return Entity(arg) elseif(argType == "table" && arg.IsEntReference == true) then return Entity(arg.EntIndex) end return arg end local convertFunctions = { ["Bool"] = tobool, ["String"] = tostring, ["Vector"] = noConverter, ["Angle"] = noConverter, ["Int"] = tonumber, ["Float"] = tonumber, ["Entity"] = entityConverter } local function writeInt(number) net.WriteInt(number, 32) end local function writeEntity(ent) net.WriteUInt(ent:EntIndex(),16) end local sendFunctions = { ["Bool"] = net.WriteBool, ["String"] = net.WriteString, ["Vector"] = net.WriteVector, ["Angle"] = net.WriteAngle, ["Int"] = writeInt, ["Float"] = net.WriteFloat, ["Entity"] = writeEntity } local defaultValues = { ["Bool"] = false, ["String"] = "", ["Vector"] = Vector(0,0,0), ["Angle"] = Angle(0,0,0), ["Int"] = 0, ["Float"] = 0, ["Entity"] = Entity(-1) } local function addIndex(key) NWVarsIndexes[key] = CurrentNWVarsIndex NWVarsIntIndexes[CurrentNWVarsIndex] = key net.Start("perpheads_NWVars_add") net.WriteUInt(CurrentNWVarsIndex,16) net.WriteString(key) net.Broadcast() CurrentNWVarsIndex = CurrentNWVarsIndex + 1 end local functionNames = {"String", "Int", "Bool", "Angle", "Vector", "Float", "Entity"} for k,functionName in pairs(functionNames) do ENTITY["SetNW" .. functionName] = function(self, key, value) key = string.lower(key) if(!IsValid(self)) then Error("Invalid self") end if(!NWVarsEntityValues[self:EntIndex()]) then NWVarsEntityValues[self:EntIndex()] = {} end if(value == nil) then NWVarsEntityValues[self:EntIndex()][key] = nil else NWVarsEntityValues[self:EntIndex()][key] = convertFunctions[functionName](value) end if(!SERVER) then return end if(!NWVarsIndexes[key]) then addIndex(key) end if(!NWVarsEntityTypes[self:EntIndex()]) then NWVarsEntityTypes[self:EntIndex()] = {} end if(value == nil) then NWVarsEntityTypes[self:EntIndex()][key] = nil net.Start("perpheads_NWVars_unset") net.WriteUInt(self:EntIndex(),16) net.WriteUInt(NWVarsIndexes[key],16) net.Broadcast() else NWVarsEntityTypes[self:EntIndex()][key] = k net.Start("perpheads_NWVars_set" .. functionName) net.WriteUInt(self:EntIndex(), 16) net.WriteUInt(NWVarsIndexes[key],16) sendFunctions[functionName](convertFunctions[functionName](value)) net.Broadcast() end end ENTITY["SetGlobal" .. functionName] = function(key, value) Entity(0)["SetNW" .. functionName](Entity(0), key, value) end ENTITY["GetGlobal" .. functionName] = function(key, default) Entity(0)["GetNW" .. functionName](Entity(0), key, default) end ENTITY["GetNW" .. functionName] = function(self, key, default) key = string.lower(key) if(!IsValid(self)) then Error("Invalid self") end if(!NWVarsEntityValues[self:EntIndex()] || !NWVarsEntityValues[self:EntIndex()][key]) then return Either(default == nil, defaultValues[functionName], default) end return convertFunctions[functionName](NWVarsEntityValues[self:EntIndex()][key]) end ENTITY["GetNetworked" .. functionName] = ENTITY["GetNW" .. functionName] ENTITY["SetNetworked" .. functionName] = ENTITY["SetNW" .. functionName] end if(SERVER) then util.AddNetworkString("perpheads_NWVars_add") for k,v in pairs(functionNames) do util.AddNetworkString("perpheads_NWVars_set" .. v) end util.AddNetworkString("perpheads_NWVars_unset") util.AddNetworkString("perpheads_NWVars_load_keys") util.AddNetworkString("perpheads_NWVars_load_values") util.AddNetworkString("perpheads_NWVars_remove") hook.Add("PlayerInitialSpawn", "NWVarsSpawnHook", function(ply) net.Start("perpheads_NWVars_load_keys") net.WriteUInt(#NWVarsIntIndexes,16) for i = 1, #NWVarsIntIndexes do net.WriteString(NWVarsIntIndexes[i]) end net.Send(ply) for k,v in pairs(NWVarsEntityValues) do net.Start("perpheads_NWVars_load_values") net.WriteUInt(k,16) net.WriteUInt(table.Count(v), 16) for key, value in pairs(v) do net.WriteUInt(NWVarsIndexes[key], 16) local varType = NWVarsEntityTypes[k][key] net.WriteUInt(varType, 8) sendFunctions[functionNames[varType]](value) end net.Send(ply) end end) hook.Add("EntityRemoved", "NWVarsRemovedHook", function(ent) NWVarsEntityValues[ent:EntIndex()] = nil NWVarsEntityTypes[ent:EntIndex()] = nil invalidateEntityReferences(ent:EntIndex()) net.Start("perpheads_NWVars_remove") net.WriteUInt(ent:EntIndex(),16) net.Broadcast() end) else net.Receive("perpheads_NWVars_load_keys", function() for i = 1, net.ReadUInt(16) do local key = net.ReadString() NWVarsIntIndexes[i] = key NWVarsIndexes[key] = i end end) local function readInt() return net.ReadInt(32) end local function readEntity() return creatEntityReference(net.ReadUInt(16)) end local readFunctions = { ["Bool"] = net.ReadBool, ["String"] = net.ReadString, ["Vector"] = net.ReadVector, ["Angle"] = net.ReadAngle, ["Int"] = readInt, ["Float"] = net.ReadFloat, ["Entity"] = readEntity } local doneLoading = false net.Receive("perpheads_NWVars_load_values", function() local index = net.ReadUInt(16) if(!NWVarsEntityValues[index]) then NWVarsEntityValues[index] = {} end for i = 1, net.ReadUInt(16) do local keyIndex = net.ReadUInt(16) local varType = net.ReadUInt(8) local value = readFunctions[functionNames[varType]]() NWVarsEntityValues[index][NWVarsIntIndexes[keyIndex]] = value end doneLoading = true end) for k,v in pairs(functionNames) do net.Receive("perpheads_NWVars_set" .. v, function() local index = net.ReadUInt(16) local keyIndex = net.ReadUInt(16) local value = readFunctions[v]() if(!doneLoading) then return end if(!NWVarsEntityValues[index]) then NWVarsEntityValues[index] = {} end NWVarsEntityValues[index][NWVarsIntIndexes[keyIndex]] = value end) end net.Receive("perpheads_NWVars_unset", function() local index = net.ReadUInt(16) local keyIndex = net.ReadUInt(16) if(!doneLoading) then return end if(!NWVarsEntityValues[index]) then return end NWVarsEntityValues[index][NWVarsIntIndexes[keyIndex]] = nil end) net.Receive("perpheads_NWVars_add", function() local index = net.ReadUInt(16) local key = net.ReadString() NWVarsIndexes[key] = index NWVarsIntIndexes[index] = key end) net.Receive("perpheads_NWVars_remove", function() local entIndex = net.ReadUInt(16) invalidateEntityReferences(entIndex) NWVarsEntityValues[entIndex] = nil end) end[/QUOTE] This may not fix it, but at least for me It helps with lag.
Sorry, you need to Log In to post a reply to this thread.