Author Topic: Send RFC on exit  (Read 2191 times)

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Send RFC on exit
« on: May 01, 2015, 03:53:48 PM »
What's the best way to send an RFC call, say a player abruptly exits?

For instance, I have a vehicle that a character enters.  I send RFCs to update the other players with the characters info (animations, positions, is the car being driven, etc).  However, if the character just turns off the game instantly, I need him to send one last RFC to everyone letting them know that the player is not in the vehicle anymore, so the vehicle can still be of use to other players.  Otherwise, the players still think the player is in the vehicle and no one can use it.

Does this make sense?

Is there a way to send out RFC if the player abruptly quits?

Rigo.cl

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 1
    • View Profile
Re: Send RFC on exit
« Reply #1 on: May 01, 2015, 05:34:41 PM »
I'm not sure if the player (client) that is being disconnected is able to say a "last goodbye", but I think that either the host or the stand-alone server could use 'case Packet.Disconnect' to check if the disconnected client was in the vehicle, if so broadcast a message saying that the vehicle is available again.

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Send RFC on exit
« Reply #2 on: May 02, 2015, 03:56:26 PM »
if you use a RCC to create your players, the player will automagically be removed when they are disconnected.  also, the "OnNetworkPlayerLeave" fires when a player leaves the channel.

alternately, you can create a server packet to inform everyone that a player has disconnected.  i use this method, due to my game requires all players to know where all other players are (all channels).

  1. //line #448~ of GameServer
  2. #if STANDALONE
  3.      if (p.id != 0) Tools.Print("[" + p.id + "] " + p.name + " has disconnected");
  4. #endif
  5.  
  6. #region Game Code
  7.  
  8. int oldchannel = 0;
  9.  
  10. if (p.channel != null)
  11. {
  12.         oldchannel = p.channel.id;
  13. }
  14.  
  15. SendLeaveChannel(p, false);//TNET CODE
  16.  
  17. long playtime = MySQL.Characters.UpdatePlayTime(p.ms_phpbbid, p.ActiveCharacter.characterid);
  18.  
  19. BinaryWriter writer = BeginSend(Packet.ResponseUpdatePlaytime);
  20. writer.Write(p.ActiveCharacter.characterid);
  21. writer.Write(playtime);
  22. EndSend(true, p);
  23.  
  24. MySQL.Characters.UpdateLastActive(p.ActiveCharacter.characterid);
  25. MySQL.Unity.UpdateLastActive(p);
  26. MySQL.Session.Logout(p);
  27.  
  28. BinaryWriter writer2 = BeginSend(Packet.ResponseDisconnectNotification);
  29. writer2.Write(p.id);
  30. writer2.Write(oldchannel);
  31. EndSend(true);
  32.  
  33. #endregion
  34.  
  35. p.Release();
  36. mPlayers.Remove(p);
  37.  
  38.  
  39.  

voncarp

  • Jr. Member
  • **
  • Thank You
  • -Given: 13
  • -Receive: 2
  • Posts: 91
    • View Profile
Re: Send RFC on exit
« Reply #3 on: May 02, 2015, 04:33:12 PM »
Thanks guys.  Those are good recommendations.  With that, I'm certain I'll be able to figure it out now.

Thanks again.