Dota2Declarations icon indicating copy to clipboard operation
Dota2Declarations copied to clipboard

CustomGameEventManager.RegisterListener problem

Open ElronMacBong opened this issue 6 years ago • 1 comments

export abstract class DevManager {
	private static RegisterListeners() {
		CustomGameEventManager.RegisterListener("devtools_get_mode", (playerID: number, event: table) => this.OnGetMode(playerID, event));
	}

	public static OnGetMode(playerID: number, event: table) {
		Log.Log(LogLevel.Debug, "DevManager", "OnGetMode", `playerID: ${playerID} event: ${event}`);
	}
}

This ends in the scenario that playerID is the event-table and event is nil. Is it related to declartions or did i failed there anything? And yes, i need that as abstract and static. ;)

ElronMacBong avatar May 12 '19 07:05 ElronMacBong

Found a solution for that:

RegisterListener(eventName: string, handler: (this: void, userID: number, event: table) => void): CCustomGameEventListener;

works perfect now. You can add this straight at line 661 on dota-api.d.ts.

ElronMacBong avatar May 12 '19 17:05 ElronMacBong