Author Topic: RFC - Sender info  (Read 3401 times)

Frooxius

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
RFC - Sender info
« on: April 02, 2015, 08:23:38 AM »
Hello!

I would like to ask if there's a way to easily get the sender info on RFC, so I know which player it came from. I have tried adding Player as the last parameter of the function (similarly how Unity Networking does it), but this doesn't seem to work.

I have searched all around, but I can't find if there's a way to do this automatically or if I have to manually send the player ID whenever sending RFC.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: RFC - Sender info
« Reply #1 on: April 02, 2015, 05:03:36 PM »
send the playerid and use TNManager.GetPlayer

assuming that the player is in the same channel.

or, as suggested in a tnet thread (and how i do it now).  when a player enters the channel broadcast a request to get all player's info and store their info in a list for reference.

the request tells everyone that you have arrived and in return you get a response from all players.

  1. [RFC]
  2. void RFC_Request_PlayerList(int playerid, int channelid, string playername, int level, int profession, int team, int guildid, string guildname, int avatar)
  3. {
  4.        
  5.         if (playername != TNManager.playerName)
  6.         {
  7.                 tno.Send("RFC_Response_PlayerList", playername, TNManager.playerID, etc, etc);
  8.         }
  9. }
  10.  

Frooxius

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: RFC - Sender info
« Reply #2 on: April 03, 2015, 03:34:07 PM »
Thanks for the reply. I was hoping I could avoid that though, since now I have to rely on each player to provide their ID accurately as a parameter, which could lead to potential errors (or abuse).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC - Sender info
« Reply #3 on: April 04, 2015, 04:19:52 AM »
tno.Send("FunctionName", player, <parameters>)

"player" is a TNet.Player.

You can also specify a Player ID instead. There is no need to use a name. Check all TNObject.Send functions available to you.