• Sending a table to a entity.
    2 replies, posted
How would you go about sending a table to a entity to be used on ent:Use?
If you give us the context maybe we can offer a better solution. If you want the client to receive something when the client presses use on an NPC then you could just net.WriteTable and send it to the client. Although, if information is used by client and server then you could easily keep the table in a shared file then pass the key to the client ( or from client to server... never trust client data, always check on the server so with a shared table the client will be able to grab the key, send it to the server [ in the event a client buys something ] and the server can handle whats next )... Here's an example where an NPC has a use function, on use sends a flag to the client, the client opens vgui and can close the vgui or click another button. The other button sends a message to the server, and the server sets the team.. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_zipped_code/acecool_npc_jointeam_example.rar[/url]
[URL="http://wiki.garrysmod.com/page/Category:net"]Net Library Link[/URL] If you use the functions in the net libary you can send net messages to the player. [URL="http://wiki.garrysmod.com/page/net/WriteTable"]writeTable[/URL] is what you would use in the message to add it to it, while on the client side you would use the [URL="http://wiki.garrysmod.com/page/net/ReadTable"]ReadTable[/URL] to pull the data client side. You could also use user messages also which is a tad different since you can not directly place a table. If you look around net messages should have a decent amount of documention on how to use them and they are simply easy to use.
Sorry, you need to Log In to post a reply to this thread.