Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

[SOLVED] C# Switching to some peds makes you invisible


waynieoaks
 Share

Recommended Posts

waynieoaks

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 by waynieoaks
Marking as solved
Link to comment
Share on other sites

waynieoaks

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? 

 

spacer.png

Link to comment
Share on other sites

waynieoaks

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.