qiangqiang101 Posted November 21, 2015 Share Posted November 21, 2015 (edited) How to convert Hash to Model? for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder" Edited November 21, 2015 by qiangqiang101 Link to comment Share on other sites More sharing options...
Jitnaught Posted November 21, 2015 Share Posted November 21, 2015 (edited) 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 November 21, 2015 by LetsPlayOrDy Link to comment Share on other sites More sharing options...
qiangqiang101 Posted November 21, 2015 Author Share Posted November 21, 2015 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 More sharing options...
alloc8or Posted November 21, 2015 Share Posted November 21, 2015 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. Jitnaught 1 Link to comment Share on other sites More sharing options...
gtaVmod Posted November 21, 2015 Share Posted November 21, 2015 How to convert Hash to Model? for example i want to convert playerPed.CurrentVehicle.Model.Hash return "adder" GET_DISPLAY_NAME_FROM_VEHICLE_MODEL Jitnaught 1 Link to comment Share on other sites More sharing options...
qiangqiang101 Posted November 21, 2015 Author Share Posted November 21, 2015 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 More sharing options...
gtaVmod Posted November 21, 2015 Share Posted November 21, 2015 then you are out of luck, make your own table. Link to comment Share on other sites More sharing options...
alloc8or Posted November 21, 2015 Share Posted November 21, 2015 Here's one way of doing this. (But it's in C++) Link to comment Share on other sites More sharing options...
Cr1TiKa7 Posted November 22, 2015 Share Posted November 22, 2015 (edited) 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 Edited November 22, 2015 by Cr1TiKa7 qiangqiang101 1 Link to comment Share on other sites More sharing options...
qiangqiang101 Posted November 22, 2015 Author Share Posted November 22, 2015 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 More sharing options...
Cr1TiKa7 Posted November 22, 2015 Share Posted November 22, 2015 (edited) 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 November 22, 2015 by Cr1TiKa7 Link to comment Share on other sites More sharing options...
gtaVmod Posted December 1, 2015 Share Posted December 1, 2015 (edited) 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 December 1, 2015 by gtaVmod 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