esx-overextended / es_extended

FiveM RPG Framework
GNU General Public License v3.0
18 stars 6 forks source link

Incorrect plate from ESX-created vehicle #51

Open ahcenezdh opened 8 months ago

ahcenezdh commented 8 months ago

When trying to get the plate of a vehicle client side it's returning me (ESX5OX03) instead of the real plate FxServer version: 7257 OneSync Infinity: yes

function loadVehiclesIntoGarages(garage, player, vin, vehProps)
    local vehiclesDetails <const> = MySQL.query.await(garageQuery["loadVehiclesIntoGarages"], { player.identifier, garage.garage })
    for _, vehicle in pairs(vehiclesDetails) do
        local coordsVehicle = vector3( garage.vehiclePositions[_].x, garage.vehiclePositions[_].y, garage.vehiclePositions[_].z)
        local heading = garage.vehiclePositions[_].w
        local xVehicle = ESX.CreateVehicle(vehicle.id, coordsVehicle, heading)
        xVehicle.setStored(true, false)
        xVehicle.setRoutingBucket(player.source)
        vehicles[#vehicles+1] = xVehicle.entity
        ESX.SetVehicleProperties(xVehicle.entity, vehProps)
        -- everything works fine, vehicles are created and properties are set
    end
    return vehicles
end

Here is how i'm getting the plate

ESX.SetFunction("GetVehiclePlate", function(ESX)
    return function(vehicle, capsLock)
        local plate = GetVehicleNumberPlateText(vehicle)
        return capsLock and string.upper(plate) or plate
    end
end)
mahanmoulaei commented 7 months ago

Could you explain more? Are you trying to get the plate from the client side or the server side?

fyi since server cannot apply vehicle properties, we have to wait for the first available player in the vehicle's scope to apply the properties such as plate automatically