Skip to content

Commit

Permalink
Merge pull request #1 from MurkyYT/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
MurkyYT authored May 11, 2023
2 parents 697d85e + 27fe351 commit 0363b30
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 11 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<setting name="saveLogs" serializeAs="String">
<value>False</value>
</setting>
<setting name="ContinueSpraying" serializeAs="String">
<value>False</value>
</setting>
</CSAuto.Properties.Settings>
</userSettings>
</configuration>
5 changes: 2 additions & 3 deletions GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class GameState
public Player Player { get; internal set; }
public Match Match { get; internal set; }
public Round Round { get; internal set; }
private string JSON;
private readonly string JSON;
public GameState(string JSON)
{
if (JSON == null)
Expand Down Expand Up @@ -180,8 +180,7 @@ private int GetRound()
string[] splitted = JSON.Split(new string[] { "\"round\": " }, StringSplitOptions.None);
if (splitted.Length > 1)
{
int res;
bool succes = int.TryParse(splitted[1].Split(',')[0], out res);
bool succes = int.TryParse(splitted[1].Split(',')[0], out int res);
if (succes)
return res;
}
Expand Down
82 changes: 74 additions & 8 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public partial class MainWindow : Window
/// <summary>
/// Constants
/// </summary>
const string VER = "1.1.1";
const string integrationFile = "\"CSAuto Integration v" + VER + "\"\r\n{\r\n\"uri\" \"http://localhost:3000\"\r\n\"timeout\" \"5.0\"\r\n\"buffer\" \"0.1\"\r\n\"throttle\" \"0.5\"\r\n\"heartbeat\" \"10.0\"\r\n\"data\"\r\n{\r\n \"provider\" \"1\"\r\n \"map\" \"1\"\r\n \"round\" \"1\"\r\n \"player_id\" \"1\"\r\n \"player_state\" \"1\"\r\n \"player_weapons\" \"1\"\r\n \"player_match_stats\" \"1\"\r\n \"bomb\" \"1\"\r\n}\r\n}";
const string VER = "1.0.0";
const string PORT = "11523";
const string integrationFile = "\"CSAuto Integration v" + VER + "\"\r\n{\r\n\"uri\" \"http://localhost:"+ PORT+"\"\r\n\"timeout\" \"5.0\"\r\n\"buffer\" \"0.1\"\r\n\"throttle\" \"0.5\"\r\n\"heartbeat\" \"10.0\"\r\n\"data\"\r\n{\r\n \"provider\" \"1\"\r\n \"map\" \"1\"\r\n \"round\" \"1\"\r\n \"player_id\" \"1\"\r\n \"player_state\" \"1\"\r\n \"player_weapons\" \"1\"\r\n \"player_match_stats\" \"1\"\r\n \"bomb\" \"1\"\r\n}\r\n}";
/// <summary>
/// Publics
/// </summary>
Expand All @@ -61,6 +62,7 @@ public partial class MainWindow : Window
readonly MenuItem autoBuyDefuseKit = new MenuItem();
readonly MenuItem preferArmorCheck = new MenuItem();
readonly MenuItem saveLogsCheck = new MenuItem();
readonly MenuItem continueSprayingCheck = new MenuItem();
readonly string integrationPath = null;
/// <summary>
/// Privates
Expand Down Expand Up @@ -107,6 +109,10 @@ public MainWindow()
{
Header = "Debug"
};
MenuItem autoReloadMenu = new MenuItem
{
Header = "Auto Reload"
};
MenuItem exit = new MenuItem
{
Header = "Exit"
Expand All @@ -125,6 +131,10 @@ public MainWindow()
startUpCheck.Header = "Start With Windows";
startUpCheck.IsCheckable = true;
startUpCheck.Click += StartUpCheck_Click;
continueSprayingCheck.IsChecked = Properties.Settings.Default.ContinueSpraying;
continueSprayingCheck.Header = "Continue Spraying (Experimental)";
continueSprayingCheck.IsCheckable = true;
continueSprayingCheck.Click += ContinueSprayingCheck_Click;
saveFramesDebug.IsChecked = Properties.Settings.Default.saveDebugFrames;
saveFramesDebug.Header = "Save Frames";
saveFramesDebug.IsCheckable = true;
Expand All @@ -150,27 +160,38 @@ public MainWindow()
preferArmorCheck.IsCheckable = true;
preferArmorCheck.Click += PreferArmorCheck_Click;
autoReloadCheck.IsChecked = Properties.Settings.Default.autoReload;
autoReloadCheck.Header = "Auto Reload";
autoReloadCheck.Header = "Enabled";
autoReloadCheck.IsCheckable = true;
autoReloadCheck.Click += AutoReloadCheck_Click;
MenuItem checkForUpdates = new MenuItem
{
Header = "Check for updates"
};
checkForUpdates.Click += CheckForUpdates_Click;
debugMenu.Items.Add(saveFramesDebug);
debugMenu.Items.Add(saveLogsCheck);
autoReloadMenu.Items.Add(autoReloadCheck);
autoReloadMenu.Items.Add(continueSprayingCheck);
autoBuyMenu.Items.Add(preferArmorCheck);
autoBuyMenu.Items.Add(autoBuyArmor);
autoBuyMenu.Items.Add(autoBuyDefuseKit);
exitcm.Items.Add(about);
exitcm.Items.Add(debugMenu);
exitcm.Items.Add(new Separator());
exitcm.Items.Add(autoBuyMenu);
exitcm.Items.Add(autoReloadCheck);
exitcm.Items.Add(autoReloadMenu);
exitcm.Items.Add(autoAcceptMatchCheck);
exitcm.Items.Add(startUpCheck);
exitcm.Items.Add(new Separator());
exitcm.Items.Add(checkForUpdates);
exitcm.Items.Add(exit);
Top = -1000;
Left = -1000;
exitcm.StaysOpen = false;
integrationPath = GetCSGODir()+"\\cfg\\gamestate_integration_csauto.cfg";
string csgoDir = GetCSGODir();
if (csgoDir == null)
throw new Exception("Couldn't find CS:GO directory");
integrationPath = csgoDir + "\\cfg\\gamestate_integration_csauto.cfg";
if (!File.Exists(integrationPath))
{
using (FileStream fs = File.Create(integrationPath))
Expand Down Expand Up @@ -201,6 +222,50 @@ public MainWindow()
}
}

private void ContinueSprayingCheck_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.ContinueSpraying = continueSprayingCheck.IsChecked;
Properties.Settings.Default.Save();
}

