• Networking not called all time.
    12 replies, posted
My networking that updates the value clientside aren't being called properly and I just can't get it working, Serverside Player function [code] function meta:updateExperienceClientside() local lvl = self.lvl; local qxp = self.queuedXP; local xp = self.xp; net.Start("updateQueuedXPCL"); net.WriteFloat(qxp); net.Send(self); net.Start("updateXPCL"); net.WriteFloat(xp); net.Send(self); net.Start("updateLVLCL"); net.WriteInt(lvl, 32); net.Send(self); end [/code] Serverside reading code [code] local fileRead = file.Read("zaugen/experience/stats/ply_"..ply:SteamID64()..".txt", "DATA" ); local readData = util.JSONToTable(fileRead); for k,v in pairs (readData) do print(fileRead) PrintTable(readData); print("xp "..readData.xp); ply.xp = readData.xp or 0; ply.queuedXP = readData.qxp or 0; ply.lvl = readData.lvl or 1; ply:updateExperienceClientside() end [/code] It sets the Player variables but even though Player:updateExperienceClientside() is called it doesn't update the values clientside The networking works as this is used something else serverside and it works fine (all 3 network messages work) [code] net.Start("updateQueuedXPCL"); net.WriteFloat(v:getQueuedXP()); net.Send(v); [/code] Clientside [code] net.Receive("updateXPCL", function( len ) local ply = LocalPlayer(); local xp = net.ReadFloat(); ply.xp = xp; end) net.Receive("updateLVLCL", function( len ) local ply = LocalPlayer(); local lvl = net.ReadInt(32); ply.lvl = lvl; end) net.Receive("updateQueuedXPCL", function( len ) local ply = LocalPlayer(); local queuedXP = net.ReadFloat(); ply.queuedXP = queuedXP; end) [/code]
[code] util.AddNetworkString("updateMyStuff") function meta:updateExperienceClientside() net.Start("updateMyStuff") net.WriteFloat(self.queuedXP) net.WriteFloat(self.xp) net.WriteInt(self.lvl, 32) net.Send(self) print("SEND", self.queuedXP, self.xp, self.lvl) end[/code] [code] net.Receive("updateMyStuff", function() local ply = LocalPlayer() ply.queuedXP = net.ReadFloat() -- Important: read in the order you write ply.xp = net.ReadFloat() ply.lvl= net.ReadInt(32) print("RECV", ply.queuedXP, ply.xp, ply.lvl) end)[/code] Let's not waste code, shall we. This shall tell you when it is sent and when it is received.
So it prints "SEND VALUE VALUE VALUE" but doesn't print any "RECV VALUE VALUE VALUE"
[QUOTE=Klaes4Zaugen;46395570]So it prints "SEND VALUE VALUE VALUE" but doesn't print any "RECV VALUE VALUE VALUE"[/QUOTE] Make sure have the second part of code on the client properly.
Looks fine to me and I'm not getting any errors [code] net.Receive("updateEverythingCL", function() local ply = LocalPlayer() ply.queuedXP = net.ReadFloat() -- Important: read in the order you write ply.xp = net.ReadFloat() ply.lvl = net.ReadInt(32) print("RECV", ply.queuedXP, ply.xp, ply.lvl) end) [/code]
[QUOTE=Klaes4Zaugen;46395681]Looks fine to me and I'm not getting any errors [code] net.Receive("updateEverythingCL", function() local ply = LocalPlayer() ply.queuedXP = net.ReadFloat() -- Important: read in the order you write ply.xp = net.ReadFloat() ply.lvl = net.ReadInt(32) print("RECV", ply.queuedXP, ply.xp, ply.lvl) end) [/code][/QUOTE] Its not getting run. Show us the file you are putting in.
This is the file it's getting run in [code] surface.CreateFont( "experienceStatsHUDFont", { font = "Trebuchet", size = 25, weight = 3000, } ) local wMod = ScrW() / 1600 local hMod = ScrH() / 900 net.Receive("updateXPCL", function( len ) local ply = LocalPlayer(); local xp = net.ReadFloat(); ply.xp = xp; end) net.Receive("updateLVLCL", function( len ) local ply = LocalPlayer(); local lvl = net.ReadInt(32); ply.lvl = lvl; end) net.Receive("updateQueuedXPCL", function( len ) local ply = LocalPlayer(); local queuedXP = net.ReadFloat(); ply.queuedXP = queuedXP; end) net.Receive("updateEverythingCL", function() local ply = LocalPlayer() ply.queuedXP = net.ReadFloat() -- Important: read in the order you write ply.xp = net.ReadFloat() ply.lvl = net.ReadInt(32) print("RECV", ply.queuedXP, ply.xp, ply.lvl) end) hook.Add("HUDPaint", "experienceSystemOverlay", function() local ply = LocalPlayer(); local xp = ply.xp or 0; local lvl = ply.lvl or 0; local queuedXP = ply.queuedXP or 0; local nextLVL = ply:needXPToLevel(); draw.SimpleText( "LVL: "..lvl, "experienceStatsHUDFont", 925*wMod, 315*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); draw.SimpleText( "EXP: "..xp.."/"..nextLVL, "experienceStatsHUDFont", 925*wMod, 285*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); draw.SimpleText( "QXP: "..queuedXP, "experienceStatsHUDFont", 925*wMod, 245*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); end) [/code]
[QUOTE=Klaes4Zaugen;46395749]This is the file it's getting run in [code] surface.CreateFont( "experienceStatsHUDFont", { font = "Trebuchet", size = 25, weight = 3000, } ) local wMod = ScrW() / 1600 local hMod = ScrH() / 900 net.Receive("updateXPCL", function( len ) local ply = LocalPlayer(); local xp = net.ReadFloat(); ply.xp = xp; end) net.Receive("updateLVLCL", function( len ) local ply = LocalPlayer(); local lvl = net.ReadInt(32); ply.lvl = lvl; end) net.Receive("updateQueuedXPCL", function( len ) local ply = LocalPlayer(); local queuedXP = net.ReadFloat(); ply.queuedXP = queuedXP; end) net.Receive("updateEverythingCL", function() local ply = LocalPlayer() ply.queuedXP = net.ReadFloat() -- Important: read in the order you write ply.xp = net.ReadFloat() ply.lvl = net.ReadInt(32) print("RECV", ply.queuedXP, ply.xp, ply.lvl) end) hook.Add("HUDPaint", "experienceSystemOverlay", function() local ply = LocalPlayer(); local xp = ply.xp or 0; local lvl = ply.lvl or 0; local queuedXP = ply.queuedXP or 0; local nextLVL = ply:needXPToLevel(); draw.SimpleText( "LVL: "..lvl, "experienceStatsHUDFont", 925*wMod, 315*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); draw.SimpleText( "EXP: "..xp.."/"..nextLVL, "experienceStatsHUDFont", 925*wMod, 285*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); draw.SimpleText( "QXP: "..queuedXP, "experienceStatsHUDFont", 925*wMod, 245*hMod, Color(253,254,255), TEXT_ALIGN_CENTER ); end) [/code][/QUOTE] Is your HUDPaint hook working?
Yes it's working fine.
Don't fucking rename anything. I am talking about this: updateEverythingCL - It must be the same as on server - updateEverything
I know and it's the same.
Show full serverside code.
I got it working using [lua]timer.Simple(0.1, function() *send values to client* end)[/lua] inside Player:updateExperienceClientside()
Sorry, you need to Log In to post a reply to this thread.