Server to a Specific client (RPC). Need help!

I want to respond from the server back to a specific client. How do I do this? And what does OtherBuffered mean?

Thanks! Tell me if you need some code…

instead of the mode you can just put the networkplayer object.
networkView.RPC(“Function”, remotenetworkplayerobject, whatyouneedtosend);

What is a remote network player object? How do I use it?

It’s a variable name appels made up, because any network aware object in the current game instance that is not owned by the local player must be a remote version of someone else’s.

Can you put it in code so I can understand how to write it up?

Never got it! :slight_smile:
I have to basicly create a new parameter called NetworkPlayer player and then when I call the RPC I pass say “Network.player”. Then in my server code instead of putting “RPCMode.others” I put player (NetworkPlayer)! Works great!!

It’s just a way to reference each player in the scene so you can easily do stuff
Networking is fun :slight_smile:

Ye :slight_smile:

When I try this

networkView.RPC(“WantsRoomsAvalible”, RPCMode.Others, networkView.owner);

And then under WantsRoomsAvalible write the following

void WantsRoomsAvalible(NetworkPlayer hisId, NetworkMessageInfo info)
{

ReciveNewMessage("Sent my Game lobby Info Got my request from: “+info.sender+” his ip " + hisId.externalIP);
networkView.RPC(“AddGameLobby”, hisId, networkView.owner, m_GameLobby.m_ShowName, m_GameLobby.m_RoomParticipants, m_GameLobby.m_RoomNumber);

}
// the ReciveNewMessage prints out 0 for info.sender and 0 for hisId.externalIP

Further more under AddGameLobby
I got the following

void AddGameLobby(NetworkPlayer owner, string ownerName, int numberOfParticipants, int roomNumber,NetworkMessageInfo info)
{
ReciveNewMessage("Recived gamelobby info from " + info.sender + " with ip " + owner.externalIP);

And this message is typed out on the server only ???. I only have two comps to try on so I use server + client on one and other client on comp 2

The info.sednder varies depending on who created the room which should be correct. but the owner.extrenalIP = servers ip. Even if I put 2 clients on one comp and server on other the result is the same

Client who made the room sends 0 on both and server somehow gets the AddGameLobby and prints out his own ip. but different info.senders depending on which client.

The point is that client who made the room should tell the client who is asking for roominfo about himself. So aAddNewRoom should end up at a client that dosn’t own a room. (yes there is some code missing on WantsRoomsAvalible that checks if the client reciving the msg is a room owner).

if I replace networkView.owner as input with Network.player I get the client with the room saying he got the request form himself but no client or server typing out the AddGameLobby message.

My goal is to be able to save ways of contacting other clients in an array. Senario
Client 1 decides to open a room, Client 2 gets a responce that client 1 opend room and enters this one so they can chat. Then client 4 decides to join the room too and should be added in the array of reciverss for the text messages. While client 3 who creates his own room should not.(will later spin out to lokal games in the rooms and what not.)

But for somereason I only succed to save the NetworkPlayer info on the server. And the clients seem unable to talk to eachother if not using RPCMode

I use something similare for server to reply to individual clients. say when client 1 tries to log in. The code is similare I send in Network.player and the client will the later get a reply if it was ok log in or failed. And that works great. Also when I tried to save the NetworkPlayers in an array on the server it works terrific. I can print out each individual ip that I saved in the array and all that. And RPC calls work nice. But somehow if I try to send info from this array 1 client at the time to a new client they end up wiht 0 saved on their end …

Well for one, if you wanted to send an RPC directly to a client, you wouldn’t use an RPCMode, you would put the NetworkPlayer of the target player in place of the RPCMode.

Second, any client will always perceive the info.sender as the server, because every message is routed through the host. Only the server is actually aware of what NetworkPlayer owns what object, from all clients perspective it will say the host owns everything. In order for clients to being able to send an RPC directly to another client’s prefab, you have to set up a scheme when the player prefabs are network instantiated that the server tells everyone what NetworkPlayer owns what objects, so everyone has an updated list.

So the simple answere is that I need to change my logic and rout everything through the “Server” instead of keeping most data traffik between clients. :slight_smile: ty for the answere. it explaines why stuff went south there.