TuffyTown
Recognized Creator-
Posts
31 -
Joined
-
Last visited
-
Days Won
8
TuffyTown last won the day on July 23
TuffyTown had the most liked content!
Personal Information
-
Country
United States
-
Gender
Male
Recent Profile Visitors
8,611 profile views
TuffyTown's Achievements
Bandit (2/10)
23
Reputation
-
c++ Adding/Removing Items To Inventory Using Natives
TuffyTown posted a topic in RDR2 Mods Discussion
Adding items to the player inventory is kinda hard, so I decided to tell everyone how to do it since I know a lot of people don't know how. These are the basics. The functions are basically taken right from the game scripts, but I have modified them to be more simplified. First you need to add these structures. Note that script struct and array variables are aligned to 8 bytes. struct sGuid { alignas(8) int data1; alignas(8) int data2; alignas(8) int data3; alignas(8) int data4; }; struct sSlotInfo { alignas(8) sGuid guid; alignas(8) int f_1; alignas(8) int f_2; alignas(8) int f_3; alignas(8) int slotId; }; struct sItemInfo { alignas(8) int f_0; alignas(8) int f_1; alignas(8) int f_2; alignas(8) int f_3; alignas(8) int f_4; alignas(8) int f_5; alignas(8) int f_6; }; Then you will need to add these functions: // Creates an empty GUID instance sGuid CreateNewGUID() { sGuid guid{}; return guid; } // Gets an item's GUID from the inventory sGuid GetPlayerInventoryItemGUID(u32 item, sGuid guid, u32 slotId) { sGuid outGuid{}; INVENTORY::INVENTORY_GET_GUID_FROM_ITEMID(1, (Any*)&guid, item, slotId, (Any*)&outGuid); return outGuid; } // Gets the players inventory GUID sGuid GetPlayerInventoryGUID() { return GetPlayerInventoryItemGUID(MISC::GET_HASH_KEY("CHARACTER"), CreateNewGUID(), MISC::GET_HASH_KEY("SLOTID_NONE")); } // Gets an item's group hash (eInvItemGroup) u32 GetItemGroup(u32 item) { sItemInfo info{}; if (!ITEMDATABASE::_ITEMDATABASE_IS_KEY_VALID(item, 0)) { return 0; } if (!ITEMDATABASE::ITEMDATABASE_FILLOUT_ITEM_INFO(item, (Any*)&info)) { return 0; } return info.f_2; } // Gets an item's slot info data sSlotInfo GetItemSlotInfo(u32 item) { sSlotInfo slotInfo{}; slotInfo.guid = GetPlayerInventoryGUID(); slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_SATCHEL"); u32 group = GetItemGroup(item); switch (group) { case 0xC2286F01: // CLOTHING if (!INVENTORY::_INVENTORY_FITS_SLOT_ID(item, MISC::GET_HASH_KEY("SLOTID_WARDROBE"))) { slotInfo.guid = GetPlayerInventoryItemGUID(MISC::GET_HASH_KEY("WARDROBE"), slotInfo.guid, MISC::GET_HASH_KEY("SLOTID_WARDROBE")); slotInfo.slotId = INVENTORY::_GET_DEFAULT_ITEM_SLOT_INFO(item, MISC::GET_HASH_KEY("WARDROBE")); } else { slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_WARDROBE"); } break; case 0x95A6F147: // HORSE slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_ACTIVE_HORSE"); break; case 0x80FB92CD: // UPGRADE if (INVENTORY::_INVENTORY_FITS_SLOT_ID(item, MISC::GET_HASH_KEY("SLOTID_UPGRADE"))) { slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_UPGRADE"); } break; default: if (INVENTORY::_INVENTORY_FITS_SLOT_ID(item, MISC::GET_HASH_KEY("SLOTID_SATCHEL"))) { slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_SATCHEL"); } else if (INVENTORY::_INVENTORY_FITS_SLOT_ID(item, MISC::GET_HASH_KEY("SLOTID_WARDROBE"))) { slotInfo.slotId = MISC::GET_HASH_KEY("SLOTID_WARDROBE"); } else { slotInfo.slotId = INVENTORY::_GET_DEFAULT_ITEM_SLOT_INFO(item, MISC::GET_HASH_KEY("CHARACTER")); } break; } return slotInfo; } // Adds an item to the player inventory via GUID bool AddItemWithGUID(u32 item, sGuid &guid, sSlotInfo &slotInfo, u32 quantity, u32 addReason) { if (!INVENTORY::_INVENTORY_IS_GUID_VALID((Any*)&slotInfo.guid)) { return false; } if (!INVENTORY::_INVENTORY_ADD_ITEM_WITH_GUID(1, (Any*)&guid, (Any*)&slotInfo.guid, item, slotInfo.slotId, quantity, addReason)) { return false; } return true; } // Adds an item to the player inventory via hash // This is the main function you will be calling to add items to your inventory bool AddItemToInventory(u32 item, u32 quantity) { sSlotInfo slotInfo = GetItemSlotInfo(item); sGuid guid = GetPlayerInventoryItemGUID(item, slotInfo.guid, slotInfo.slotId); return AddItemWithGUID(item, guid, slotInfo, quantity, MISC::GET_HASH_KEY("ADD_REASON_DEFAULT")); } Now to actually add an item to the player inventory, all you need to call is AddItemToInventory() Like so: AddItemToInventory(MISC::GET_HASH_KEY("CONSUMABLE_CORNEDBEEF_CAN"), 1); AddItemToInventory(MISC::GET_HASH_KEY("PROVISION_TALISMAN_BUFFALO_HORN"), 1); // etc To remove an item from the player inventory is way easier and can be done with a single native call: INVENTORY::_INVENTORY_REMOVE_INVENTORY_ITEM_WITH_ITEMID(1, MISC::GET_HASH_KEY("CONSUMABLE_CORNEDBEEF_CAN"), 1, MISC::GET_HASH_KEY("REMOVE_REASON_DEFAULT")); And that's how you add/remove items from the player inventory. Any questions, ask me and I'll try to answer them. -
csharp ScriptHookRDR2DotNet (C#) is being updated again
TuffyTown replied to TuffyTown's topic in Community ScripthookRDR2.NET
@HughJanus The Euphoria stuff is a complete mystery to me. Not sure why it's even there. I haven't touched any of it except changing native calls. I've looked at the code serveral times and it all seems pointless to me. I'm honestly not sure how it even works, but I kept it because some people probably use it. If you need to do things with ragdolls, there are certain natives that can mess with that. If you need to change specific behaviors, then you'll probably need to do file editing with LML.- 5 replies
-
- modding resource
- scripting
-
(and 2 more)
Tagged with:
-
csharp ScriptHookRDR2DotNet (C#) is being updated again
TuffyTown replied to TuffyTown's topic in Community ScripthookRDR2.NET
I personally have not experienced this, but I am almost certain that this is still an issue as the DllMain.cpp files are basically the exact same. I will look into this, but there is no guarantees that I can fix it, but I will try.- 5 replies
-
- modding resource
- scripting
-
(and 2 more)
Tagged with:
-
Since the original C# script hook hasn't been updated in almost 3 years, I decided to make my own fork of the project and start updating it again. I've already made many great improvements and additions to the new version, including a new native calling system that removes the need to use Function.Call(). Credits go to Satlyq for the original ScriptHookRDR2DotNet implementation You can find the project here: https://github.com/Halen84/ScriptHookRDR2DotNet-V2 You can download the latest version here: https://github.com/Halen84/ScriptHookRDR2DotNet-V2/releases/latest You can find all releases here: https://github.com/Halen84/ScriptHookRDR2DotNet-V2/releases/ If you would like to create mods with this version of ScriptHookRDR2DotNet (ScriptHookRDR2DotNet V2), please follow this guide posted by Mooshe. Notes: - Old mods that use ScriptHookRDR2DotNet will NOT be compatible with this version - The following tutorial is a little outdated, but the steps are almost all the same. The code that he uses is outdated.
- 5 replies
-
- 1
-
- modding resource
- scripting
-
(and 2 more)
Tagged with:
-
Which Scripthook Vers for build "1436.28"
TuffyTown replied to veryrareflicks's topic in RDR2 Mods Discussion
just update the game and version.dll -
How can I determine the movement set of a ped?
TuffyTown replied to HughJanus's topic in RDR2 Mods Discussion
You can check if a ped is bleeding out via IS_PED_IN_WRITHE(Ped ped) -
There is already a mod for this https://www.nexusmods.com/reddeadredemption2/mods/1209 A quick google search is all it takes...
-
-
-
What NativeUI are you talking about? ScriptHookDotNet hasnt been updated in years so you probably shouldnt use it anymore. If you want to make mods, you should probably learn C++
-
question How to Decompile Native Functions?
TuffyTown replied to WesternGamer's topic in RDR2 Mods Discussion
-
Here is a simple list of keycodes 8 backspace 9 tab 13 enter 16 shift 17 ctrl 18 alt 19 pause/break 20 caps lock 27 escape 32 (space) 33 page up 34 page down 35 end 36 home 37 left arrow 38 up arrow 39 right arrow 40 down arrow 45 insert 46 delete 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 65 a 66 b 67 c 68 d 69 e 70 f 71 g 72 h 73 i 74 j 75 k 76 l 77 m 78 n 79 o 80 p 81 q 82 r 83 s 84 t 85 u 86 v 87 w 88 x 89 y 90 z 91 left window key 92 right window key 93 select key 96 numpad 0 97 numpad 1 98 numpad 2 99 numpad 3 100 numpad 4 101 numpad 5 102 numpad 6 103 numpad 7 104 numpad 8 105 numpad 9 106 multiply 107 add 109 subtract 110 decimal point 111 divide 112 f1 113 f2 114 f3 115 f4 116 f5 117 f6 118 f7 119 f8 120 f9 121 f10 122 f11 123 f12 144 num lock 145 scroll lock 186 semi-colon 187 equal sign 188 comma 189 dash 190 period 191 forward slash 192 grave accent 219 open bracket 220 back slash 221 close braket 222 single quote
-
-
All of these are already documented on femga's repo
-