• Error: Trying to network (receive) unacceptable type (table)
    4 replies, posted
So I'm working on an ugly chat tag system for my server and I'm running into an issue with using net.WriteTable I think. Also DColorMixer isn't working too well for me... I'll paste the entire file below, but I'll give you the parts I think are wrong here. [lua] local rainbow = vgui.Create("DColorMixer", base) rainbow:SetSize( ScrW()/2.5, ScrH()/5) rainbow:SetPos((ScrW() - (ScrW()/10 + ScrW()/4)/2) - rainbow:GetWide(), ScrH() - 10 - ScrH()/5) rainbow:SetColor(Color(255,0,255,255)) col = rainbow:GetColor() cRed = col.r cGreen = col.g cBlue = col.b dat[1] = cRed dat[2] = cGreen dat[3] = cBlue dat[4] = tagList:GetSelectedLine() dat[5] = LocalPlayer() PrintTable(dat) local conf = vgui.Create("DButton", base) conf:SetSize(75, 20) conf:Center() conf:SetText("Confirm") conf.DoClick = function() print("Sending color and title data to server") net.Start("DataRefresh") net.WriteTable( dat ) net.SendToServer() end [/lua] [lua] function readyServer() util.AddNetworkString("DataRefresh") end hook.Add("Initialize", "Get dem network strings up", readyServer) ///client told us to change stuff so do it net.Receive( "DataRefresh", function(len) local dat = net.ReadTable() local red = dat[1] local green = dat[2] local blue = dat[3] local title = dat[4] local targ = dat[5] targ:SetPData("ColorR", red) targ:SetPData("ColorG", green) targ:SetPData("ColorB", blue) targ:SetPData("Title", title) targ:SetNWInt("NColorR", red) targ:SetNWInt("NColorG", green) targ:SetNWInt("NColorB", blue) targ:SetNWString("Title", title) targ:ChatPrint("Received update...") targ:ChatPrint("Red: "..tostring(dat[1])..", Green: "..tostring(dat[2])..", Blue: "..tostring(dat[3])..", title: "..dat[4].." ") end ) [/lua] [editline]23rd June 2014[/editline] Entire file: [lua] numTags = 5 local tagTab = {} tagTab[1] = "Indecisive" tagTab[2] = "" tagTab[3] = "" tagTab[4] = "" tagTab[5] = "Noobie" if SERVER then ///boop/// function readyServer() util.AddNetworkString("DataRefresh") end hook.Add("Initialize", "Get dem network strings up", readyServer) ///client told us to change stuff so do it net.Receive( "DataRefresh", function(len) local dat = net.ReadTable() local red = dat[1] local green = dat[2] local blue = dat[3] local title = dat[4] local targ = dat[5] targ:SetPData("ColorR", red) targ:SetPData("ColorG", green) targ:SetPData("ColorB", blue) targ:SetPData("Title", title) targ:SetNWInt("NColorR", red) targ:SetNWInt("NColorG", green) targ:SetNWInt("NColorB", blue) targ:SetNWString("Title", title) targ:ChatPrint("Received update...") targ:ChatPrint("Red: "..tostring(dat[1])..", Green: "..tostring(dat[2])..", Blue: "..tostring(dat[3])..", title: "..dat[4].." ") end ) function initColors( ply ) if ply:GetPData("ColorR") == nil then ply:ChatPrint("Welcome to the server! Initializing some stuff for you...") ///Color( 200, 50, 50 ) default colors ply:SetPData("ColorR", 200 ) //remember Luaderp stores these as strings because yolo ply:SetPData("ColorG", 50 ) ply:SetPData("ColorB", 50 ) end end hook.Add("PlayerInitialSpawn", "First time joining", initColors) function initTags( ply ) if ply:GetPData("HasJoined") != "true" then ply:SetPData("HasJoined", "true") for i = 1,numTags do ply:SetPData("OwnsTag"..i.."", 0) end ply:SetPData("OwnsTag5", 1) end end hook.Add("PlayerInitialSpawn", "First time joining2", initTags) function loadTitle( ply ) if not ply:GetPData("Title") == nil then ply:SetNWString("Title", ply:GetPData("Title")) end end hook.Add("PlayerSpawn", "reload selected title", loadTitle) function loadColors( ply ) ply:SetNWInt("NColorR", tonumber(ply:GetPData("ColorR"))) ply:SetNWInt("NColorG", tonumber(ply:GetPData("ColorG"))) ply:SetNWInt("NColorB", tonumber(ply:GetPData("ColorB"))) end hook.Add("PlayerSpawn", "Refresh the rainbow", loadColors) function loadTags( ply ) //force Noobie to load if it didn't if ply:GetPData("OwnsTag5") == nil then ply:SetPData("OwnsTag5", 1) ply:ChatPrint("Have the <Noobie> chat tag for free!") end for i = 1,numTags do ply:SetNWInt("OwnsTag"..i.."", tonumber(ply:GetPData("OwnsTag"..i..""))) end end hook.Add("PlayerSpawn", "Restore our loaded tags here", loadTags) function openSelect( ply, text, public) if string.upper(string.sub(text, 1,4)) == "!TAG" then //debug code /*if ply:GetPData("NumOfOpens") then ply:ChatPrint(ply:GetPData("NumOfOpens")) end*/ umsg.Start("OpenMenu", ply) umsg.End() if (ply:GetPData("NumOfOpens") == nil) or (ply:GetPData("NumOfOpens") == 0) or (ply:GetPData("NumOfOpens") == "") then ply:SetPData("NumOfOpens", 1) else ply:SetPData("NumOfOpens", tonumber(ply:GetPData("NumOfOpens")) + 1) end if tonumber(ply:GetPData("NumOfOpens")) > 4 and ply:GetPData("OwnsTag1") != "1" then ply:SetPData("OwnsTag1", 1) ply:ChatPrint("You have earned the <Indecisive> tag for opening chat tag selection 5 times!") end end end hook.Add("PlayerSay", "Open the tag selection menu", openSelect) end if CLIENT then dat = {} function refreshData() end function chatting( ply, strText, bTeamOnly, bPlayerIsDead ) red = ply:GetNWInt("NColorR") blue = ply:GetNWInt("NColorG") green = ply:GetNWInt("NColorB") -- I've made this all look more complicated than it is. Here's the easy version -- chat.AddText( ply:GetName(), Color( 255, 255, 255 ), ": ", strText ) local tab = {} if ( bPlayerIsDead ) then table.insert( tab, Color( 255, 30, 40 ) ) table.insert( tab, "*DEAD* " ) end if ( bTeamOnly ) then table.insert( tab, Color( 30, 160, 40 ) ) table.insert( tab, "(TEAM) " ) end if ( IsValid( ply ) ) then if ply:GetNWString("Title") != "" then title = ply:GetNWString("Title") else title = "Noobie" end table.insert( tab, Color( red, green, blue ) ) table.insert( tab, " <"..title.."> " ) table.insert( tab, Color( 144, 33, 208 ) ) table.insert( tab, ply:GetName() ) else table.insert( tab, "Console" ) end table.insert( tab, Color( 255, 255, 255 ) ) table.insert( tab, ": "..strText ) chat.AddText( unpack(tab) ) return true end hook.Add("OnPlayerChat", "boop", chatting) function theMenu( um ) LocalPlayer():ChatPrint( tostring( LocalPlayer():GetNWInt("OwnsTag1") ) ) //local copiedTags = table.Copy(tagTab) local copiedTags = {} for i = 1,numTags do if tonumber(LocalPlayer():GetNWInt("OwnsTag"..i.."")) == 1 then table.insert(copiedTags, tagTab[i]) LocalPlayer():ChatPrint("Adding tag "..tagTab[i].."!") end end table.sort(copiedTags) local base = vgui.Create("DFrame") base:SetSize( ScrW(), ScrH() ) base:SetPos( 0, 0) base:SetTitle("Tag Selection") base:SetVisible( true ) base:SetDraggable( false ) base:ShowCloseButton( true ) base:MakePopup() local tagList = vgui.Create("DListView", base) tagList:SetPos(ScrW()/10, ScrH()/10) tagList:SetSize(ScrW()/4, ScrH() - ScrH()/5) tagList:SetMultiSelect(false)//what does this even do? lol tagList:AddColumn("Title") for k,v in pairs(copiedTags) do tagList:AddLine(v) end local rainbow = vgui.Create("DColorMixer", base) rainbow:SetSize( ScrW()/2.5, ScrH()/5) rainbow:SetPos((ScrW() - (ScrW()/10 + ScrW()/4)/2) - rainbow:GetWide(), ScrH() - 10 - ScrH()/5) rainbow:SetColor(Color(255,0,255,255)) col = rainbow:GetColor() cRed = col.r cGreen = col.g cBlue = col.b dat[1] = cRed dat[2] = cGreen dat[3] = cBlue dat[4] = tagList:GetSelectedLine() dat[5] = LocalPlayer() PrintTable(dat) local conf = vgui.Create("DButton", base) conf:SetSize(75, 20) conf:Center() conf:SetText("Confirm") conf.DoClick = function() print("Sending color and title data to server") net.Start("DataRefresh") net.WriteTable( dat ) net.SendToSe
What's the error or problem you're having?
"Error: Trying to network (receive) unacceptable type (table)" is the error I'm being given. It appears it doesn't want to send the table from Client to Server? Also I'm not sure if DColorMixer:GetColor().r .b .g are working properly x.x
do dat.cRed and shit rather than [1] and tell me if the error continues to happen
That seems to have solved me previous error zero. Now all that seems to be wrong is that rainbow:GetColor() does not seem to actually return the real color. In fact, when I try to print rainbow:GetColor() in console it won't print anything. Printing rainbow:GetColor().r will print 255, no matter what the live preview says the red value is set to.
Sorry, you need to Log In to post a reply to this thread.