C# cant figure out a way to send some info over network

i use C#

I cant figure out how to send info over a network, i have set up a network properly and can send chat data but i dont know how to attack somebody or “Get” somebodys name variable(string).
you cant retrieve a string through ‘stream.(ref value)’, so how can i do this?

i dont fully understand RPCs and stream.serialize, but i have assumed it possible to target another player on another client, then check their name and health variables(Bob Hp: 100)
and then if conditions were met, send an attack. by the way, yes i did read up on rpcs and serializing, and tutorials, and unity docs, no guide has an example i could use… sorry if my questions unclear, im a bit annoyed,(had this problem for several days)

RPC’s are easy, just like send message.

They are sent to networkView of specified object(somegameobject.networkView.RPC), or just use networkView for the self object.

Think of it like this, no-one knows your name, an RPC is sent with your name(from you), in the receive call, everyone else gets your name, and then the yourname string is made into the sent name variable, You call the message by,

networkView.RPC(“NameOfFunctionToCall”,RPCMode.All, DataToSend);
RPCModes are All(Sends to data to everyone) Other(to everyone but the sender), and Server(Just to server), also there are buffered calls.

To receive a call do this

void NameOfFunctionToCall(DataToSend){
//Then do something in here.
somethingtochange = DataToSend;// or equavelent.

Keep in mind RPC’s Cannot send every type of variable, but they can send unlimited amounts of a variable.

Variables that can be sent through RPC’s


Also, to sync your name, I guess you are a player gameobject, the RPC needs to be sent from you with name, and then received by appliying the local function variable as the name variable.