1 | var CSGO = require("../index"),
|
2 | util = require("util"),
|
3 | protos = require("../helpers/protos");
|
4 |
|
5 | CSGO.CSGOClient.prototype.itemDataRequest = function(s, a, d, m) {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | if (!this._gcReady) {
|
16 | if (this.debug) {
|
17 | util.log("GC not ready");
|
18 | }
|
19 | return null;
|
20 | }
|
21 |
|
22 | if (this.debug) {
|
23 | util.log("Sending item data request");
|
24 | }
|
25 |
|
26 | var payload = new protos.CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest({
|
27 | param_s: s,
|
28 | param_a: a,
|
29 | param_d: d,
|
30 | param_m: m
|
31 | });
|
32 |
|
33 | this._gc.send({msg:CSGO.ECSGOCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest, proto: {}},
|
34 | payload.toBuffer());
|
35 | };
|
36 |
|
37 | var handlers = CSGO.CSGOClient.prototype._handlers;
|
38 |
|
39 | handlers[CSGO.ECSGOCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse] = function onItemDataResponse(message) {
|
40 | var itemDataResponse = protos.CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse.decode(message);
|
41 |
|
42 | if (this.debug) {
|
43 | util.log("Received item data");
|
44 | }
|
45 |
|
46 |
|
47 | if ("iteminfo" in itemDataResponse && "paintwear" in itemDataResponse["iteminfo"]) {
|
48 | floatbuffer = new Buffer(4);
|
49 | floatbuffer.writeUInt32LE(itemDataResponse["iteminfo"]["paintwear"], 0);
|
50 | itemDataResponse["iteminfo"]["floatvalue"] = floatbuffer.readFloatLE(0);
|
51 | }
|
52 |
|
53 | this.emit("itemData", itemDataResponse);
|
54 | };
|