Author Topic: GetPlayer  (Read 4280 times)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
GetPlayer
« on: January 17, 2015, 06:51:11 AM »
it appears that GetPlayer is bound by the players that are within the same channel?

  1. Player player = TNManager.GetPlayer(playerid);
  2.  

how do i "GetPlayer" of a playerid that is in another channel?  i can think of a solution from the server-side -- but id prefer not.

im getting a null from a valid playerid...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GetPlayer
« Reply #1 on: January 18, 2015, 04:31:21 AM »
You can't retrieve players that aren't in the same channel as you. If you are trying to send a private message, do it by their player name instead.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: GetPlayer
« Reply #2 on: January 18, 2015, 02:07:07 PM »
i have a central location chat where a player can see all matches that are going on and the status of each match.

can you retrieve player data via a private message?  if so, is there an example of this somewhere?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GetPlayer
« Reply #3 on: January 19, 2015, 11:55:00 AM »
Send a private message same way you'd send any other packet. The only difference is that instead of specifying a target you'd specify a player name. The rest is the same. It's just an RFC like any other.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: GetPlayer
« Reply #4 on: January 19, 2015, 07:06:16 PM »
Send a private message same way you'd send any other packet. The only difference is that instead of specifying a target you'd specify a player name. The rest is the same. It's just an RFC like any other.

just to be clear:  you can send a private message to someone who is in a different channel?  i'd assume yes.  however, my understanding of the process is not working.

the player in the remote channel is not receiving the RFC.

  1.     public string RemotePlayerName = "";
  2.  
  3.     public void OnClick_TestRFC()
  4.     {
  5.         Debug.Log("OnClick_TestRFC");
  6.  
  7.         tno.Send("RFCRequestData", RemotePlayerName, TNManager.playerName);
  8.     }
  9.  
  10.     //GUI textList for debugging
  11.     void ClientDEBUG(string msg)
  12.     {
  13.         textList.Add(string.Format("[00ff00][Client]: [ffffff]{0}", msg));
  14.     }
  15.  
  16.  
  17.  
  18.  
  19.     [RFC]
  20.     void RFCRequestData(string reponseName)
  21.     {
  22.         int level = TNManager.playerDataNode.GetChild<int>("Level");
  23.         int prof = TNManager.playerDataNode.GetChild<int>("Profession");
  24.         string profabbr = GetAbbrProfession(prof);
  25.  
  26.         ClientDEBUG(string.Format("RFCRequestData reponseName={0}", reponseName));
  27.  
  28.         tno.Send("RFCResponseData", reponseName, TNManager.playerID, level, prof, profabbr);
  29.     }
  30.  
  31.     [RFC]
  32.     void RFCResponseData(int playerid, int level, int prof, string profession)
  33.     {
  34.         ClientDEBUG(string.Format("RFCResponseData playerid={0} level={1}", playerid, level));
  35.     }
  36.  
  37.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GetPlayer
« Reply #5 on: January 20, 2015, 10:35:29 PM »
Yes, you can. Both players must have an object with the RFC present for this to work.

This is generally achieved by having a DontDestroyOnLoad() static game object with a TNObject that has a fixed ID (not instantiated via TNManager).

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: GetPlayer
« Reply #6 on: January 21, 2015, 05:34:21 AM »
Yes, you can. Both players must have an object with the RFC present for this to work.

This is generally achieved by having a DontDestroyOnLoad() static game object with a TNObject that has a fixed ID (not instantiated via TNManager).

i have 5 scenes that are their own channels - all with a TNObject component attached to an empty game object.  i have one TNManager that follows along from scene to scene with the player. all TNObject component's have a unique ID.  1-5.  the two channels that are talking to each other both have identical RFC method's as shown in the post above.

i'm happy that i understand the process.  ideas on why they are not communicating?  should i only be using one TNObject for all scene's?  my setup fits the criteria without using DontDestroyOnLoad().

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: GetPlayer
« Reply #7 on: January 22, 2015, 01:14:01 PM »
When a message is sent, it's sent to a TNObject. If both scene's objects have the same exact IDs, it'll work fine. But if scene A has that script on object with ID of 1, and another with ID of 2, it won't work.

In any case, I suggest making it travel from scene to scene along with your TNManager. You can just make it a child of that object. Keep in mind though, TNManager's presence is not required from the start.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: GetPlayer
« Reply #8 on: January 22, 2015, 11:58:29 PM »
Fixed!

appreciate your patience and support.  thanks!