Send data from a table from server to client?

So currently I have a couple tables that need to be defined serverside because they set prices/amounts for buying in game items.
I have the tables created on the shared file. On the client, the tables are looped through and then the information is displayed in a DList. This works, however aren’t clients able to somehow change the prices through clientside scripts/injecting things if the var’s are also defined clientside as well as serverside( in a shared file )?
I might just be paranoid but it’s better to be safe then sorry.

If it’s not clear, my question is how would I send each table to the client and then loop through it?
Is net.WriteTable a valid option?

[editline]24th February 2016[/editline]

Solved. I simply used net.WriteTable to send the table to the client from the server.

Even if they could inject a clientside lua script that would edit the table and change prices and what not, it wouldn’t matter because the prices are all subtracted on the server.

Or are you sending the price from client to server when a purchase is made?

Shared file or not, they still may be able to inject lua code and change the prices even after you transfer the data with a net message and save it in some table to use later.

[editline]25th February 2016[/editline]

Make sure you account for tables that too large to be send in one net message!

How would I do that? All of my tables are only 8 keys in size.

Also, I’m sending the whole table for the specific weapon they selected (this)


addWeapon[1] = {
	name = "CZ-75",
	model = "models/weapons/w_dber_czechcz75.mdl",
	class = "cw_ber_cz75",
	price = 10,
	amount = 1,
	allowed = { TEAM_CITIZEN },
	category = "Pistols",
	license = 1
}

How would I check to see if it’s all the right info? Do I just compare the strings/numbers sent from the client to the ones defined serverside? It seems to me that it would dumb to do it that way, but I can’t think of any other way.

Look how the save system does it.

I solved it by sending the key from the table of the gun they wanted to buy. This way even if they inject some other data other than a legitimate number, or if that key/weapon table doesn’t exist, it doesn’t do anything. They also can’t change the price, amount or anything, because no matter what key they input, it will always use the data defined on the server. I hope I didn’t sound like an idiot trying to describe what I did to fix it…