Jump to content
McKay Development

globaloffensive - matchList multiple in a row


Xaviius

Recommended Posts

Hey,

is there any possibility to repeat the requestLiveGameForUser method? If I call the method the first time it works, but the second, third... time it does not. Here is the important code:

csgoUser.on('connectedToGC', async () => {
    searchedids = []
    for (let steamid of steamids) {
        if (!searchedids.some((searched) => searched === steamid.getSteamID64())) {
            csgoUser.requestLiveGameForUser(steamid.getSteamID64());
            await sleep(10000)
        }
    }
});
csgoUser.on('matchList', async (response) => {
    console.log(response);
    steamClient.logOff();
});

Any clue why it does not work? 

Thank you for this awesome lib!

Link to comment
Share on other sites

I already tried to use it with Promise like this:

await new Promise((resolve) => {
	csgoUser.on('matchList', resolve);
})

The first time it works and the second it awaits and never finishes... 

the whole important code looks like this at the moment:

for (let steamid of steamids) {
	if (!searchedids.some((searched) => searched === steamid.getSteamID64())) {
		csgoUser.requestLiveGameForUser(steamid.getSteamID64());
		await matchList(await new Promise((resolve) => {
			csgoUser.on('matchList', resolve);
		}));
		await sleep(1000);
	}
}
steamClient.logOff();

 

Link to comment
Share on other sites

Its basically what I did in the event before:

async function matchList(matches: Array<IMatch>) {
    console.log(matches)
    if (matches[0]) {
        matches[0].roundstats_legacy.reservation.account_ids.forEach(async (accid: number) => {
            if (await monitoringRepository.findOne(SteamID.fromIndividualAccountID(accid).getSteamID64()) === undefined && await mmRepository.findOne(SteamID.fromIndividualAccountID(accid).getSteamID64()) === undefined) {
                var steamid_db = {
                    id: SteamID.fromIndividualAccountID(accid).getSteamID64(),
                    date: new Date().toJSON().slice(0, 10)
                };
                searchedids.push(SteamID.fromIndividualAccountID(accid).getSteamID64());
                mmRepository.save(steamid_db).then(() => logger.info("SteamID: " + SteamID.fromIndividualAccountID(accid).getSteamID64() + " added to matchmaking accounts."))
                    .catch((err) => logger.error(err));
            }
        });
    }
}

Even with once it does not work constantly. Sometimes it only works for 2 steamids and then again only for one, even though they are 8. steamids is an array of type SteamID of your other library.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...