Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
implement russian roulette mode
Browse files Browse the repository at this point in the history
  • Loading branch information
keoy7am committed Nov 22, 2019
1 parent cd1b83e commit 8bdc07d
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 28 deletions.
23 changes: 23 additions & 0 deletions GTA5 Casino Helper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll</HintPath>
Expand Down Expand Up @@ -88,6 +110,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="MemoryHelper.cs" />
<Compile Include="SimulateHelper.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
6 changes: 6 additions & 0 deletions GTA5 Casino Helper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|x64.ActiveCfg = Debug|x64
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|x64.Build.0 = Debug|x64
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|x86.ActiveCfg = Debug|x86
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Debug|x86.Build.0 = Debug|x86
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|Any CPU.Build.0 = Release|Any CPU
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|x64.ActiveCfg = Release|x64
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|x64.Build.0 = Release|x64
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|x86.ActiveCfg = Release|x86
{0F56EDA9-CF7F-4C49-A67B-3FCD434D4902}.Release|x86.Build.0 = Release|x86
EndGlobalSection
Expand Down
172 changes: 146 additions & 26 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
using Process.NET.Memory;
using SysProcess = System.Diagnostics.Process;
using keyTypes = Process.NET.Native.Types.Keys;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Threading;

namespace GTA5_Casino_Helper
{
Expand All @@ -27,17 +30,41 @@ namespace GTA5_Casino_Helper
public partial class MainWindow : MetroWindow
{
// TODO Log
// TODO Implement Russian Roulette Mode
// TODO Hotkey
SysProcess _process { get; set; }
ProcessSharp _sharp { get; set; }
bool isHB_Running = false;
bool isBR_Running = false;
bool isRR_Running = false;
static readonly IntPtr[] RR_BettingAmout_Offsets =
{
(IntPtr)0x028AA178,
(IntPtr)0x28,
(IntPtr)0x48,
(IntPtr)0x120,
(IntPtr)0xA8,
(IntPtr)0x58,
(IntPtr)0x108,
(IntPtr)0x34
};
static readonly IntPtr[] RR_BettingNumber_Offsets =
{
(IntPtr)0x02E18A88,
(IntPtr)0x08,
(IntPtr)0x298,
(IntPtr)0x10,
(IntPtr)0x108,
(IntPtr)0x4D0
};
Thread RRWorkerThread;
public MainWindow()
{
InitializeComponent();
}

RRWorkerThread = new Thread(RRWorker);
RRWorkerThread.IsBackground = true;
RRWorkerThread.Start();
}
#region Event
private async void StatusBar_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
try
Expand All @@ -57,22 +84,125 @@ private async void StatusBar_PreviewMouseDown(object sender, MouseButtonEventArg
}
private async void btn_EarnMoneyByHB_Click(object sender, RoutedEventArgs e)
{
if (isBR_Running)
try
{
#region oooo
if (isRR_Running)
{
MessageBox.Show("You are running russian roulette now.");
return;
}


if (isHB_Running)
{
await SetStatus("關閉自動下注");
isHB_Running = false;
}
else
{
await SetStatus("啟用自動下注");
isHB_Running = true;
}
#endregion
await HR_ClickBet();
}
catch (Exception ex)
{
MessageBox.Show("You are running russian roulette now.");
return;
MessageBox.Show($"{ex.Message}");
}
await HR_ClickBet();

}
private void btn_EarnMoneyByRR_Click(object sender, RoutedEventArgs e)
private async void btn_EarnMoneyByRR_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Non-Support Now.");
if (isHB_Running)
try
{
#region oooo
if (isHB_Running)
{
MessageBox.Show("You are running horse betting now.");
return;
}


if (isRR_Running)
{
await SetStatus("關閉自動下注");
isRR_Running = false;
}
else
{
await SetStatus("啟用自動下注");
isRR_Running = true;
}
#endregion
await SetStatus("已鎖定俄羅斯輪盤出 0 , 下 0 金額為 50000。");
isRR_Running = true;
}
catch (Exception ex)
{
MessageBox.Show("You are running horse betting now.");
return;
MessageBox.Show($"{ex.Message}");
}
}
#endregion
#region RR
private async void RRWorker()
{
while (true)
{
try
{
if (!isRR_Running)
{
Thread.Sleep(TimeSpan.FromSeconds(5));
continue;
}
SetBettingAmount();
SetBettingNumber();
}
catch (Exception ex)
{
await SetStatus($"RRWorker() => {ex.Message}");
MessageBox.Show($"自動下注已停止,錯誤如下:\n{ex.Message}");
isRR_Running = false;
}
finally
{
Thread.Sleep(TimeSpan.FromMilliseconds(250));
}
}
}
private void SetBettingAmount()
{
try
{
IntPtr bettingAmountPtr = MemoryHelper.GetPtr(_process, RR_BettingAmout_Offsets, true);
byte[] bettingAmount = BitConverter.GetBytes(50000);

_sharp.Memory = new ExternalProcessMemory(_sharp.Handle);
_sharp.Memory.Write((IntPtr)bettingAmountPtr, bettingAmount);
}
catch (Exception ex)
{
throw new Exception($"SetBettingAmount():{ex.Message}");
}
}
private void SetBettingNumber()
{
try
{
IntPtr bettingNumberPtr = MemoryHelper.GetPtr(_process, RR_BettingNumber_Offsets, true);
byte[] bettingNumber = BitConverter.GetBytes(0);

_sharp.Memory = new ExternalProcessMemory(_sharp.Handle);
_sharp.Memory.Write((IntPtr)bettingNumberPtr, bettingNumber);
}
catch (Exception ex)
{
throw new Exception($"SetBettingNumber():{ex.Message}");
}
}
#endregion
private async Task SetUIAsync(bool enable)
{
try
Expand All @@ -84,7 +214,7 @@ await this.Dispatcher.BeginInvoke(new Action(() =>
StatusBar.Text = "Status:Game Detected!";
StatusBar.IsEnabled = false;
btn_EarnMoneyByHB.IsEnabled = true;
btn_EarnMoneyByBR.IsEnabled = true;
btn_EarnMoneyByRR.IsEnabled = true;
}));
}
else
Expand All @@ -94,7 +224,7 @@ await this.Dispatcher.BeginInvoke(new Action(() =>
StatusBar.Text = "Status:Game Detected!";
StatusBar.IsEnabled = true;
btn_EarnMoneyByHB.IsEnabled = false;
btn_EarnMoneyByBR.IsEnabled = false;
btn_EarnMoneyByRR.IsEnabled = false;
}));
}
}
Expand All @@ -120,16 +250,6 @@ await this.StatusBar.Dispatcher.BeginInvoke(new Action(() =>
private async Task HR_ClickBet()
{
var window = _sharp.WindowFactory.MainWindow;
if (isHB_Running)
{
await SetStatus("關閉自動下注");
isHB_Running = false;
}
else
{
await SetStatus("啟用自動下注");
isHB_Running = true;
}
while (isHB_Running)
{
// TODO 寫成Action
Expand Down Expand Up @@ -168,10 +288,10 @@ private async Task HR_ClickBet()
window.Mouse.MoveTo(950, 1010);
SimulateHelper.LeftClick(950, 1010);

for(int i = 500; i > 0; i--)
for (int i = 500; i > 0; i--)
{
await Task.Delay(1);
await SetStatus($"將在 {i/100} 秒後重新執行下注");
await SetStatus($"將在 {i / 100} 秒後重新執行下注");
if (!isHB_Running)
{
await SetStatus($"結束。");
Expand Down
Loading

0 comments on commit 8bdc07d

Please sign in to comment.