Log in to reply
 

Help with C# cannot explicitly call operator or accessor



  • I'm trying to improve my understanding of C# by decompiling simple script mods and trying to understand the code. For example I decompiled this disable radio mod but when I try to recompile it in VS it throws compiler errors.
    Mod was open source but link is rotten.
    Mod: https://www.gta5-mods.com/scripts/disable-radio

    Can someone explain to me why these errors and how to correct them?

    P.S. Not going to use this script or upload it. Just want to learn how to code properly.

    Currently I have my own code for shutting of the radio:

     if (Game.Player.Character.IsSittingInVehicle())
                {
       Function.Call(Hash.SET_VEH_RADIO_STATION, Game.Player.Character.CurrentVehicle, "OFF");
    OR             
       Function.Call(Hash.SET_VEHICLE_RADIO_ENABLED, Game.Player.Character.CurrentVehicle, false);
                    
                }
    

    But this is the code I'm trying to learn from:
    And these are the errors
    'Entity.operator !=(Entity, Entity)': cannot explicitly call operator or accessor
    and
    'InputArgument.implicit operator InputArgument(bool)': cannot explicitly call operator or accessor

    
    using GTA;
    using GTA.Native;
    using System;
    using System.Windows.Forms;
    
    namespace Disable_Radio
    {
      public class Disable_Radio : Script
      {
        private bool enabled;
        private ScriptSettings config;
        private readonly int cheatString;
        private Keys Toggle_Radio;
    
        public Disable_Radio()
        {
          this.enabled = this.Settings.GetValue<bool>("SETTINGS", "ENABLED_ON_STARTUP", true);
          this.cheatString = Game.GenerateHash(this.Settings.GetValue("SETTINGS", "CHEAT_STRING", "radio"));
          this.config = ScriptSettings.Load("scripts\\Disable_Radio.ini");
          this.Toggle_Radio = this.config.GetValue<Keys>("Options", "Toggle_Radio:", Keys.None);
          this.Interval = 0;
          this.Tick += new EventHandler(this.DisableRadio_Tick);
          this.KeyDown += new KeyEventHandler(this.ToggleRadio_Down);
        }
    
        private void DisableRadio_Tick(object sender, EventArgs e)
        {
          if (Function.Call<bool>((Hash) 6160435850588389544L, new InputArgument[1]
          {
            InputArgument.op_Implicit(this.cheatString)
          }))
          {
            this.enabled = !this.enabled;
            if (!this.enabled && Game.Player.Character.IsInVehicle())
            {
              Vehicle currentVehicle = Game.Player.Character.CurrentVehicle;
              if (Entity.op_Inequality((Entity) currentVehicle, (Entity) null) && ((Entity) currentVehicle).Exists() && ((Entity) currentVehicle).IsAlive)
                Function.Call((Hash) 4294324703405435915L, new InputArgument[2]
                {
                  InputArgument.op_Implicit(currentVehicle),
                  InputArgument.op_Implicit(true)
                });
            }
          }
          if (!this.enabled || !Game.Player.Character.IsInVehicle())
            return;
          Vehicle currentVehicle1 = Game.Player.Character.CurrentVehicle;
          if (Entity.op_Inequality((Entity) currentVehicle1, (Entity) null) && ((Entity) currentVehicle1).Exists() && ((Entity) currentVehicle1).IsAlive)
            Function.Call((Hash) 4294324703405435915L, new InputArgument[2]
            {
              InputArgument.op_Implicit(Game.Player.Character.CurrentVehicle),
              InputArgument.op_Implicit(false)
            });
        }
    
        private void ToggleRadio_Down(object sender, KeyEventArgs e)
        {
          if (e.KeyCode == this.Toggle_Radio)
          {
            this.enabled = !this.enabled;
            if (!this.enabled && Game.Player.Character.IsInVehicle())
            {
              Vehicle currentVehicle = Game.Player.Character.CurrentVehicle;
              if (Entity.op_Inequality((Entity) currentVehicle, (Entity) null) && ((Entity) currentVehicle).Exists() && ((Entity) currentVehicle).IsAlive)
                Function.Call((Hash) 4294324703405435915L, new InputArgument[2]
                {
                  InputArgument.op_Implicit(currentVehicle),
                  InputArgument.op_Implicit(true)
                });
            }
          }
          if (!this.enabled || !Game.Player.Character.IsInVehicle())
            return;
          Vehicle currentVehicle1 = Game.Player.Character.CurrentVehicle;
          if (Entity.op_Inequality((Entity) currentVehicle1, (Entity) null) && ((Entity) currentVehicle1).Exists() && ((Entity) currentVehicle1).IsAlive)
            Function.Call((Hash) 4294324703405435915L, new InputArgument[2]
            {
              InputArgument.op_Implicit(Game.Player.Character.CurrentVehicle),
              InputArgument.op_Implicit(false)
            });
        }
      }
    }
    
    

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.