Skip to content

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

@Gostinia

Description

@Gostinia

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);
});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions