Self Switch Script call for multiple events on a map

Hi All,

I need to use
Code:
$gameSelfSwitches.setValue([$gameMap._mapId, EVENTID, 'A'], false);

But for EVENTID I was hoping to use an array of multiple event IDs so I don't have to redo that code for multiple events. Something like this, but you know, done correctly:
Code:
var E = [1,5,9, etc.]
$gameSelfSwitches.setValue([$gameMap._mapId, E, 'A'], false);

I feel like I found that a while ago but i can't for the life of me find it again. Could anybody here help show me how I could do that?
Any help is greatly appreciated.
Solution:
JavaScript:
                Game_Interpreter.prototype.allEvSelfSwitch = function(letters, false) {
                    for (var i = 1; i <= $gameMap.events().length; i++) {
                    var event = $gameMap.event([i]);
                    //use extra if conditions here if needed
                        var key = [this._mapId, ([i]), letters];
                        $gameSelfSwitches.setValue(key, false);
                  
              
                    }
                };

I edited one of My Plugins Scripts.. this should do what you want, it will set all SELf Switches of all Events on Map to the "true or false" ..where "letters" are 'A' ,'B', 'C' or 'D' ...

You can use extra If Conditions to include or exclude some GameMap Events

as example this is the original Script which i use in my plugin SRPG_UnitGroups.js:
Another Example:
JavaScript:
                //12T_reset SelfSwitch: "this.allTxSelfSwitch(checkId, letters, "team")"
                Game_Interpreter.prototype.allTxSelfSwitch = function(checkId, letters, team) {
                    for (var i = 1; i <= $gameMap.events().length; i++) {
                    var battleunit = $gameSystem.EventToUnit([i]);
                    var eventunit = $gameMap.event([i]);
                    if (battleunit && eventunit && (battleunit[0] === 'actor' || battleunit[0] === 'enemy') && (!battleunit[1].isDead())) {
                        if (battleunit[1].isStateAffected(checkId) && (battleunit[1].srpgTeam() == team)) {
                            var key = [this._mapId, ([i]), letters];$gameSelfSwitches.setValue(key, false);
                        }
                    }
              
                    }
                    return true;
                };
(I only use this to reset all SelfSwitches thats why my example Script dont ask for true of false in the function "()"..)
setValue sets one switch at a time, so you need use a loop here. E.g.
JavaScript:
var m = $gameMap.mapId();
[1,5,9].forEach(function(e) {
  $gameSelfSwitches.setValue([m, e, 'A'], false);
});
Thank you so much, that worked perfectly.

Original thread: https://forums.rpgmakerweb.com/threads/self-switch-script-call-for-multiple-events-on-a-map.128995/