Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I apply a sticker with node-globaloffensive? #101

Open
Gostinia opened this issue Nov 26, 2024 · 3 comments
Open

How do I apply a sticker with node-globaloffensive? #101

Gostinia opened this issue Nov 26, 2024 · 3 comments

Comments

@Gostinia
Copy link

Here is my current code, it runs through and says
"Sticker ID 32188920185 applied to item 40584216802 at slot 2." because of console log
However my inventory does not change.

I have a few questions

  1. Am I formatting the message, body/paylod right?
  2. Is there a way to verify the message was sent and received
  3. I tried to match what I saw on NetHookAnalyzer2 when I placed a sticker, does anyone know the correct syntax?

`const SteamUser = require('steam-user');
const GlobalOffensive = require('globaloffensive');
const protobuf = require('protobufjs');

// Load Protobuf schema
const schema = require('./econ_gcmessages'); // Ensure this path is correct

// Steam credentials
const STEAM_USERNAME = 'steamuser';
const STEAM_PASSWORD = 'steampass';

// Create instances
let user = new SteamUser();
let csgo = new GlobalOffensive(user);

// Extend GlobalOffensive to include applySticker method
GlobalOffensive.prototype.applySticker = function (weaponItemId, stickers) {
stickers.forEach((sticker) => {
// Construct the payload for the sticker application
const payload = {
request: schema.EGCItemCustomizationNotification.k_EGCItemCustomizationNotification_ApplySticker, // ApplySticker request type
sticker_item_id: sticker.sticker_id, // Sticker ID
item_item_id: weaponItemId, // Weapon item ID
sticker_slot: sticker.slot, // Slot number (0–5)
baseitem_defidx: 0,
sticker_wear: sticker.wear || null,
sticker_rotation: sticker.rotation || null,
sticker_scale: sticker.scale || null,
sticker_offset_x: sticker.offset_x || null,
sticker_offset_y: sticker.offset_y || null,
sticker_offset_z: 0 || null,
sticker_wear_target: 0
};

    // Encode the payload
    const encoded = schema.CMsgGCItemCustomizationNotification.encode(payload).finish();

    // Send the payload to the Game Coordinator
    this._send(1086, schema.CMsgGCItemCustomizationNotification, encoded);

    console.log(
        `Sticker ID ${sticker.sticker_id} applied to item ${weaponItemId} at slot ${sticker.slot}.`
    );
});

};

// Log into Steam
user.logOn({
accountName: STEAM_USERNAME,
password: STEAM_PASSWORD,
});

// When logged in, launch CS:GO
user.on('loggedOn', () => {
console.log('Logged into Steam!');
user.gamesPlayed([730]); // Launch CS:GO
});

// Wait for GC connection
csgo.on('connectedToGC', () => {
console.log('Connected to GC!');

// Example weapon item ID
const weaponItemId = 40584216802; // Replace with actual weapon item ID

// Stickers to apply
const stickers = [
    {
        slot: 2, // Slot number (0–5)
        sticker_id: 32188920185, // Sticker ID
        wear: null, // Wear value (float, null if not applicable)
        scale: null, // Scale value (float, null if not applicable)
        rotation: 0, // Rotation value (float, null if not applicable)
        tint_id: null, // Tint ID (null if not applicable)
        offset_x: 0, // X-offset (float, null if not applicable)
        offset_y: 0, // Y-offset (float, null if not applicable)
    },
];

// Apply stickers
csgo.applySticker(weaponItemId, stickers);

});

// Debugging: Monitor connection status
csgo.on('connectionStatus', (status) => {
console.log('GC Connection Status:', status);
});

// Debugging: Capture GC-specific events (customize if needed)
csgo.on('message', (header, body) => {
console.log('GC Message Received:', header, body);
});

// Handle GC disconnection
csgo.on('disconnectedFromGC', () => {
console.log('Disconnected from GC.');
});

// Error handling for Steam and GC
user.on('error', (err) => {
console.error('Steam User Error:', err);
});

csgo.on('error', (err) => {
console.error('CS:GO GC Error:', err);
});
`

@DarkGL
Copy link

DarkGL commented Nov 27, 2024

https://github.com/DoctorMcKay/node-globaloffensive/pull/90/files

@Gostinia
Copy link
Author

Gostinia commented Nov 27, 2024

https://github.com/DoctorMcKay/node-globaloffensive/pull/90/files

Thank you !
now how do I connect my script with cs2
like https://www.youtube.com/watch?v=vWVbrV1dG2A he did here?
how does he have steam/cs2 open and the script running
it doesnt let me login if steam/cs2 is open.

@DarkGL
Copy link

DarkGL commented Nov 29, 2024

As far as I know, you can't be logged in in cs at 2 places at the same time, so I have no idea. Why would you need that? Just run the script and then run cs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants