Game Development Community

How to send data in C++ to 1 client only (in player class by example)?

by elvince · in Torque 3D Professional · 09/01/2010 (7:40 am) · 3 replies

Hi,

My goal: Add some attribute to a player in Player Class and network them. Those attributes must be networked only to the onwer on the player (means 1 player and not all).

So I can't use the current pack/unpack function as those will send information to the connection scope.

I know I can do it via script with CommandToClient function. But in my opinion, use a script function to read, send, write those C++ information are not the correct way of sending those kind of information via the network. I mean, adding the script engine layer, it's just adding "cpu time" for nothing.

I start looking in the forum, and it seems the solution is to built a netevent.

When I'm looking the structure of this, I need to derived from NetEvent, implement the constructor, pack/unpack & process function
I need to create a function in Player Class to post the net event.

Is it the right approach?
How in process of the netevent (client side in my case), I can hook back to the player class and set my different attributes?
Do I need to send the object ID, so I can find the ghost one on the client side?

Thanks,

#1
09/01/2010 (12:19 pm)
Hi Elvine,

yes that´s possible, I coded a NetEvent derived class for that. There you can put data as you want. For detection you have to send the ghost id as well, which is resolved on the client.
In pack/write you put all writing stuff and in unpack/process you have to resolve back your datas. All mentioned functions are virtual. Just have a look for a netEvent derived class, it will essentially help you!
#2
09/01/2010 (6:53 pm)
Thanks I will look into that deeply^^
#3
09/01/2010 (8:17 pm)
No problem! If you need further assistance, just give a short note!