Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using SteamKit2.GC.CSGO.Internal;
- using SteamKit2;
- using SteamKit2.Internal;
- using SteamKit2.GC;
- using System.Threading;
- using System.Collections.Concurrent;
- using System.Text.RegularExpressions;
- /**
- Too lazy to teach ppl have some sample shit code for csgo's float wear shit
- **/
- namespace csgo_qq {
- public class InspectItem {
- public ulong param_s { get; set; } = 0;
- public ulong param_a { get; set; } = 0;
- public ulong param_d { get; set; } = 0;
- public ulong param_m { get; set; } = 0;
- public static InspectItem FromLink(string link) {
- Match matches = LINK_REGEX.Match(link.ToLower());
- if (!matches.Success)
- throw new ArgumentException("Bad inspection link");
- return new InspectItem {
- param_s = matches.Groups["S"].Success ? Convert.ToUInt64(matches.Groups["S"].Value) : 0,
- param_a = Convert.ToUInt64(matches.Groups["A"].Value),
- param_d = Convert.ToUInt64(matches.Groups["D"].Value),
- param_m = matches.Groups["M"].Success ? Convert.ToUInt64(matches.Groups["M"].Value) : 0,
- };
- }
- public bool Send(SteamGameCoordinator steamGC) {
- var request = new ClientGCMsgProtobuf<CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest>((uint) ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockRequest);
- request.Body.param_s = param_s;
- request.Body.param_a = param_a;
- request.Body.param_d = param_d;
- request.Body.param_m = param_m;
- Console.WriteLine($"Requesting skin: ASSETID[{param_a}], DICKID[{param_d}], STEAMID[{param_s}], MARKETID[{param_m}]");
- steamGC.Send(request, Client.APP_ID);
- return true;
- }
- public override string ToString() {
- return $"S[{param_s}] A[{param_a}] D[{param_d}] M[{param_m}]";
- }
- public static Regex LINK_REGEX = new Regex(@"(?:s(?<S>\d+)|m(?<M>\d+))a(?<A>\d+)d(?<D>\d+)", RegexOptions.Compiled);
- }
- public class Test {
- ConcurrentQueue<InspectItem> Items = new ConcurrentQueue<InspectItem>();
- private Thread _workerThread;
- private bool isRunning = false;
- public SteamGameCoordinator steamGC { get; set; }
- public int Append(InspectItem item) {
- Items.Enqueue(item);
- return Items.Count;
- }
- public Test() {
- _workerThread = new Thread(Consume) { IsBackground = true, Name = "fuckmesenpai" };
- }
- public void Start() {
- _workerThread.Start();
- isRunning = true;
- }
- public void Stop() {
- isRunning = false;
- _workerThread.Abort();
- }
- private void Consume() {
- while (isRunning) {
- InspectItem item;
- if (!Items.TryDequeue(out item)) {
- Thread.Sleep(150);
- continue;
- }
- item.Send(steamGC);
- Thread.Sleep(1400);
- }
- }
- }
- public class Client {
- public const uint APP_ID = 730;
- public string username { get; set; }
- public string password { protected get; set; }
- private static SteamClient steamClient { get; } = new SteamClient();
- private static CallbackManager manager { get; } = new CallbackManager(steamClient);
- private static SteamUser steamUser { get; } = steamClient.GetHandler<SteamUser>();
- private static SteamFriends steamFriends { get; } = steamClient.GetHandler<SteamFriends>();
- private static SteamGameCoordinator steamGC { get; } = steamClient.GetHandler<SteamGameCoordinator>();
- public bool isRunning, isReady;
- public Test test;
- public void Init(bool autoStart = false) {
- SteamDirectory.Initialize().Wait(); // Servers fucked
- manager.Subscribe<SteamClient.ConnectedCallback>((callback) => {
- if (callback.Result != EResult.OK) {
- Stop($"Unable to connect to Steam: {callback.Result}");
- return;
- }
- Console.WriteLine($"Connected to steam, logging into the account '{username}'.");
- steamUser.LogOn(new SteamUser.LogOnDetails {
- Username = this.username,
- Password = this.password,
- });
- this.password = null;
- });
- manager.Subscribe<SteamGameCoordinator.MessageCallback>(OnMessage);
- manager.Subscribe<SteamUser.LoggedOnCallback>((cb) => Launch());
- manager.Subscribe<SteamUser.LoggedOffCallback>((cb) => Stop($"Logged off: {cb.Result}"));
- manager.Subscribe<SteamClient.DisconnectedCallback>((cb) => Stop($"Disconnected: UI[{cb.UserInitiated}]"));
- manager.Subscribe<SteamUser.AccountInfoCallback>(async (cb) => await steamFriends.SetPersonaState(EPersonaState.Online));
- if (autoStart)
- Start();
- }
- public void Start() {
- Console.WriteLine("Connecting to Steam...");
- isRunning = true;
- steamClient.Connect();
- while (isRunning)
- manager.RunWaitCallbacks(TimeSpan.FromSeconds(5));
- Console.WriteLine("Ended");
- Console.ReadKey();
- }
- public void OnMessage(SteamGameCoordinator.MessageCallback callback) {
- Console.WriteLine($"Msg: {callback.AppID} {callback.EMsg} {callback.Message}");
- switch (callback.EMsg) {
- // case (uint) EGCBaseClientMsg.k_EMsgGCClientConnectionStatus: useless
- case (uint) ECsgoGCMsg.k_EMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse:
- var msg = new ClientGCMsgProtobuf<CMsgGCCStrike15_v2_Client2GCEconPreviewDataBlockResponse>(callback.Message);
- Console.WriteLine($"Got skin: ASSETID[{msg.Body.iteminfo.itemid}]");
- break;
- }
- }
- public void Launch() {
- Console.WriteLine("Launching the game");
- var playGame = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);
- playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = APP_ID });
- steamClient.Send(playGame);
- Thread.Sleep(550);
- isReady = true;
- test = new Test { steamGC = steamGC };
- test.Start();
- new string[] {
- "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M624118688564276523A5408039791D19281346927938555",
- "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198105687636A3173070464D2334815196074989997",
- "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198105687636A3172915484D2334815196074989997",
- "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198105687636A4059023842D14448148361047816919",
- "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198105687636A4068938673D9838858901213249043"
- }.ToList().ForEach(s => test.Append(InspectItem.FromLink(s)));
- }
- public bool canCheck() => isRunning && isReady;
- public bool Stop(object Message) {
- Console.WriteLine(Message);
- return isRunning = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement