After hours of experimenting the code finally works
The problem was the hash value. It was always empty so I put the hash value directly as a argument.
For those who want to know how to add cash to the player, here's an example:
public void moneyfunction ( ){
if (Game.IsKeyDown(Keys.Left)) {
NativePointer nativePointer = new NativePointer();
int money = 0;
NativeFunction.Natives.STAT_GET_INT(0x324C31D, nativePointer, -1); // SP0_TATAL_CASH = 0x324C31D Michael's Cash
nativePointer.SetValue(nativePointer.GetValue<int>() + 2000); // Cash value + 2000
NativeFunction.Natives.STAT_SET_INT<int>(0x324C31D, nativePointer.GetValue<int>(), -1); // Add 2000$
}
}
I know this code needs to be optimized but it will do for now
Thank you very much for your help, without your help I would never find it out