waynieoaks Posted September 14 Share Posted September 14 (edited) Hi, I have a script that backs up and restores a lot of stuff (vehicle, clothing, weather, time, etc.) but the one thing people keep asking for is the ability to backup and restore the ped they are using. I backup the ped, components and props to an xml file and then read that to restore. https://github.com/waynieoaks/RecovFR On restore, certain peds will be invisible. e.g. mp_m_execpa_01 Am I missing something in my capture / restore that means these certain peds become invisible? I have tried (in Rage Plugin Hook): Game.LocalPlayer.Model = (string)GetElements.Element("MyModel"); As well as the native: NativeFunction.Natives.SetPlayerModel(Game.LocalPlayer, Game.GetHashKey((string)GetElements.Element("MyModel"))); Most work fine, just some of them come in invisible. I would also like to try to capture and restore mp_freemode models but cannot seem to find any way to capture things like the heritage, nose, mouth, eyes, etc to rebuild them. Does anybody know what I am doing wrong that makes certain ones invisible? I currently rebuild the components and props like this: try { ////// RESTORE COMPONENTS //////////////////////////////////////////////////////////// IEnumerable<XElement> MyComponentElements = xdocument.Descendants("MyComponentElements"); foreach (XElement GetElements in MyComponentElements.Elements()) { int GetComponentId = Int16.Parse(GetElements.Attribute("ComponentId").Value); NativeFunction.Natives.SET_PED_COMPONENT_VARIATION(EntryPoint.MyPed, Int16.Parse(GetElements.Attribute("ComponentId").Value), Int16.Parse(GetElements.Attribute("DrawableId").Value), Int16.Parse(GetElements.Attribute("TextureId").Value), Int16.Parse(GetElements.Attribute("PaleteId").Value)); } } catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring character components"); } try { ////// RESTORE PROPS //////////////////////////////////////////////////////////// IEnumerable<XElement> MyPropElements = xdocument.Descendants("MyPropElements"); foreach (XElement GetElements in MyPropElements.Elements()) { int GetComponentId = Int16.Parse(GetElements.Attribute("ComponentId").Value); NativeFunction.Natives.SET_PED_PROP_INDEX(EntryPoint.MyPed, Int16.Parse(GetElements.Attribute("ComponentId").Value), Int16.Parse(GetElements.Attribute("DrawableId").Value), Int16.Parse(GetElements.Attribute("TextureId").Value), Int16.Parse(GetElements.Attribute("PaleteId").Value)); } } catch (Exception e) { EntryPoint.ErrorLogger(e, "Restore", "Error restoring character props"); } And the underlying XML looks like this: <MyPedElements> <MyModel>MP_M_FREEMODE_01</MyModel> <MyLocX>-560.7261</MyLocX> <MyLocY>-141.4154</MyLocY> <MyLocZ>38.36947</MyLocZ> <MyLocH>204.1337</MyLocH> <MyWanted>0</MyWanted> <MyHealth>200</MyHealth> <MyArmor>25</MyArmor> <MyInvincible>False</MyInvincible> </MyPedElements> <MyComponentElements> <Component ComponentId="0" DrawableId="0" TextureId="0" PaleteId="0" /> <Component ComponentId="1" DrawableId="0" TextureId="0" PaleteId="0" /> <Component ComponentId="2" DrawableId="54" TextureId="0" PaleteId="0" /> <Component ComponentId="3" DrawableId="11" TextureId="0" PaleteId="0" /> <Component ComponentId="4" DrawableId="35" TextureId="0" PaleteId="0" /> <Component ComponentId="5" DrawableId="72" TextureId="0" PaleteId="0" /> <Component ComponentId="6" DrawableId="51" TextureId="0" PaleteId="0" /> <Component ComponentId="7" DrawableId="8" TextureId="0" PaleteId="0" /> <Component ComponentId="8" DrawableId="53" TextureId="0" PaleteId="0" /> <Component ComponentId="9" DrawableId="14" TextureId="0" PaleteId="0" /> <Component ComponentId="10" DrawableId="0" TextureId="0" PaleteId="0" /> <Component ComponentId="11" DrawableId="190" TextureId="13" PaleteId="0" /> </MyComponentElements> <MyPropElements> <Prop ComponentId="0" DrawableId="-1" TextureId="-1" PaleteId="0" /> <Prop ComponentId="1" DrawableId="-1" TextureId="-1" PaleteId="0" /> <Prop ComponentId="2" DrawableId="-1" TextureId="-1" PaleteId="0" /> <Prop ComponentId="3" DrawableId="-1" TextureId="-1" PaleteId="0" /> </MyPropElements> Many thanks. Edited Thursday at 06:56 PM by waynieoaks Marking as solved Link to comment Share on other sites More sharing options...
waynieoaks Posted September 14 Author Share Posted September 14 Even though I searched before posting (I did, honest!) Just think I have found the answer in @CliffHanger's post: By running it like this: Game.LocalPlayer.Model = (string)GetElements.Element("MyModel"); Game.LocalPlayer.Character.ResetVariation(); mp_f_freemode and mp_m_freemode still not restoring components though - if anyone has any ideas what I am doing wrong? Link to comment Share on other sites More sharing options...
waynieoaks Posted September 14 Author Share Posted September 14 OK so for the MP_F_FREEMODE_01 - I have worked out I need to start with GetPedHeadBlendData but have no idea how to pull the data out. https://docs.fivem.net/natives/?_0x2746BD9D88C5C5D0 I put in this public strut: public struct HeadBlendData { public int ShapeFirst; public int ShapeSecond; public int ShapeThird; public int SkinFirst; public int SkinSecond; public int SkinThird; public float ShapeMix; public float SkinMix; public float ThirdMix; } But that is where I get stuck as whatever I do I cannot populate it. Ultimately, I want to export the variables to an xml file so I can restore them later. I have been reading but I will be honest I haven't a clue what I am doing. Link to comment Share on other sites More sharing options...
waynieoaks Posted Thursday at 06:57 PM Author Share Posted Thursday at 06:57 PM Marking as solved (on the invisible ped issue) Will keep trying on the freemode issue and reach out if I still struggle. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now