• Having issues transfering a table from server to client
    3 replies, posted
I've been working on a logging system for our server, but the table that I have in the shared code doesn't seem to update once I make changes to it through serverside. This means that the clientside version of the table is always empty, a.k.a the logs are empty. If anyone can help me that would be great. My code is: local may_damagelist = {} local may_chatlist = {} local may_proplist = {} if CLIENT then concommand.Add("may_openlogs", function() local may_frame = vgui.Create("DFrame") may_frame.title = "May's log system" may_frame.size = Vector(600, 400, 0) may_frame.index = 36 local may_scrollpanels = {} local may_exit = vgui.Create("DButton") local may_addtab = function(text) local scrollpanel = vgui.Create("DScrollPanel") scrollpanel.index = 6 scrollpanel:SetParent(may_frame) scrollpanel:SetSize(may_frame.size.x - 6 - 72 - 6 - 6, may_frame.size.y - 66) scrollpanel:SetPos(6 + 72 + 6, 36) scrollpanel:SetVisible(false) function scrollpanel:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end local vbar = scrollpanel:GetVBar() function vbar:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end function vbar.btnUp:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end function vbar.btnDown:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end function vbar.btnGrip:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end local button = vgui.Create("DButton") button:SetParent(may_frame) button:SetText(text) button:SetSize(72, 48) button:SetPos(6, may_frame.index) button:SetVisible(true) button:SetTextColor(Color(0, 255, 0)) button.DoClick = function() for k, v in pairs(may_scrollpanels) do v:SetVisible(false) end scrollpanel:SetVisible(true) surface.PlaySound("ambient/levels/canals/drip4.wav") end function button:Paint(w, h) if scrollpanel:IsVisible() then surface.SetDrawColor(Color(0, 255, 0)) surface.DrawRect(0, 0, w, h) button:SetTextColor(Color(255, 255, 255)) else surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) button:SetTextColor(Color(0, 255, 0)) end end may_frame.index = may_frame.index + 54 table.insert(may_scrollpanels, scrollpanel) return scrollpanel end local may_addlabel = function(text, panel) local label = vgui.Create("DLabel") surface.SetFont("Default") label:SetParent(panel) label:SetText(text) label:SetWide(surface.GetTextSize(text)) label:SetPos(6, panel.index) label:SetVisible(true) label:SetTextColor(Color(0, 255, 0)) panel.index = panel.index + 30 end may_frame.lblTitle.UpdateColours = function(label, skin) label:SetTextStyleColor(Color(0, 255, 0)) end may_frame:SetPos(ScrW() / 2 - (may_frame.size.x / 2), ScrH() / 2 - (may_frame.size.y / 2)) may_frame:SetSize(may_frame.size.x, may_frame.size.y) may_frame:SetVisible(true) may_frame:SetTitle(may_frame.title) may_frame:SetDraggable(true) may_frame:ShowCloseButton(false) may_frame:MakePopup() function may_frame:Paint(w, h) surface.SetDrawColor(Color(36, 36, 36, 225)) surface.DrawRect(0, 0, w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) end may_exit:SetParent(may_frame) may_exit:SetPos(may_frame.size.x - 30, 6) may_exit:SetSize(24, 24) may_exit:SetText("") may_exit:SetColor(Color(0, 255, 0)) may_exit.DoClick = function() may_frame:Close() surface.PlaySound("ambient/levels/canals/drip4.wav") end function may_exit:Paint(w, h) surface.SetDrawColor(Color(0, 255, 0)) surface.DrawOutlinedRect(0, 0, w, h) surface.DrawLine(9, 9, 15, 15) surface.DrawLine(14, 9, 9, 14) end local may_damage = may_addtab("Damage") local may_chat = may_addtab("Chat") local may_props = may_addtab("Props") may_damage:SetVisible(true) for k, v in pairs(may_damagelist) do may_addlabel(v, may_damage) end for k, v in pairs(may_chatlist) do may_addlabel(v, may_chat) end for k, v in pairs(may_proplist) do may_addlabel(v, may_props) end end) elseif SERVER then hook.Add("PlayerHurt", "may_logs_playerhurt093832", function(victim, attacker, healthremaining, damage) if attacker:IsPlayer() then table.insert(may_damagelist, os.date("%I:%M %p", os.time()) .. " " .. attacker:Name() .. " damaged " .. victim:Name() .. " for " .. damage .. ".") end end) hook.Add("PlayerSay", "may_logs_playersay09329352", function(ply, text, tm) table.insert(may_chatlist, os.date("%I:%M %p", os.time()) .. " " .. ply:Name() .. " said " .. text .. ".") end) hook.Add("PlayerSpawnProp", "may_logs_playerspawnprop920138", function(ply, model) table.insert(may_proplist, os.date("%I:%M %p", os.time()) .. " " .. ply:Name() .. " spawned a " .. model .. ".") end) end I've tried using SetGlobalString and GetGlobalString in conjunction with string.Explode, and a custom seperator to remake the table once it's sent, and it seemed to work, until I realized there was a length limit. I also tried to use net.Start and net.Receive to send the table over to the client, but it was returning nil. Perhaps something I might have done wrong ?
Do you still have the code you used for net.Start and net.Receive?
I removed it, but give me a few and I'll redo it & send.
Seems to work fine for me Note that I am using two different files rather than your combined
Sorry, you need to Log In to post a reply to this thread.