• Can anyone explain how this is nil?
    4 replies, posted
The code below is client-side code, and is in a net.Receive() that is called when the player initially spawns. It's erroring on the 'ply.frost.achievs' line saying field 'frost' is nil. I'm confused as it shouldn't be nil as the if statement before it ensures it isn't nil. Can anybody help? :pwn: [CODE]local ply = LocalPlayer(); local tbl = net.ReadTable(); if not tbl then return end if not ply.frost then ply.frost = {} end ply.frost.achievs = tbl; [/CODE]
Remove the if not ply.frost and the end.
[QUOTE=KarmaLord;41131913]Remove the if not ply.frost and the end.[/QUOTE] That would then defeat the purpose of the frost table as it would be reset every time I sync achievements...
[QUOTE=zeoed;41132204]That would then defeat the purpose of the frost table as it would be reset every time I sync achievements...[/QUOTE] I would rather remove them and change ply.frost = {} to ply.frost = ply.frost or {} Edit: Send the net messages few seconds later or after the client's InitPostEntity is done. That may fix it.
[QUOTE=Leystryku;41132444]I would rather remove them and change ply.frost = {} to ply.frost = ply.frost or {} Edit: Send the net messages few seconds later or after the client's InitPostEntity is done. That may fix it.[/QUOTE] Doing both of your suggestions fixed it. Thanks!
Sorry, you need to Log In to post a reply to this thread.