buy items in game
Could you please explain how the author uses CS2Interface to implement the purchase of keys or other items in the CS2 game? Thank you!
This isn't something that can currently be done and I don't have plans to add anything like this.
To add, most items I think can be purchased in a web browser, outside of the game. More info here (the links there don't work but the general idea does). This doesn't work for keys anymore as keys I believe are only purchased at the moment of unboxing and no longer go to your inventory. It also doesn't work for any items on the "Tools" store tab.
For example: Half-Life: Alyx Sticker Capsule: https://store.steampowered.com/buyitem/730/20153/1 Copenhagen 2024 Legends Sticker Capsule: https://store.steampowered.com/buyitem/730/4923/1 Anubis Collection Package: https://store.steampowered.com/buyitem/730/20197/1
The format for this is:
https://store.steampowered.com/buyitem/730/def_index/amount
amount can be between 1 and 20
def_index for an item can be found here
Thank you for your reply.I'm trying to do in-game purchase in CS:GO through GameCoordinator.
internal async Task<CMsgGCStorePurchaseInitResponse> RequestStorePurchaseInit(ulong item_id) {
if (!HasGCSession) {
throw new ClientException(EClientExceptionType.Failed, Strings.ClientNotConnectedToGC);
}
await GCSemaphore.WaitAsync().ConfigureAwait(false);
try {
CGCStorePurchaseInit_LineItem lineItem = new CGCStorePurchaseInit_LineItem {
item_def_id = (uint)item_id,
quantity = 1,
cost_in_local_currency = 25,
purchase_type = 0,
};
var msg = new ClientGCMsgProtobuf<CMsgGCStorePurchaseInit>((uint)EGCItemMsg.k_EMsgGCStorePurchaseInit) {
Body = {
country = "EU",
language = 3,
currency = 3,
}
};
msg.Body.line_items.Add(lineItem);
var fetcher = new GCFetcher<CMsgGCStorePurchaseInit, CMsgGCStorePurchaseInitResponse> {
GCResponseMsgType = (uint)EGCItemMsg.k_EMsgGCStorePurchaseInitResponse
};
Bot.ArchiLogger.LogGenericDebug(String.Format("{0}: {1}", Strings.InspectingPlayer, item_id));
var response = fetcher.Fetch(this, msg);
if (response == null) {
throw new ClientException(EClientExceptionType.Timeout, Strings.RequestTimeout);
}
return response.Body;
}
finally {
GCSemaphore.Release();
}
}
Why is the response result equal to 8? Is there a problem with my parameters? Can you help me?
Nothing looks obviously wrong to me, but I don't know what parameters should be used for the account you're trying this with. I'm not sure that "EU" is a valid country code or if that even matters. Based on this (which I don't know if this is accurate), a result of 8 could mean the currency parameter is wrong:
k_EPurchaseResultWrongCurrency = 8, // Microtransaction's currency does not match user's wallet currency
NetHook2 and NetHookAnalyzer2 should be helpful in figuring out what the parameters should be.
Thank you once again for clarifying things for me; it has been very helpful. I wish you all the best.
I now have plans to implement this feature, as the latest tournament sticker capsules don't work with the buyitem url method mentioned above.
Currently only have an InitializePurchase API that generates urls which can be used to complete purchases in the browser. Testing would be appreciated as I have no way to test this in other regions. Builds can be found under Github actions for the 1.2 branch, by clicking on the latest commit and looking under "Artifacts" (must be logged into github to see this).