Table screwed up after sending from server-side to client-side

Hey,
So basically I’m trying to send a table from server-side to client-side with the net library
[lua] net.WriteTable(table) [/lua]

Everything seems to be fine, until I send it, then the table on client-side pretty much screwed up :
For example I have a table called “blah” with some fields in the following example:
[lua]
local blah = {}

blah.name = "test"
blah.id = 1
blah.description = "test description"

blah.tableInaTable= {}
blah.tableInaTable[0] = "asdasdasd"
blah.tableInaTable[1] = "mnsdfsdf"

[/lua]

Above is the table on server-side, before I send it.

Now this is the table on the client-side after I send it :
[lua]
blah.name = blah.id
1 = “test”
blah.description = blah.tableInaTable[0]
“asdasdasd” = “test description”
blah.tableInaTable[1] = “mnsdfsdf”
[/lua]

So after the sending the table pretty much messes and screwed up for some reason.
Any ideas?

(Note : That’s not actually the table I’m using, this was used to show an example and an easy explanation of my issue)

I have an automated system where I send some pretty complex tables for some of my data; show your code. Something isn’t right on your end.

That’s server-side

[lua]
net.Start(“QNPC_OpenMenu”)
net.WriteTable(KQNPCS.JonnyQuests)
net.Send(Caller)
[/lua]

That’s client-side
[lua]
local Tag = “QNPC”

local function MissionPackage(ply)
    local localTable = net.ReadTable()
    print(table.ToString(localTable))
end
net.Receive( Tag.. "_OpenMenu", MissionPackage)

[/lua]

Do a PrintTable on the output.

Did :
That’s on server-side before the sending:



		id	=	1
		Accept	=	function: 0x258549d0
		target	=	kqnpc_kyle
		description	=	Hello There! I have been watching those streets for a 
very long time, I don't even have time to go visit my
friend Kyle, I neecant! 

Would you be a good citizen and go deliver him this 
package?

That would be really nice of you...
		npc	=	kqnpc_jonny
		objectives	=	Clean the streets from the junk.
		messages:
				1	=		
Hey there... I see you got there Jonny's package, 
I've been waiting for it for a very long, finally!
What took so long?
Anyw to me. You can now go back to Jonny
and tell him I got it. Thanks!.
				2	=	Did you give Kyle my package? Aha.... I see,
Thank you so much for doing that, I greatly appreciate
your help, here's your rewa		name	=	Jonny's Package
		reward	=	1,500$ dollars


That’s on client-side after the sending:



		1	=	npc
		kqnpc_kyle	=	reward
		kqnpc_jonny	=	objectives
		Accept	=	target
		Jonny's Package	=	description
		Clean the streets from the junk.	=	name
		1,500$ dollars	=	id

reward


Ah, you’re trying to send functions in a table. You can’t do that. Make sure the table is fully parsed with content before sending it.

Try removing function values.

To add to what Acecool is saying:

How can the client possibly know what function it is and how it’s called from just the pointer that exists on the server?

Alright, thanks. Is there any alternate way to send it then?

You can send the function as text, parse it on the client, then run it. But why can’t you grab the value and then send that? Does it need to be a function?

Alright thanks, would you mind to tell me how to send a function as a text?(I need to send it as a function)

You should never have to send a function. If you explain what you are trying to do then someone may be able to help you remove this requirement.

Well I’m pretty much trying to make an NPC quest/missions system, and for each mission I have a table, for each mission I need a function that will pretty much do what it needs for each function on events like accept the mission, turn in, progress etc. So to make the code efficient and easy I’m just trying to send the table with the values and functions to clientside, so it can be based on a gui with the selection of the missions (the functions that I’m trying to send will use the net library to send actions to the server from the client). That’s why I need to send a function.

You should revisit this entire system. Make the functions server-side for accepting mission, assigning missions, etc etc.

Server should manage the data and available quests, those can be IDs and possible some simple instructions but set up shared enums.

QUEST_TYPE_RETRIEVE = 1
QUEST_TYPE_DELIVER = 2
QUEST_TYPE_KILL = 3
QUEST_TYPE_DESTROY = 4

You’ll probably need a target point, or entity, use EntIndex if it’s an entity, vector or table of vectors for points.

Sending functions each time for a quest is inefficient. I’d recommend making the client be a viewer, and the server manage the data. Simple instructions should be sent to the client to interpret.

Alright, Thanks.