tfalmeida91 1 Posted April 1, 2021 Share Posted April 1, 2021 Hello everyone, I've successfuly managed to spawn object in the game, although I would need to store it in C# to be able to handle them, rotate them and such. But the thing is that Rage Plugin Hook for RDR2 has no such variables that I could use to store them, and whenever I try to store them to a normal c# object, it throws an error. I call this native "CREATE_OBJECT" (0x509D5878EB39E842), like this: Game.CallNative(0x509D5878EB39E842, "P_GEN_POSTERWANTED05X".HashCode(), PlayerPed.Position.X, PlayerPed.Position.Y, PlayerPed.Position.Z, false, false, true, false, false); But just as the NativeDB states, this native returns a Type "Object". So I would have to use: Some_var_Type _object = Game.CallNative<Some_var_Type>(0x509D5878EB39E842, "P_GEN_POSTERWANTED05X".HashCode(), PlayerPed.Position.X, PlayerPed.Position.Y, PlayerPed.Position.Z, false, false, true, false, false); to store it. Everytime I try to create it like this: object _object = Game.CallNative<object>(0x509D5878EB39E842, "P_GEN_POSTERWANTED05X".HashCode(), TfaRageUtils.PlayerPed.Position.X, TfaRageUtils.PlayerPed.Position.Y, TfaRageUtils.PlayerPed.Position.Z, false, false, true, false, false); it throws the following error: System.ArgumentException: The specified structure must allow representation by bits / bytes or have schema information. With code: -2147024809 How can I manage this? Or is it currently impossible? Thank you in advance! Quote Link to comment Share on other sites More sharing options...
LMS 674 Posted April 1, 2021 Share Posted April 1, 2021 Game entities are of a handle type which is a 4 byte value. You could use an unsigned integer in C# to represent that. Note that you do not need to do that when using built-in RPH functions to create peds, vehicles, props etc. but only when manually invoking natives. To convert a handle to its RPH representation, you can use World.GetEntityByHandle. 2 Quote Link to comment Share on other sites More sharing options...
tfalmeida91 1 Posted April 1, 2021 Author Share Posted April 1, 2021 3 hours ago, LMS said: Game entities are of a handle type which is a 4 byte value. You could use an unsigned integer in C# to represent that. Note that you do not need to do that when using built-in RPH functions to create peds, vehicles, props etc. but only when manually invoking natives. To convert a handle to its RPH representation, you can use World.GetEntityByHandle. Hi LMS, thank you very much for your answer! I ended up finding out how to do what I wanted. So basicaly, as stated in the NativeDB, "CREATE_OBJECT" (0x509D5878EB39E842) returns an object of type Object, which in Rage is represented by Prop type. You can indeed get the spawned Handle by using Dynamic Native Call, just like this: Prop _prop = Game.Natives.x509D5878EB39E842<Prop>(_objectNameString.HashCode(), _position.X, _position.Y, _position.Z, false, true, true, false, false); After atributting the newly returned Object to the Type Prop, you can do anything you wish with it! Best regards! 😄 1 Quote Link to comment Share on other sites More sharing options...
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.