private void CheckForUpdates_Click(object sender, RoutedEventArgs e)
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
CheckForUpdatesAsync();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
async Task CheckForUpdatesAsync()
{
try
{
System.Net.WebClient client = new System.Net.WebClient() { Encoding = Encoding.UTF8 };
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Log.WriteLine("Checking for updates");
string webInfo = await client.DownloadStringTaskAsync("https://github.com/MurkyYT/CSAuto/releases/latest");
string latestVersion = webInfo.Split(new string[] { "https://github.com/MurkyYT/CSAuto/releases/tag/" }, StringSplitOptions.None)[1].Split('&')[0];
Log.WriteLine($"The latest version is {latestVersion}");
if (latestVersion == VER)
{
Log.WriteLine("Latest version installed");
MessageBox.Show("You have the latest version!", "Check for updates (CSAuto)", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
Log.WriteLine($"Newer version found {VER} --> {latestVersion}");
MessageBoxResult result = MessageBox.Show($"Found newer verison ({latestVersion}) would you like to download it?", "Check for updates (CSAuto)", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result == MessageBoxResult.Yes)
{
Debug.WriteLine("Downloading latest version");
System.Diagnostics.Process.Start("https://github.com/MurkyYT/CSAuto/releases/latest/download/CSAuto.exe");
}
}
}
catch (Exception ex)
{
Log.WriteLine($"Couldn't check for updates - '{ex.Message}'");
MessageBox.Show($"Couldn't check for updates\n'{ex.Message}'", "Check for updates (CSAuto)", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void SaveLogsCheck_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.saveLogs = saveLogsCheck.IsChecked;
Expand Down Expand Up @@ -237,7 +302,7 @@ public bool StartGSIServer()
return false;

_listener = new HttpListener();
_listener.Prefixes.Add("http://localhost:" + "3000" + "/");
_listener.Prefixes.Add("http://localhost:" + PORT + "/");
Thread ListenerThread = new Thread(new ThreadStart(Run));
try
{
Expand Down Expand Up @@ -483,9 +548,10 @@ private void TryToAutoReload()
|| weaponType == WeaponType.MachineGun
|| weaponType == WeaponType.SubmachineGun
|| weaponName == "weapon_cz75a")
&& (weaponName != "weapon_sg556"))
&& (weaponName != "weapon_sg556")
&& Properties.Settings.Default.ContinueSpraying)
{
Thread.Sleep(150);
Thread.Sleep(100);
mouse_event(MOUSEEVENTF_LEFTDOWN,
System.Windows.Forms.Cursor.Position.X,
System.Windows.Forms.Cursor.Position.Y,
Expand Down
12 changes: 12 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
<Setting Name="saveLogs" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ContinueSpraying" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1 align="center">CSAuto</h1>
<p align="center">
<img width="auto" src="https://img.shields.io/github/release-date/murkyyt/csauto?label=Latest%20release" alt="Latest Release">
<img width="auto" src="https://img.shields.io/github/v/tag/murkyyt/csauto?label=Latest%20version" alt="Latest Version">
<img width="auto" src="https://img.shields.io/github/downloads/murkyyt/csauto/total?color=brightgreen&label=Total%20downloads" alt="Total Downloads">
</p>

### [Open Latest Release](https://github.com/MurkyYT/CSAuto/releases/latest).
### [Download Latest Release](https://github.com/MurkyYT/CSAuto/releases/latest/download/CSAuto.exe).
## Description
Have you ever started searching for a game in CS:GO went for a bit, and see that you missed the accept button?
frustrating isn't it?
Or have you ever forgot to buy armor or defuse kit as ct?

*Dont Worry!*
**CSAuto** is the software for you, CSAuto can:
* Auto accept matches for you
* Auto reload for you when you have 0 bullets left and keep spraying after reloading! (continue spraying might lag out trying to find a fix)
* Auto buy armor for you or auto refill it when you have less then 70 left!
* Auto buy defuse kit for you as a CT

**Image demonstration of the menu:**
![right-click-menu](menuimage.png)
Binary file added menuimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0363b30

Please sign in to comment.