Vehicle Enter/Exit plugin

Hi all- been a hectic week and a progressive one at that.


I'm currently in desperate need for a plugin that can allow me to command when I want the player to be able to enter or exit a vehicle- why? Because the program as far to my knowledge is not equip with such a command and I need it so I can prevent glitches occurring with events I have been working on.


I have considered using many plugins that allow you to control where vehicles can be operational using regions and terrain etc. But these factors are already in use and cannot be tampered with further in specific areas. The master plugin list also does not appear to supply a plugin as such and google itself is not exactly providing me the resources.


I greatly appreciate the help here!
I haven't tested this and I'm just about to shut down, but your request seems simple enough that it wouldn't take much.  Please post back if there are any issues (if an error message, full error message plus screenshot of console log from F8).  File name does not matter.

Code:
//========================================================================
// Vehicle Interaction Conditions
//========================================================================

/*:
 * @plugindesc Vehicle Interaction Conditions
 * <VehicleInteractionConditions>
 * @author Shaz
 *
 * @param Vehicle Enable Switch
 * @desc Switch to turn on when vehicle can be interacted with
 * @default 10
 *
 * @help This plugin has no plugin commands
 */

(function() {
  var params = $plugins.filter(function(p) { return p.description.contains('<VehicleInteractionConditions>'); })[0].parameters;
  var vehicleSwitch = Number(params['Vehicle Enable Switch']);
  
  _Game_Player_getOnOffVehicle = Game_Player.prototype.getOnOffVehicle;
  Game_Player.prototype.getOnOffVehicle = function() {
    if ($gameSwitches.value(vehicleSwitch)) {
      _Game_Player_getOnOffVehicle.call(this);
    }
  };
    
})();
Seems to work very well for me, thank you for your assistance. I'll make sure to give you credit for this 🙂
Does this work for MZ? I tried changing the value but it made no seeming difference.
Necro-post notice: @Seyfert

Please ask your questions in your own thread.

Original thread: https://forums.rpgmakerweb.com/threads/vehicle-enter-exit-plugin.73284/