SuperNovaXM 1 Posted September 15, 2020 Posted September 15, 2020 (edited) Hi, I'm fairly new to modding in general, but I've followed a few tutorials successfully and now I have some questions. I was trying to use the SET_PED_AMMO native function but when I went to put in the weapon hash it gives me the error: cannot convert from 'RDR2.WeaponHash' to 'RDR2.Native.InputArgument'. I tried constructing an InputArgument using this code, but it crashed my game: var hash = new RDR2.Native.InputArgument(CurrentPlayerWeapon()); //CurrentPlayerWeapon() returns the hash of the weapon currently equipped Function.Call(Hash.SET_PED_AMMO, Game.Player.Character.Handle, hash, 100); If there's better documentation than what little I found, or if there's any other way to do this then do let me know. Edited September 17, 2020 by SuperNovaXM Quote
HughJanus 244 Posted September 15, 2020 Posted September 15, 2020 (edited) Are you using ABs script hook or RPH? Edit: forget what I asked, just saw the forum you posted in. Why dont you try GET_CURRENT_PED_WEAPON and pass the player ped to it? In the parameters you have to pass the variable in which the weapon shall be stored. Something like this should do it: Ped playerPed = PLAYER::PLAYER_PED_ID(); Hash weaponHash = 0; int ammo = 100; WEAPON::GET_CURRENT_PED_WEAPON(playerPed, &weaponHash, false, 0, false); if (weaponHash != 0) WEAPON::SET_PED_AMMO(playerPed, weaponHash, ammo); Edited September 15, 2020 by HughJanus Quote
SuperNovaXM 1 Posted September 15, 2020 Author Posted September 15, 2020 Hmm, it seems like you're using Alexander Blade's c++ scripthook, where I'm using the RDR2.net scripthook api. If I don't find any solutions to my problem then I'll start to look into getting the developing with the AB scripthook, if you have any good resources for starting a project using the AB sdk that would be much appreciated. Quote
HughJanus 244 Posted September 15, 2020 Posted September 15, 2020 The natives should be the same, though :) Quote
SuperNovaXM 1 Posted September 16, 2020 Author Posted September 16, 2020 Thanks for your help, but it turns out I was doing a number of things wrong unrelated to the natives so I'm glad I caught that as well. That said, I have a new issue regarding the natives that ought to modify the player's ammo. I have tried using SET_PED_AMMO, SET_PED_AMMO_BY_TYPE, _ADD_AMMO_TO_PED, and other similar functions and the only two I've actually gotten to work are SET_PED_INFINITE_AMMO which is useless in my case and SET_AMMO_IN_CLIP which isn't robust enough as it only moves stored ammo to and from your gun. I was wondering if I was doing something wrong again or if these functions don't work for the player as I thought they might. Quote
LMS 674 Posted September 18, 2020 Posted September 18, 2020 I tested it as well, and it seems that many of the ammo natives do not work correctly on the player (or at all). For instance, SET_PED_AMMO_BY_TYPE has support to remove ammo and calculates the amount to remove properly, only for the actual call to CPedInventory::RemoveAmmo to ignore the request due to a (wrong?) hardcoded parameter. What has worked for me though was 0xB6CFEC32E3742779 aka _REMOVE_AMMO_FROM_PED_BY_TYPE. Calling it like this to remove one ammo from your revolver (RPH syntax): Game.CallNative(0xB6CFEC32E3742779, Game.LocalPlayer.Character, Game.GetHashKey("AMMO_REVOLVER"), 1, 0x2188E0A3); 1 1 Quote
SuperNovaXM 1 Posted September 18, 2020 Author Posted September 18, 2020 Sweet! This worked perfectly, I can't believe it. Thanks for helping me out so much, I was starting to think it wouldn't be possible! No idea why it didn't work when I tried it, maybe I casted the hash at the end wrong. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.