get event id?

hello, I need some little help from the pro scripters. I need to get the last id of the event to erase it that triggered from the certain event.

Ruby:
#==============================================================================
# ** Event Killing Each Other
#------------------------------------------------------------------------------
#  This class handles events. Functions include event page switching via
# condition determinants and running parallel process events. Used within the
# Game_Map class.
#==============================================================================

class Game_Event < Game_Character
  #==========================================================================
  def get_id_if_dead(i)
    a = 0
    for @id in 0..i do # for each amount of existing events in the last defined id
      until a == i do # tracks down the event id to be erased
        a++
      end
      if a == i # if it gets the right id then erases the chosen id's event
        @erased = true # dunno if this works
        refresh
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Trigger Map Event
  #     triggers : Trigger array
  #     normal   : Is priority set to [Same as Characters] ?
  #--------------------------------------------------------------------------
  def start_map_event(x, y, triggers, normal, id)
    return if $game_map.interpreter.running?
    $game_map.events_xy(x, y).each do |event|
      if event.trigger_in?(triggers) && event.normal_priority? == normal
        get_id_if_dead(event.id) if $game_switches[1] == true # how can i find it's id
        event.start
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Determine if Touch Event is Triggered
  #--------------------------------------------------------------------------
  def check_event_trigger_touch(x, y)
    start_map_event(x, y, [1,2], true)
  end
end

i think my idea is to make a for each or for loop defining every existing event ids inside the new method to get the chosen id to be deleted but i have no idea how can i do it.
First of all, Ruby and RGSS has no such thing as var++. You will need to write it as var += 1 instead.

Err, perhaps there's another way to solve this issue. What about setting a method to tell the system or the map that an event has recently died? Then you could store it in some array for later use. It'd be better than looping through all of the 100+ events on the map. Just saying.
What about setting a method to tell the system or the map that an event has recently died? Then you could store it in some array for later use. It'd be better than looping through all of the 100+ events on the map. Just saying.
do you mean (let me make a pseudocode):
make an array of total events of 100 setting each values to "true" defining an event is alive
a = 0
until a == total of events - non enemy events
enemies[a] = true
a += 1

def check_event_death(i)
set enemies = false
if enemies == false
then remove event id no (i)

def trigger battle(event id a, event id b)
random 1..2
if random is = 1
then event a wins
then call check_event_death(event id b)
else envent b wins

when event no. 6 and event no. 1 are touching each other
call trigger battle(event no. 1's id, event no. 6's id)
#but how can i get these guys event ids when this happen?

Original thread: https://forums.rpgmakerweb.com/threads/get-event-id.152512/