Skip to content

Commit

Permalink
fix: sometimes we have nil values.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshPiper committed Jan 14, 2025
1 parent a7db0c1 commit 115b3f6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lua/autorun/photon/shared/sh_simplenet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ if SERVER then
net.WriteEntity(ent)
for _, datum in ipairs(NET.FMap) do
PrintTable(datum)
NET.WriteFunctions[datum[2]](ent["Get" .. NET.Normalise(datum[1])](ent), datum[3])
local v = ent[NET.Normalise(datum[1])]
if v == nil then
net.WriteBool(false)
else
net.WriteBool(true)
NET.WriteFunctions[datum[2]](v, datum[3])
end

end
net.Send(ply)
end)
Expand All @@ -162,7 +169,9 @@ if CLIENT then
net.Receive("Photon_SimpleNet_Sync", function(len, ply)
local ent = net.ReadEntity()
for _, datum in ipairs(NET.FMap) do
ent[NET.Normalise(datum[1])] = NET.ReadFunctions[datum[2]](datum[3])
if net.ReadBool() then
ent[NET.Normalise(datum[1])] = NET.ReadFunctions[datum[2]](datum[3])
end
end
end)

Expand Down

0 comments on commit 115b3f6

Please sign in to comment.