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

Removal of stickers from weapons by means of API #15

Open k1de opened 6 years ago

k1de commented 6 years ago

Hello, dear DoctorMcKay and all readers. Is there a way to remove stickers from the skin by API, if not, will it be implemented? This feature would greatly facilitate the life of me and not only.

Thank you for your attention and your work. :-*

vankxr commented 5 years ago

Removing a sticker is just scratching it until it disappears (wear 100%) iirc. If that's the case you can take a look at this proto https://github.com/SteamDatabase/Protobufs/blob/f4d88b86687f841a2798fd9fe57dd4099ef04beb/csgo/base_gcmessages.proto#L176 The attr_defidx is 114 for sticker in slot 1, 118 for slot 2, 122 for slot 3 and 126 for slot 4. the attr_value should be set to 0x3F800000 (bit representation of 1 in float) if you want to scratch it completely. If you just want to change the wear to something else you should encode the wear float value in the that field.

k1de commented 5 years ago

@vankxr , thank you very much for your answer, which EGCItemMSG should I use to send CMsgModifyAttribute proto? I am tried: ApplySticker: 1086, ItemAcknowledged: 1087.

vankxr commented 5 years ago

https://github.com/SteamDatabase/Protobufs/blob/f4d88b86687f841a2798fd9fe57dd4099ef04beb/csgo/econ_gcmessages.proto#L89

k1de commented 5 years ago

@vankxr , man, I made some changes to node-globaloffensive https://github.com/k1de/node-globaloffensive/commit/d5e0fd7e37df8f5940fd626925cde078766bcb52 I use

csgo.on('connectedToGC', () => {
  csgo.removeSticker(15533389229,114,1)
})

but nothing happens

Sending GC message ClientHello Sending hello, setting timer for next attempt to 2000 ms Got handled GC message ClientWelcome Unknown SO type 2 with 1 items Unknown SO type 7 with 1 items Unknown SO type 45 with 4 items GC connection established Got unhandled GC message 9194 Got handled GC message MatchmakingGC2ClientHello Sending GC message ModifyItemAttribute

What am I doing wrong?

vankxr commented 5 years ago

What does removeSticker do exactly?

k1de commented 5 years ago

@vankxr , just this

GlobalOffensive.prototype.removeSticker = function(item_id, attr_defidx, attr_value) {
    this._send(Language.ModifyItemAttribute, Protos.CMsgModifyItemAttribute, {
        item_id ,
        attr_defidx ,
        attr_value ,
    });
};
vankxr commented 5 years ago

Removing a sticker is just scratching it until it disappears (wear 100%) iirc. If that's the case you can take a look at this proto https://github.com/SteamDatabase/Protobufs/blob/f4d88b86687f841a2798fd9fe57dd4099ef04beb/csgo/base_gcmessages.proto#L176 The attr_defidx is 114 for sticker in slot 1, 118 for slot 2, 122 for slot 3 and 126 for slot 4. the attr_value should be set to 0x3F800000 (bit representation of 1 in float) if you want to scratch it completely. If you just want to change the wear to something else you should encode the wear float value in the that field.

Read this again. You are sending the wrong attr_value.

To get the bit representation of an arbitrary float value you can use: var buf = Buffer.alloc(4); buf.writeFloatLE(arbitrary_float); attr_value = buf.readUInt32LE(0);

PS: My bad lol I did not see you linked your fork

k1de commented 5 years ago

@vankxr , unfortunately it didn't help https://github.com/k1de/node-globaloffensive/commit/dd5d6219955b22736ea3cbf7315880e84f632d00

Sending GC message ClientHello Sending hello, setting timer for next attempt to 2000 ms Sending GC message ClientHello Sending hello, setting timer for next attempt to 4000 ms Got handled GC message ClientWelcome Unknown SO type 2 with 1 items Unknown SO type 7 with 1 items Unknown SO type 45 with 4 items GC connection established { item_id: 15533389229, attr_defidx: 114, attr_value: 1065353216 } Sending GC message ModifyItemAttribute

vankxr commented 5 years ago

Can you try this one: https://github.com/SteamDatabase/Protobufs/blob/f4d88b86687f841a2798fd9fe57dd4099ef04beb/csgo/base_gcmessages.proto#L168 https://github.com/SteamDatabase/Protobufs/blob/f4d88b86687f841a2798fd9fe57dd4099ef04beb/csgo/econ_gcmessages.proto#L84

sticker_item_id = 0 item_item_id = your item id sticker_slot = slot (starting from 0, ending at 3) baseitem_defidx = 0 sticker_wear = 1

k1de commented 5 years ago

@vankxr , again failed https://github.com/k1de/node-globaloffensive/commit/360f3af2bb069c16838bdbb237b1caaf2602ba0e

Sending GC message ClientHello Sending hello, setting timer for next attempt to 2000 ms Got handled GC message ClientWelcome Unknown SO type 2 with 1 items Unknown SO type 7 with 1 items Unknown SO type 45 with 4 items GC connection established { sticker_item_id: 0, item_item_id: 15533389229, sticker_slot: 1, baseitem_defidx: 0, sticker_wear: 1 } Sending GC message ApplySticker Got handled GC message MatchmakingGC2ClientHello Got unhandled GC message 9194

skinfans commented 4 years ago

@vankxr, Many thanks for the information above! The solution to this issue is still relevant for us. Could you help us to create the correct request template?

vankxr commented 4 years ago

I'm currently not at home. I can hook the GC interface in the game and scratch some weapon to see what happens, but I don't think I have one atm. I'll see on Monday

venila commented 3 years ago

Want to up this topic