I need to send some data from the server to the client in a efficent way. The way im having right now is putting global variables on a entity i spawn at server start. I then get those variables at the client code. I have found this is very unefficent and bad but i really dont know any else way.
To the top of the cake, i need to color code it in a special way otherwise it gives me crappy errors that i cant remember:
server code:
client code:Code:function Init_TriggerLogic() Failent = ents.Create("prop_physics") Failent:SetModel("models/props_junk/PopCan01a.mdl") Failent:SetColor(143,210,85,123) Failent:SetPos(Vector(0,0,0)) Failent:SetName("John") Failent:Spawn() timer.Create("taim bitch",1,1,function() Names = file.Read("Teleportlist/Names/"..game.GetMap()..".txt") Positions = file.Read("Teleportlist/Positions/"..game.GetMap()..".txt") Owners = file.Read("Teleportlist/Owners/"..game.GetMap()..".txt") Failent:SetNWString("Globalnames",Names) Failent:SetNWString("Globalpositions",Positions) Failent:SetNWString("Globalowners",Owners) end) end hook.Add( "InitPostEntity", "MapStartTrigger", Init_TriggerLogic )
If you dident notice, im trying to transfer data from files at the server to every client. Sorry for the bad variable names, i cant really find anything better.Code:-- Lots of shit just to find that goddamn can -.- Failenttbl = ents.FindByClass("prop_physics") if Failent == nil then for k, v in pairs( Failenttbl ) do local r,g,b,a = v:GetColor() local str=""..r..g..b..a if str=="14321085123" then Failent = v break end end end -- End FakeGlobalnames = Failent:GetNWString("Globalnames") FakeGlobalpositions = Failent:GetNWString("Globalpositions") FakeGlobalowners = Failent:GetNWString("Globalowners")
Just to say, this works perfectly, but its very unefficent.


LinkBack URL
About LinkBacks




Reply With Quote








Bookmarks