Get current event id

Hey guys, I want to get current (running) event id.

I have tried

$gameMap.event(this.eventId)but it's not work. any solution?
Use either

this._eventId

or

this.eventId()
Use either

this._eventId

or

this.eventId()
still no luck  🙁
Show the whole script you're trying to run.  If your plugin runs through Game_Interpreter, either of the above will work.  So it depends on the context - whether it's in a Game_Interpreter function, a Game_Map function, a Game_Event function, or something of your own.
it's game_map.

Spoiler
Code:
//this script will locate the event at random position specific by region.var alias = Game_Map.prototype.initialize;Game_Map.prototype.initialize = function () {	alias.apply(this);};var mapRegion = [];var mapRegionData = [];var alias2 = Scene_Map.prototype.start;Scene_Map.prototype.start = function () {	alias2.apply(this)	//console.log($gameMap.regionId($gamePlayer.x, $gamePlayer.y))	if (this.isReady()) {		console.log(Number($gameMap.getWidth()));	}};Game_Map.prototype.setupRegion = function () {	mapRegion = [];	mapRegionData = [];	for (i = 0; i < 255; i++) {		mapRegion.push(i);		mapRegionData.push([])	}	for (j = 0; j < Number($gameMap.getWidth()); j++) {		for (k = 0; k < Number($gameMap.getHeight()); k++) {			if (($gameMap.regionId(j, k) == 0) == false) {				mapRegionData[$gameMap.regionId(j, k)].push(j + "," + k);			};		};	};};Game_Map.prototype.setEventLocatex = function (region,direction) {	if (mapRegionData[region].length > 0) {		var rand = Math.floor((Math.random() * mapRegionData[region].length) + 1);		var test = mapRegionData[region][rand];		var text = test.split(/\s*,\s*/);		//console.log('X: ' + text[0] + ' \nY: ' + text[1]);		console.log(test);		console.log(rand);		console.log($gameMap.event(this._eventId).x) // << this is the error		//$gameMap.event(this.eventId).locate(Number(text[0]),Number(text[1]));   // << this is the error		//$gameMap.event(this._eventId).locate(Number(text[0]),Number(text[1]));  // << this is the error		if (direction) {			$gameMap.events(this.eventId()).setDirection(direction)		};	};};Game_Map.prototype.getWidth = function () {	return String($dataMap.width)};Game_Map.prototype.getHeight = function () {	return String($dataMap.height)}; 
Then there is no "current" event.  The function would need to accept an event id, if it's called from a script or plugin call, or would need to test ALL of the events in its list to see which one(s) need to be moved.  If you are doing some "place event randomly when the map starts", I assume you would have some way of determining which events need to be placed randomly, and in that case, within Game_Event would be the better place for your code to go.

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