Help with gameus/game_guy/G_G's "Party Item Limit" script deleting equipment when unequipping them?

This script is the best I've found for what I'm going for, and I've found solutions for its two other flaws (Bugs regarding shops and it not accounting for Key Items), but this one refuses to cooperate with me.

Long story short, if your inventory is full and you unequip something (Not swapping it for another piece of equipment), it gets deleted. The closest I've gotten to fixing it is having it prevent you from unequiping if you're inventory is one less than the max (For some reason).

Here's the link to script in question, and the spoilers have what I've edited of it and how I've edited "Scene_Equip."

Script edit:
Spoiler
Code:
#===============================================================================
# Party Item Limit
# Author: game_guy
# Date: June 6th, 2009
#-------------------------------------------------------------------------------
# Intro
# What this script does is set the party's item limit. For instance say the
# party item limit is 10. You can only hold 10 different items/weapons/armors.
# For example you have 6 potions and 4 high potions. You won't be able to
# Carry anything else.
#
# Features
# * Limits how many items the party can carry
#
# Instructions
# Go down to the BEGIN CONFIG and you'll see this line
# @max_items = 20
# Change that 20 to whatever you like.
# You can also change that number in game using this in a script call
# $game_system.max_items = x
# x = number
#
# Credits
# game_guy ~ for making it
# Xuroth ~ inspiring me with the idea of a post
# link to post
# http://forum.chaos-project.com/index.php?topic=3444.msg74388#msg74388
#===============================================================================

#===============================================================================
# Game_System
#-------------------------------------------------------------------------------
# *Changed one method
#===============================================================================
class Game_System
  attr_accessor :max_items
  alias add_max_items initialize
  def initialize
    #===========================================================================
    # BEGIN CONFIG
    @max_items = 60 #+ $game_variables[1] # Change this to the max items you want the party to carry
    # END CONFIG
    #===========================================================================
    add_max_items
  end
end
#===============================================================================
# Game_Party
#-------------------------------------------------------------------------------
# *Added one method
# *changed three methods
#===============================================================================
class Game_Party
  #=============================================================================
  # Get Item Total
  #=============================================================================
  def get_item_total
    amount = 0
    $game_variables[1] = 0
    for i in 1...$data_items.size
      if item_number(i) > 0
        amount += item_number(i)
      end
    end
    for i in 1...$data_weapons.size
      if weapon_number(i) > 0
        amount += weapon_number(i)
      end
    end
    for i in 1...$data_armors.size
      if armor_number(i) > 0
        amount += armor_number(i)
      end
    end
    amount -= $game_variables[3]
    $game_variables[1] = amount
    return amount
  end
  #=============================================================================
  # Gain Item
  #=============================================================================
  def gain_item(item_id, n)
    if item_id > 0
      itemamount = get_item_total
      unless itemamount == $game_system.max_items + 1 #The "+ 1" solves the perma-item bug.
        number = $game_system.max_items - itemamount
        if n > number
          n = number
        end
        @items[item_id] = [[item_number(item_id) + n, 0].max, 99].min
      end
    end
  end
  #=============================================================================
  # Gain Weapon
  #=============================================================================
  def gain_weapon(weapon_id, n)
    if weapon_id > 0
      itemamount = get_item_total
      unless itemamount == $game_system.max_items + 1
        number = $game_system.max_items - itemamount
        if n > number
          n = number
        end
        @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
      end
    end
  end
  #=============================================================================
  # Gain Armor
  #=============================================================================
  def gain_armor(armor_id, n)
    if armor_id > 0
      itemamount = get_item_total
      unless itemamount == $game_system.max_items + 1
        number = $game_system.max_items - itemamount
        if n > number
          n = number
        end
        @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
      end
    end
  end
end

Scene_Equip edit:
Spoiler
Code:
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================

