I created an entity, and part of this entity relies on the "should collide" hook.
I've stored a table on the entity containing info, and I'd like to be able to access that table clientside in order to make the hook run properly. Is that possible?
Use the net library to transfer any data between serverside and clientside: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
Is there maybe a way to make the table stored on my entity shared, rather than having to network it?
[QUOTE=Z0mb1n3;46928842]Is there maybe a way to make the table stored on my entity shared, rather than having to network it?[/QUOTE]
That's not how gamestates work.
The only way to have a shared 'table' is to replicate the data exactly using networking. However, this method is barbaric and would cause greater issues down the road.
[QUOTE=vexx21322;46928962]That's not how gamestates work.
The only way to have a shared 'table' is to replicate the data exactly using networking. However, this method is barbaric and would cause greater issues down the road.[/QUOTE]
Okay, so then it will not be possible for me to allow a client to read the table as he pleases? The reason I need it is because the entity's table is constantly changing, and the clientside version of the "ShouldCollide" hook that I have depends on knowing if the player is on a sort of whitelist stored on the entity.
If you use data tables it will sync it up both client server and client side. The value will be the same on both but if someone tries to change the variable client side it will only change for that client. This means players won't have access to change that servers variables and won't be able to screw up your server.
[url]http://wiki.garrysmod.com/page/Entity/NetworkVar[/url]
[QUOTE=Z0mb1n3;46931368]Okay, so then it will not be possible for me to allow a client to read the table as he pleases? The reason I need it is because the entity's table is constantly changing, and the clientside version of the "ShouldCollide" hook that I have depends on knowing if the player is on a sort of whitelist stored on the entity.[/QUOTE]
It sounds like what you would want to do is send the entity whenever you want to add or remove from the whitelist.
On the client side, cache the entity in a table and iterate the table in ShouldCollide.
Be careful with ShouldCollide, though. That hook is a bit fiddly and will cause VPhysics to go awry if used wrong.
[QUOTE=vexx21322;46931441]It sounds like what you would want to do is send the entity whenever you want to add or remove from the whitelist.
On the client side, cache the entity in a table and iterate the table in ShouldCollide.
Be careful with ShouldCollide, though. That hook is a bit fiddly and will cause VPhysics to go awry if used wrong.[/QUOTE]
Do you mean send the entity I'm whitelisting or send the entire entity itself?
EDIT:
I tried networking the actual entity itself through ENT:SetupDataTables(), and then doing
[CODE]self:NetworkVar("Entity", self, "Ent")[/CODE]
yet that still can't be accessed from the client.
EDIT2: I experimented with what you said, vexx, and it worked perfectly. Thank you guys so much!
It depends on the table of data. If you set up the table and it is the same for every ent that uses that base, then keep it shared.
If it changes data, you could always update the client when something changes.
Sorry, you need to Log In to post a reply to this thread.