Log in to reply
 

Can someone help me to _GET_PED_HEAD_BLEND_DATA in C# ?



  • I need to find out the way to get freemode characters head blend data to improve my BuddyControl script.Does anyone now how to work with struct in C# ? I just can't get it work.



  • I don't know about C# but:

    [StructLayout(LayoutKind.Explicit, Size = 80)]
    public struct HeadBlendData {
    	[FieldOffset(0)]
    	public int shapeFirstID;
    	[FieldOffset(8)]
    	public int shapeSecondID;
    	[FieldOffset(16)]
    	public int shapeThirdID;
    	[FieldOffset(24)]
    	public int skinFirstID;
    	[FieldOffset(32)]
    	public int skinSecondID;
    	[FieldOffset(40)]
    	public int skinThirdID;
    	[FieldOffset(48)]
    	public float shapeMix;
    	[FieldOffset(56)]
    	public float skinMix;
    	[FieldOffset(64)]
    	public float thirdMix;
    	[FieldOffset(75)]
    	public bool isParent;
    }
    
    public static class HeadBlend {
    	public static HeadBlendData GetDataFromPed(Ped p) {
    		HeadBlendData result;
    		unsafe
    		{
    			Native.Function.Call(Native.Hash._GET_PED_HEAD_BLEND_DATA, p.Handle, &result);
    		}
    		return result;
    	}
    }
    


  • @MAFINS Thanks for you answer, bro i'm trying to get it work on vb.net but log shows:

    [20:04:42] [ERROR] Caught fatal unhandled exception:
    System.InvalidCastException: Unable to cast object of type 'Avatar.Krlos_Rokr_Avatar+HeadBlendData' to native value
    en GTA.Native.?A0x55605b1d.ObjectToNative(Object value)
    en GTA.Native.InputArgument..ctor(Object value)
    en Avatar.Krlos_Rokr_Avatar.Get_Head_Blend_Data(Ped Ped, HeadBlendData DataStructure)

    Public Structure HeadBlendData
        Public shapeFirstID As Integer
        Public shapeSecondID As Integer
        Public shapeThirdID As Integer
        Public skinFirstID As Integer
        Public skinSecondID As Integer
        Public skinThirdID As Integer
        Public shapeMix As Single
        Public skinMix As Single
        Public thirdMix As Single
        Public IsParent As Boolean
    End Structure
    
    Sub Get_Head_Blend_Data(Ped As GTA.Ped, DataStructure As HeadBlendData)
        Native.Function.Call(Native.Hash._GET_PED_HEAD_BLEND_DATA, Ped.Handle , New Native.InputArgument(DataStructure))
        UI.Notify("Shape First: " & DataStructure.shapeFirstID.ToString)
    End Sub
    
            If Game.IsControlJustPressed(0, GTA.Control.Reload) = True Then
                Dim HBD As New HeadBlendData
                Get_Head_Blend_Data(Game.Player.Character, HBD)
            End If

  • MODERATOR

    @Krlos_Rokr Afaik VB does not support pointers, which Mafins' code uses. You would have to use an OutputArgument instead, like this (untested):

    Public Shared Function GetDataFromPed(ByVal p As Ped) As HeadBlendData
    	Dim outResult As OutputArgument = New OutputArgument()
    	Function.Call(Hash._GET_PED_HEAD_BLEND_DATA, p.Handle, outResult)
    	Return outResult.GetResult(Of HeadBlendData)()
    End Function


  • @Jitnaught Thanks for answered my friend, but still doesn't work :/, which is that language?


  • MODERATOR

    @Krlos_Rokr Sorry? The code I posted is VB .NET, and OutputArgument is apart of Script Hook V .NET.



  • @Krlos_Rokr Don't forget the alignment to 8 bytes or add 4 byte padding after every var
    And make the last one an int instead of a bool



  • @Jitnaught i meant programming language MAFINS uses jejej, thanks 😎.
    @MAFINS thanks man. I'll try that way.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.