CamxxCore / iFruitAddon

GTA V ScriptHookVDotNet extension allowing customization of the in- game mobile phone
MIT License
20 stars 10 forks source link

New contact either overlayed another contact or not available #4

Closed RainerHilmer closed 8 years ago

RainerHilmer commented 8 years ago

I took your example script and copied most parts in a vehicle delivery mod that I'm currently developing. In fact, I attached a method "CallVehicleDeliverer" to the Selected event. When using index 19 as in your sample script, it dials Ricky, I get the line occupied signal and the vehicle gets delivered. Then I tried placing the new contact below the last entry in Michael's contact list by setting the index to 24. The new contact is in the list but when I dial it I get a message "The contact you dialed is no longer available" and nothing else happens. Here is the code. For your convenience I removed most parts which have no role regarding this issue.

using System;
using System.Windows.Forms;
using Cyron43.GtaV.Common;
using GTA;
using GTA.Math;
using iFruitAddon;

namespace VVehicleDelivery
{
   // ReSharper disable once ClassNeverInstantiated.Global
   public class Core : Script
   {
      private const int SPAWNING_RADIUS = 100;
      private readonly CommonObjects _commonObjects;
      private readonly KeyHandling _keyHandling;
      private readonly TickEventHandlers _tickEventHandlers;
      private bool _fail;
      CustomiFruit _ifruit;
      private ErrorType _typeOfError;

      public Core()
      {
         ReadConfiguration();
         if(_typeOfError != ErrorType.None)
            return;
         _commonObjects = CommonObjects.CreateOrGetThis();
         Interval = _commonObjects.GlobalTickInterval;
         _keyHandling = new KeyHandling(this);
         _tickEventHandlers = new TickEventHandlers(this);
         KeyDown += OnKeyDown;
         CreateiFruitContact();
      }

      private void CreateiFruitContact()
      {
         _ifruit = new CustomiFruit();
         var contact = new iFruitContact("Vehicle delivery", 19);
         contact.Selected += (s, a) => CallDeliverer();
         contact.DialTimeout = 0;
         contact.Icon = ContactIcon.Taxi;
         _ifruit.Contacts.Add(contact);
         Tick += OnTick;
      }

      private void OnTick(object sender, EventArgs e)
      {
         _ifruit.Update();
      }      

      internal void CallDeliverer()
      {
         ReadConfiguration();
         _fail = false;
         _commonObjects.Dismissed = false;
         DelivererIsOnDuty = true;
         _commonObjects.Target = Game.Player.Character.Position;
         CreateVehicle();
         if(_fail)
            return;
         MakeVehicleDrive();
         UI.ShowSubtitle("The vehicle deliverer is on his way to you.",
            5000);
      }
   }
}
CamxxCore commented 8 years ago

Yes this demonstrates some of the limits we have to deal with when manipulating scaleform movies. We have no way of determining the amount of items in the list without some kind of manual calibration. We also cannot remove the action that is performed when the item is selected because it is all managed by rockstar scripts. I have tried many workarounds to get the phone to stay open (disabling control actions etc.). Nothing has worked :( Of course we could stop the script that handles the phone but that's a bit counterintuitive

RainerHilmer commented 8 years ago

Thank you

RainerHilmer commented 8 years ago

The creator of the watchdogs hack mod ( https://www.gta5-mods.com/scripts/hack-mod-v-01a ) managed to add new contacts with the help of your framework. So it must be possible somehow.

CamxxCore commented 8 years ago

You will be able to do that by default. Its the reason I made this add-on. Maybe you have some calls to script.wait elsewhere in your tick method that is delaying the time when the Update() method is called? Maybe try reverting to an older version and see if you have any luck. I can't rule out the possibility that maybe there is some incompatibility between scripthookvdotnet versions based on some of the new things I've added.

RainerHilmer commented 8 years ago

I don't quite understand. At first you say "We have no way of determining the amount of items in the list without some kind of manual calibration". What do you mean by "manual calibration" anyway? And then you say "You will be able to do that by default". Isn't this a contradiction? And why do you use the term "will be"? You mean it's not by default right now but in a future release?

CamxxCore commented 8 years ago

Not at all. We are talking about two completely different things here my friend. You can still add items past the last visible item in the list, but we can't determine the amount of items without iterating through every item until the index lapses to 0. This is what I mean by manual calibration. I apologize that my explanations have been confusing for you. You are right in that maybe I could have worded it better.