forked from joshuaferrara/node-csgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request joshuaferrara#40 from Step7750/master
ItemPreviewDataBlock Support
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
var CSGO = require("../index"), | ||
util = require("util"), | ||
protos = require("../helpers/protos"); | ||
|
||
CSGO.CSGOClient.prototype.itemDataRequest = function(s, a, d, m) { | ||
/* | ||
An inspect link will include s or m depending on whether the | ||
item is in an inventory or the market | ||
If there is no value for a parameter, set it to "0" | ||
REMEMBER: The parameters must be strings in order for JavaScript to keep precision | ||
*/ | ||
|
||
if (!this._gcReady) { | ||
if (this.debug) { | ||
util.log("GC not ready"); | ||
} | ||
return null; | ||
} | ||
|
||
if (this.debug) { | ||
util.log("Sending item data request"); | ||
} | ||
|
||
var payload = new protos.CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest({ | ||
param_s: s, | ||
param_a: a, | ||
param_d: d, | ||
param_m: m | ||
}); | ||
|
||
this._gc.send({msg:CSGO.ECSGOCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest, proto: {}}, | ||
payload.toBuffer()); | ||
}; | ||
|
||
var handlers = CSGO.CSGOClient.prototype._handlers; | ||
|
||
handlers[CSGO.ECSGOCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse] = function onItemDataResponse(message) { | ||
var itemDataResponse = protos.CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse.decode(message); | ||
|
||
if (this.debug) { | ||
util.log("Received item data"); | ||
} | ||
|
||
// Convert the paintwear uint32 to float | ||
if ("iteminfo" in itemDataResponse && "paintwear" in itemDataResponse["iteminfo"]) { | ||
floatbuffer = new Buffer(4); | ||
floatbuffer.writeUInt32LE(itemDataResponse["iteminfo"]["paintwear"], 0); | ||
itemDataResponse["iteminfo"]["floatvalue"] = floatbuffer.readFloatLE(0); | ||
} | ||
|
||
this.emit("itemData", itemDataResponse); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters