Skip to content

Commit

Permalink
Skip Game.Player.Money completely
Browse files Browse the repository at this point in the history
  • Loading branch information
justalemon committed Apr 26, 2021
1 parent 6a0c244 commit 207e43c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 42 deletions.
48 changes: 8 additions & 40 deletions PlayerCompanion.RuntimePatching/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ internal static class MoneyGetterPatch2
{
public static bool Prefix(ref int __result)
{
switch ((SHVDN2::GTA.Native.PedHash)SHVDN2::GTA.Game.Player.Character.Model)
{
case SHVDN2::GTA.Native.PedHash.Michael:
case SHVDN2::GTA.Native.PedHash.Franklin:
case SHVDN2::GTA.Native.PedHash.Trevor:
return true;
default:
__result = Companion.Wallet.Money;
return false;
}
__result = Companion.Wallet.Money;
return false;
}
}

Expand All @@ -37,16 +29,8 @@ internal static class MoneySetterPatch2
{
public static bool Prefix(ref int value)
{
switch ((SHVDN2::GTA.Native.PedHash)SHVDN2::GTA.Game.Player.Character.Model)
{
case SHVDN2::GTA.Native.PedHash.Michael:
case SHVDN2::GTA.Native.PedHash.Franklin:
case SHVDN2::GTA.Native.PedHash.Trevor:
return true;
default:
Companion.Wallet.Money = value;
return false;
}
Companion.Wallet.Money = value;
return false;
}
}

Expand All @@ -63,16 +47,8 @@ internal static class MoneyGetterPatch3
{
public static bool Prefix(ref int __result)
{
switch ((SHVDN3::GTA.PedHash)SHVDN3::GTA.Game.Player.Character.Model)
{
case SHVDN3::GTA.PedHash.Michael:
case SHVDN3::GTA.PedHash.Franklin:
case SHVDN3::GTA.PedHash.Trevor:
return true;
default:
__result = Companion.Wallet.Money;
return false;
}
__result = Companion.Wallet.Money;
return false;
}
}

Expand All @@ -85,16 +61,8 @@ internal static class MoneySetterPatch3
{
public static bool Prefix(ref int value)
{
switch ((SHVDN3::GTA.PedHash)SHVDN3::GTA.Game.Player.Character.Model)
{
case SHVDN3::GTA.PedHash.Michael:
case SHVDN3::GTA.PedHash.Franklin:
case SHVDN3::GTA.PedHash.Trevor:
return true;
default:
Companion.Wallet.Money = value;
return false;
}
Companion.Wallet.Money = value;
return false;
}
}

Expand Down
1 change: 1 addition & 0 deletions PlayerCompanion/PlayerCompanion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en-US</NeutralLanguage>
<PackageOutputPath>..\bin\$(Configuration)</PackageOutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down
37 changes: 35 additions & 2 deletions PlayerCompanion/Wallet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GTA;
using GTA.Native;
using GTA.UI;
using Newtonsoft.Json;
using System;
Expand Down Expand Up @@ -40,7 +41,26 @@ public int this[Model model]
{
if (model == PedHash.Michael || model == PedHash.Franklin || model == PedHash.Trevor)
{
return Game.Player.Money;
int stat = 0;
switch ((PedHash)model)
{
case PedHash.Michael:
stat = Game.GenerateHash("SP0_TOTAL_CASH");
break;
case PedHash.Franklin:
stat = Game.GenerateHash("SP1_TOTAL_CASH");
break;
case PedHash.Trevor:
stat = Game.GenerateHash("SP2_TOTAL_CASH");
break;
}

int result = 0;
unsafe
{
Function.Call(Hash.STAT_GET_INT, stat, &result, -1);
}
return result;
}
else
{
Expand All @@ -64,7 +84,20 @@ public int this[Model model]

if (model == PedHash.Michael || model == PedHash.Franklin || model == PedHash.Franklin)
{
Game.Player.Money = value;
int stat = 0;
switch ((PedHash)model)
{
case PedHash.Michael:
stat = Game.GenerateHash("SP0_TOTAL_CASH");
break;
case PedHash.Franklin:
stat = Game.GenerateHash("SP1_TOTAL_CASH");
break;
case PedHash.Trevor:
stat = Game.GenerateHash("SP2_TOTAL_CASH");
break;
}
Function.Call(Hash.STAT_SET_INT, stat, value, 1);
}
else
{
Expand Down

0 comments on commit 207e43c

Please sign in to comment.