Skip to content

Commit

Permalink
feat: Only sync vars once?
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshPiper committed Jan 14, 2025
1 parent 115b3f6 commit 2671a25
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/autorun/photon/shared/sh_simplenet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,21 @@ if CLIENT then
ent[NET.Normalise(datum[1])] = NET.ReadFunctions[datum[2]](datum[3])
end
end
ent.HasBeenPhotonSimpleNetted = true
end)

net.Receive("Photon_SimpleNet_Change", function(len, ply)
local ent = net.ReadEntity()
local idx = net.ReadUInt(NET.Bits)
if not IsValid(ent) then
return PhotonWarning("Invalid Entity given in Photon_SimpleNet_Change")
end
local name, netType, extra = unpack(NET.FMap[idx])
ent[NET.Normalise(name)] = NET.ReadFunctions[netType](extra)
end)

hook.Add("NotifyShouldTransmit", "EMVU.Net.NotifyShouldTransmit", function(ent, shouldTransmit)
if shouldTransmit and ent.IsEMV and ent:IsEMV() then
if shouldTransmit and ent.IsEMV and ent:IsEMV() and not ent.HasBeenPhotonSimpleNetted then
net.Start("Photon_SimpleNet_Sync")
net.WriteEntity(ent)
net.SendToServer()
Expand Down

0 comments on commit 2671a25

Please sign in to comment.