Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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

VB.NET get model name from hash


qiangqiang101
 Share

Recommended Posts

qiangqiang101

How to convert Hash to Model?

for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder"

Edited by qiangqiang101
Link to comment
Share on other sites

I asked a similar question a while back, and the answer was that it's not possible. You could make a switch case (select case in vb.net I think) statement that checks if the hash equals each model hash then returns a string.

 

Refer to gtaVmod's post.

 

||

V

Edited by LetsPlayOrDy
Link to comment
Share on other sites

qiangqiang101

i found a code, but its not working on VB.NET

 

C#

((VehicleHash)player.Character.CurrentVehicle.Model.Hash).ToString()
Link to comment
Share on other sites

 

i found a code, but its not working on VB.NET

 

C#

((VehicleHash)player.Character.CurrentVehicle.Model.Hash).ToString()

ToString() only represents the hash as string that you can use to draw a text or something. There is no real conversion.

Link to comment
Share on other sites

How to convert Hash to Model?

for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder"

 

GET_DISPLAY_NAME_FROM_VEHICLE_MODEL
Link to comment
Share on other sites

qiangqiang101

 

How to convert Hash to Model?

for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder"

 

GET_DISPLAY_NAME_FROM_VEHICLE_MODEL

 

this is not what i want,

I call Native.Function.Call(Of String)(Hash.GET_DISPLAY_NAME_FROM_VEHICLE_MODEL, playerPed.CurrentVehicle.Model)

returns SCHAFTER, but the Model Name suppose to be SCHAFTER2

Link to comment
Share on other sites

I found a way but you need to convert the "hash" first from int32 to uint32.

(Maybe not the best solution but it worked. I tried it with the Schafter2)



<StructLayout(LayoutKind.Explicit)>
Public Structure UnionInt32
<FieldOffset(0)>
Public IntValue As Int32
<FieldOffset(0)>
Public UIntValue As UInt32
End Structure

'Define two arrays. First Contains all the names inside the VehicleHash Enum
Dim VhNames As Array = GTA.Native.VehicleHash.GetNames(GetType(VehicleHash))
'The other one contains the hashcodes.
Dim VhHash As Array = GTA.Native.VehicleHash.GetValues(GetType(VehicleHash))

'Define an Int32 variable
Dim tmpUint As UnionInt32
'and assign the vehicle hash to it
tmpUint.IntValue = Game.Player.Character.Currentvehicle.Model.Hash
'Then define an UInt32 variable and assign the converted hashcode to it
Dim UIntVal As UInt32 = tmpUint.UIntValue

'After this go through the VhHash array
for i = 0 to ubound(VhHash)
'and ask if the converted hashcode equals to one of the entries in vhhash
if VhHash(i) = UIntVal. then
'Then do whatever you want. I tested it with notifying me with the name.
ui.notify(VhNames(i))
exit for
end if
next




Edited by Cr1TiKa7
  • Like 1
Link to comment
Share on other sites

qiangqiang101

 

I found a way but you need to convert the "hash" first from int32 to uint32.
(Maybe not the best solution but it worked. I tried it with the Schafter2)
<StructLayout(LayoutKind.Explicit)>    Public Structure UnionInt32    <FieldOffset(0)>    Public IntValue As Int32    <FieldOffset(0)>    Public UIntValue As UInt32End Structure'Define two arrays. First Contains all the names inside the VehicleHash EnumDim VhNames As Array = GTA.Native.VehicleHash.GetNames(GetType(VehicleHash))'The other one contains the hashcodes.Dim VhHash As Array = GTA.Native.VehicleHash.GetValues(GetType(VehicleHash))'Define an Int32 variableDim tmpUint As UnionInt32'and assign the vehicle hash to ittmpUint.IntValue = Game.Player.Character.Currentvehicle.Model.Hash'Then define an UInt32 variable and assign the converted hashcode to itDim UIntVal As UInt32 = tmpUint.UIntValue'After this go through the VhHash arrayfor i = 0 to ubound(VhHash)    'and ask if the converted hashcode equals to one of the entries in vhhash    if VhHash(i) = UIntVal. then        'Then do whatever you want. I tested it with notifying me with the name.        ui.notify(VhNames(i))        exit for    end ifnext

 

its working, thx alot (but just few vehicle like low rider dlc and halloween surprise dlc return empty string)

Link to comment
Share on other sites

the reason for the empty strings is because the developer of scripthookvnet hasnt added the hashes for the cars. but you can easily edit the source for it.

If you downloaded the source you can edit the VehicleHashes.hpp

You just need to add the following lines to it:

'Lowrider DLC VehiclesFaction2 = 0x95466bdb,Faction3 = 0x866bce26,Moonbeam2 = 0x710a2b9b,Primo2 = 0x86618eda,Sabregt2 = 0x0d4ea603,Virgo2 = 0xca62927a,Virgo3 = 0x00fdffb0,Chino2 = 0xaed64a63,Buccaneer2 = 0xc397f748,Tornado5 = 0x94da98ef,Slamvan3 = 0x42bc5e19,'Halloween DLC VehiclesBtype2 = 0xCE6B35A4,Lurcher = 0x7B47A6A7,
Edited by Cr1TiKa7
Link to comment
Share on other sites

  • 2 weeks later...

 

How to convert Hash to Model?

for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder"

 

GET_DISPLAY_NAME_FROM_VEHICLE_MODEL

 

 

OK i found a (native) way to display full vehicle name, but anyway it requires a table/switch, this is how carmod_shop.c4 do it:

                UI::_SET_TEXT_ENTRY("TWOSTRINGS");                UI::_ADD_TEXT_COMPONENT_ITEM_STRING(sub_7f47f(ENTITY::GET_ENTITY_MODEL());                UI::_ADD_TEXT_COMPONENT_ITEM_STRING(VEHICLE::GET_DISPLAY_NAME_FROM_VEHICLE_MODEL());

where sub_7f47f() is a huge switch (look at the sources yourself).

 

Anybody want to convert sub_7f47f() to a compilable C code?

Edited by gtaVmod
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.