• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • PlayerEntry.IsOnline

    Discussion in 'Archives' started by araklisk, May 2, 2014.

    1. araklisk

      araklisk New Member

      Joined:
      Apr 4, 2014
      Messages:
      47
      Likes Received:
      0
      Trophy Points:
      0
      I sent this as a PM to pushedx but maybe someone else is able to assist me since I know the beta updates are probably keeping them busy.

      Trying to make an auto invite plugin atm and running into a snag where it still spams the invite even if the person isn't online.

      This is the relevant code that, as far as I can see, should be checking that the person is currently online.

      Code:
      //Credits to xtenshisanx for party check and wrapper        
      	private PartyMember memberWrapper
              {
                  get
                  {
                      return LokiPoe.InstanceInfo.PartyMembers.Where(o => o.PlayerEntry.Name.Equals(nameToInvite)).FirstOrDefault();
                  }
              }
      
      
              public Boolean IsInParty
              {
                  get
                  {
                      if (memberWrapper != null && memberWrapper.PlayerEntry.IsOnline)
                      {
                          return true;
                      }
                      else
                      {
                          return false;
                      }
                  }
              }
      
      
      
      from that I simply have a check for if (IsInParty) then send invite and otherwise print out debug message on screen.

      Any thoughts as to what I'm missing? It's basically the same code xtenshisanx uses for Exiledfollower, but theirs has no check whether the person is online as they are just accepting an invite.
       
    2. pushedx

      pushedx Moderator Moderator Buddy Core Dev

      Joined:
      Sep 24, 2013
      Messages:
      4,252
      Likes Received:
      290
      Trophy Points:
      83
      Meant to reply to your PM, but I forgot. I'll check into this right now.
       
    3. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      some code that pushedx gave me a while back

      Code:
      private string _masterCharacter = "CHANGE_THIS_TO_LEADER_NAME";
      
       Log.DebugFormat("[Main] We need to join a party.");
      
                              found = false;
                              foreach (var invite in LokiPoe.InstanceInfo.PendingPartyInvites)
                              {
                                  var owner = invite.PartyMembers.First(m => m.MemberStatus == PartyStatus.PartyLeader)
                                      .PlayerEntry.Name;
                                  if (owner == _masterCharacter)
                                  {
                                      Log.DebugFormat("[Main] We have a pending party invite from the master account. Accepting it.");
      
                                      invite.Accept();
      
                                      found = true;
      
                                      yield return LokiCoroutine.Sleep(1000);
      
                                      break;
                                  }
                              }
      
                              if (found)
                                  continue;
      
                              Log.DebugFormat("[Main] We do not have a pending party invite from the master account. Waiting a little before we check again.");
      
                              yield return LokiCoroutine.Sleep(5000);
       
    4. pushedx

      pushedx Moderator Moderator Buddy Core Dev

      Joined:
      Sep 24, 2013
      Messages:
      4,252
      Likes Received:
      290
      Trophy Points:
      83
      Just ran the following code:
      Code:
                      foreach (var pm in LokiPoe.InstanceInfo.PartyMembers)
                      {
                          Log.DebugFormat("Name: {0} | IsOnline: {1}", pm.PlayerEntry.Name, pm.PlayerEntry.IsOnline);
                      }
      
      It looks working still, so the logic you are trying to implement is probably incorrect with how the game works.

      In PoE, when you invite someone to your party, they are placed in your party, but in a pending state. If you see a character in your party, then they have to be online.

      You probably want to check your friends list to know if a character is online instead.
      Code:
              bool IsFriendOnline(string name)
              {
                  var f = LokiPoe.InstanceInfo.FriendList.FirstOrDefault(pe => pe.Name == name);
                  if (f == null)
                      return false;
                  return f.IsOnline;
              }
      
      When the character is not online, their name won't show up in the FriendList, so you handle that assuming they are not online.

      Logic wise, you want to send the invite once pretty much, wait a little, then check current client state. Here's some code that shows an example of doing this.

      You need to register and have one post to see spoilers!
      Now I did find a bug in the some core code for trying to invite a character with a name shorter than 8 characters, so that'll be fixed soon in the next version. In addition, the PartyStatus.Invited will be added. If you aren't using coroutines, you just need to implement a n emulated sleep in your behavior tree to not execute anything until the sleep timer is completed. Or, just use a stopwatch if you are doing it in a plugin to not execute it. Otherwise you can spam things that shouldn't be spammed.
       
    5. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      what he said.
       
    6. araklisk

      araklisk New Member

      Joined:
      Apr 4, 2014
      Messages:
      47
      Likes Received:
      0
      Trophy Points:
      0
      Using the friendlist check worked perfect. Not sure why the other didn't, maybe because it can't check if they're online if they're not in party or friendlist? Either way, thanks a lot.
       

    Share This Page