Team Spartan Cookies & Milk Forums
Find by Class - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Find by Class (/thread-3757.html)



Find by Class - 4N0NYM - 30-04-2022

So i encountered a very interesting thing:

If someone spawns a Ship Core on another Galaxy (i.e. i am in Universe space and someone spawns a Ship Core on Shakuras) and you track it via Server find.byClass and then net broadcast it to Client it gets turned into a NULL Entity

--@shared 

if SERVER then
    timer.create("U",2,0,function()
        SC  = find.byClass("ship_core")
        for i=1,#SC do
            printConsole(SC[i],"Server")
        end
        net.start()
        net.writeTable(SC)
        net.broadcast()
    end)
else
    hook("net","net",function()
        Table = net.readTable()
        for i=1,#Table do
            printConsole(Table[i],"Client")
        end
    end)
end


Output : 

Entity [533][ship_core] Server
Entity [764][ship_core] Server

Entity [533][ship_core] Client
[NULL ENTITY] Client


RE: Find by Class - 57e11a - 01-05-2022

Well, it makes sense, considering entities out of area aren't guaranteed to exist on the client.


RE: Find by Class - 4N0NYM - 01-05-2022

But i transfer them from the Server to the Client, so it should still work. If I searched them via Client it would make sense, but I am searching them on the Server side and then sending them to the Client.


RE: Find by Class - Person8880 - 01-05-2022

You're sending the entity ID which the client uses to lookup the entity. If the entity hasn't been seen by the client then it'll be null.

This is expected behaviour, you can't force an entity to be networked when it's not visible to the client in Starfall for obvious reasons.