Issue with native function GetDisplayNameFromVehicleModel

Hi,

I notice that in the code, when testing a pound function, a, strange things for the return of this native function

:GetDisplayNameFromVehicleModel

I tested this one with many vehicle, and have an issue for modelname who exceed 8 chars,

For exemple, for washington, it print washingt
same for all vehicule who exceed 8 chars.

If anyone know why.

Tested with build 431 on linux server

Sorry for my english.

Cheers

1 Like

You want to do something like this to get the actual name

        local aheadVehHash = GetEntityModel(aheadVeh)
        local aheadVehName = GetDisplayNameFromVehicleModel(aheadVehHash)
        local aheadVehNameText = GetLabelText(aheadVehName)
2 Likes

I know sorry, i just resume the situation, here example of code where i’m using it :

function tvRP.getNearestVehicle(radius)
  local x,y,z = tvRP.getPosition()
  local ped = GetPlayerPed(-1)
  if IsPedSittingInAnyVehicle(ped) then
    return GetVehiclePedIsIn(ped, true)
  else
    -- flags used:
    --- 8192: boat
    --- 4096: helicos
    --- 4,2,1: cars (with police)

    local veh = GetClosestVehicle(x+0.0001,y+0.0001,z+0.0001, radius+0.0001, 0, 8192+4096+4+2+1)  -- boats, helicos
    if not IsEntityAVehicle(veh) then veh = GetClosestVehicle(x+0.0001,y+0.0001,z+0.0001, radius+0.0001, 0, 4+2+1) end -- cars
    return veh
  end
end

function tvRP.getNearestVehiclePound(radius)
  local veh = tvRP.getNearestVehicle(radius)
  if IsEntityAVehicle(veh) then
    local plate = GetVehicleNumberPlateText(veh)
    local model_name = GetDisplayNameFromVehicleModel(GetEntityModel(veh))
	print(model_name)
    if  model_name == "CARNOTFOUND" then
      tvRP.notify("Véhicule inconnu, contactez votre vendeur de voitures !!")
      -- we can't identify wehicle then we cancel task
      return nil,nil
    else
      return plate,model_name
    end
  else
    return nil,nil
  end
end

In my case, the return of GetDisplayNameFromVehicleModel(aheadVehHash) never execeed 8 char for vehicle who get more than that, is it normal ?

You need to use that after GetDisplayNameFromVehicleModel

Ok sorry for not understanding your last post, will test with that one

I tested it for example for the model cogcabrio

The function GetLabelText doesn’t match with what i need

I need to retrive the exact model name of cogcabrio with the function GetDisplayNameFromVehicleModel, but i get cogcabri, one letter is missing, and its a problem for function i’m using

The function getlabeltext, give me the total display name, like “Cognoscienti Cabro”, i dont need that ^^

So you’re looking for the model name that the game uses?

In my case, i used the model name in many function.

I need it for example, to get the model name in client-side function, to send it to server-side and mysql.

The problem is, the native function in client-side, dont seems to get model name correctly for vehicles where their model name exceed 8 chars

Personally I just store the hash as an integer, it can be used for pretty much everything the name can.

in my case, my DB deal with model name and all my system, cant change to convert the whole system ^^

I think its just a problem with native, who dont send the all modelname if it’s exceed 8 chars

There’s nothing wrong with the native, those names aren’t the same as the model name. Unfortunately I don’t know another way.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.