DoctorMcKay / node-globaloffensive

A Node.js module to connect to and interact with the CS2 game coordinator. Mostly used to get item data.
https://www.npmjs.com/package/globaloffensive
MIT License
262 stars 61 forks source link

Is there a way to handle rankup event on csgo? #21

Closed dalexhd closed 5 years ago

dalexhd commented 5 years ago

It whould be nice to, instead of requesting some profiles every x time, to have an event that is emmited when the player´s profile gets changed.

vankxr commented 5 years ago

AFAIK you don't get notified of other players rank changes. Imagine handling that... You get, however, notified of your own rank changes: https://github.com/SteamDatabase/Protobufs/blob/master/csgo/cstrike15_gcmessages.proto#L553 If you are interested in implementing this, rank_type_id in PlayerRankingInfo is 6 for the Matchmaking Rank, and 7 for the Wingman rank. The rest should be obvious.

You can ask the GC to send you an update if you don't know your rank at the start by sending the same message with just the rank_type_id field set to the rank you want an update for.

DoctorMcKay commented 5 years ago

Is it even possible to rank up without playing a game?

vankxr commented 5 years ago

It is possible to rank down/lose your rank due to cheaters which you queued with getting banned or inactivity

dalexhd commented 5 years ago

It is possible to rank down/lose your rank due to cheaters which you queued with getting banned or inactivity

This is why every time user launchs csgo, I queue his rank check.

dalexhd commented 5 years ago

AFAIK you don't get notified of other players rank changes. Imagine handling that... You get, however, notified of your own rank changes: https://github.com/SteamDatabase/Protobufs/blob/master/csgo/cstrike15_gcmessages.proto#L553 If you are interested in implementing this, rank_type_id in PlayerRankingInfo is 6 for the Matchmaking Rank, and 7 for the Wingman rank. The rest should be obvious.

You can ask the GC to send you an update if you don't know your rank at the start by sending the same message with just the rank_type_id field set to the rank you want an update for.

So how do players get all friends and random people ranks updated if there must be a delay between commands to the GC? I meant, if your are on a lobby, its not possible to fetch 5 people's rank in less than 2 sec...

vankxr commented 5 years ago

They are not updated. When you click them in the menu, the game sends a profile request and the GC replies. If you are on a slow connection you will see a delay between you clicking them and the rank actually updating/showing. Iirc you can see your friends rank even if they are not in cs go but that's only cached data Lobbies are different. I don't think the game sends 5 separate requests when the lobby is already full. Later I can test that and report back what messages are exchanged with my hooks in game.

dalexhd commented 5 years ago

They are not updated. When you click them in the menu, the game sends a profile request and the GC replies. If you are on a slow connection you will see a delay between you clicking them and the rank actually updating/showing. Iirc you can see your friends rank even if they are not in cs go but that's only cached data Lobbies are different. I don't think the game sends 5 separate requests when the lobby is already full. Later I can test that and report back what messages are exchanged with my hooks in game.

Also, when you end a match and someone on your team has ranked up, you can see his updated rank in the lobby. That happens on 2-3 Sec, so how does my account know when to fetch those users profiles that have ranked up? PD: It whould be nice to know which software do you use to filter those kind of GC requests from your computer?

vankxr commented 5 years ago

Maybe because a game ended? xD It's not that hard.

dalexhd commented 5 years ago

Maybe because a game ended? xD It's not that hard.

I know that, but how does my account know which profiles has ranked up? Lets say 4 people has ranked up, so my account should fetch their ranks before showing the lobby. This makes me 2 questions: How does my profile know witch profiles to fetch? Or it always fetch those 4 profiles even if they have not ranked up? Also, when the game ends, how does my account fetch other team ranks so fast (even if they are not updated...)?

vankxr commented 5 years ago

You know the other team ranks during the entire game. There is a feature in most cheats that reveals the ranks, and that feature does nothing but calling a function to show the ranks, it does not do magic to fetch them. Also, 2~3 seconds as you say is A LOT of time to fetch 4 or even 10 people ranks. It can also have a cachinig system like the inventory does, where you send the timestamp when you got the last update form the GC and it just answers if there has been an update after that timestamp

dalexhd commented 5 years ago

You know the other team ranks during the entire game. There is a feature in most cheats that reveals the ranks, and that feature does nothing but calling a function to show the ranks, it does not do magic to fetch them. Also, 2~3 seconds as you say is A LOT of time to fetch 4 or even 10 people ranks. It can also have a cachinig system like the inventory does, where you send the timestamp when you got the last update form the GC and it just answers if there has been an update after that timestamp

How much is the dalay needed between calls? Edit: It seems that is 1 sec looking on forums...

vankxr commented 5 years ago

1 sec between every message sent to GC? Can you link me that?

dalexhd commented 5 years ago

descarga 1 I did not explain myself very well... I mean, the delay between profile requests...

vankxr commented 5 years ago

Strange, I remember spamming the GC with ClientHello in my Inventory Changer cheat, and it always worked.

vankxr commented 5 years ago

Ok so I tested within the game. I confirmed that the game sends a profile request everytime you click someone in your friends/nearby list. Regarding the lobbies it is a different story. It is handled by other means, probably by steam friends, since none of the lobby actions except starting matchmaking seem to trigger any GC messages. If you click a lobby member it is the same as clicking anyone in the friends list.

I can also confirm that I successfully spam the GC https://image.prntscr.com/image/7ESYgnMiSAq5B5wuKMlIsA.jpeg https://image.prntscr.com/image/g47-by5qSoifIjVwuAUaUA.jpeg https://image.prntscr.com/image/xgzrM9--RleDcQ8DwMmL_w.jpeg

Full log: (The first integer is the Unix Timestamp in seconds) log.txt

As you can see, at 1550611258 I send a ClientHello (4006) plus a bunch of other messages. The GC does not complain and it even responds with the big ClientWelcome (4004) payload. All this within the same second