class Scene_Equip
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #     equip_index : equipment index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
    @equip_index = equip_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @help_window = Window_Help.new
    @left_window = Window_EquipLeft.new(@actor)
    @right_window = Window_EquipRight.new(@actor)
    @item_window1 = Window_EquipItem.new(@actor, 0)
    @item_window2 = Window_EquipItem.new(@actor, 1)
    @item_window3 = Window_EquipItem.new(@actor, 2)
    @item_window4 = Window_EquipItem.new(@actor, 3)
    @item_window5 = Window_EquipItem.new(@actor, 4)
    # Associate help window
    @right_window.help_window = @help_window
    @item_window1.help_window = @help_window
    @item_window2.help_window = @help_window
    @item_window3.help_window = @help_window
    @item_window4.help_window = @help_window
    @item_window5.help_window = @help_window
    # Set cursor position
    @right_window.index = @equip_index
    refresh
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @left_window.dispose
    @right_window.dispose
    @item_window1.dispose
    @item_window2.dispose
    @item_window3.dispose
    @item_window4.dispose
    @item_window5.dispose
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Set item window to visible
    @item_window1.visible = (@right_window.index == 0)
    @item_window2.visible = (@right_window.index == 1)
    @item_window3.visible = (@right_window.index == 2)
    @item_window4.visible = (@right_window.index == 3)
    @item_window5.visible = (@right_window.index == 4)
    # Get currently equipped item
    item1 = @right_window.item
    # Set current item window to @item_window
    case @right_window.index
    when 0
      @item_window = @item_window1
    when 1
      @item_window = @item_window2
    when 2
      @item_window = @item_window3
    when 3
      @item_window = @item_window4
    when 4
      @item_window = @item_window5
    end
    # If right window is active
    if @right_window.active
      # Erase parameters for after equipment change
      @left_window.set_new_parameters(nil, nil, nil)
    end
    # If item window is active
    if @item_window.active
      # Get currently selected item
      item2 = @item_window.item
      # Change equipment
      last_hp = @actor.hp
      last_sp = @actor.sp
      @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
      # Get parameters for after equipment change
      new_atk = @actor.atk
      new_pdef = @actor.pdef
      new_mdef = @actor.mdef
      # Return equipment
      @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
      @actor.hp = last_hp
      @actor.sp = last_sp
      # Draw in left window
      @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @left_window.update
    @right_window.update
    @item_window.update
    refresh
    # If right window is active: call update_right
    if @right_window.active
      update_right
      return
    end
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when right window is active)
  #--------------------------------------------------------------------------
  def update_right
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(2)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If equipment is fixed
      if @actor.equip_fix?(@right_window.index)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Activate item window
      @right_window.active = false
      @item_window.active = true
      @item_window.index = 0
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different equipment screen
      $scene = Scene_Equip.new(@actor_index, @right_window.index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Activate right window
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      $game_variables[1] = $game_party.get_item_total
      # Play equip SE (Old)
      #$game_system.se_play($data_system.equip_se)
      # Get currently selected data on the item window
      item = @item_window.item
      # Change equipment
      #if $game_party.get_item_total == $game_system.max_items
      if $game_variables[1] == $game_system.max_items
        #if $game_party.weapon_number(item.id) > 0
        if item == nil
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
        else
          # Play equip SE
          $game_system.se_play($data_system.equip_se)
          # Equip item
          @actor.equip(@right_window.index, item == nil ? 0 : item.id)
        end
      else
        # Play equip SE
        $game_system.se_play($data_system.equip_se)
        # Equip item
        @actor.equip(@right_window.index, item == nil ? 0 : item.id)
      end
      # Activate right window
      @right_window.active = true
      @item_window.active = false
      @item_window.index = -1
      # Remake right window and item window contents
      @right_window.refresh
      @item_window.refresh
      return
    end
  end
end

Trying to fix this is starting to drive me mad, so I'm trying my luck asking for help. Probably doesn't help that this is my first time making something other than a Pokémon Essentials game with XP (My main reason is the existence of the FPLE script, since it runs and looks much better than the MV version).

Edit: So, apparently it also deletes Items when you swap equipment. Idk how I didn't notice that before.

Edit 2: I just realized this goes elsewhere, and I'm not sure how to delete or move a post. .-.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-gameus-game_guy-g_gs-party-item-limit-script-deleting-equipment-when-unequipping-them.164153/