altmp / altv-issues

Issues and roadmap for alt:V project
93 stars 17 forks source link

Handling API doesn't work for some vanilla vehicles #1582

Closed xxshady closed 2 days ago

xxshady commented 2 years ago

Description of the problem

Handling API doesn't working not only for custom vehicles (#1173), but also for some vanilla too, e.g. blista2, blista, issi2.

If you try to change some values directly on the vehicle object using vehicle.handling it's just won't work. When you try to get alt.HandlingData instance with passed vehicle.handling.handlingNameHash it says "model doesn't exist" (already fixed)

Some notes:

Reproduction steps

  1. Spawn blista vehicle

  2. Try to change some handling

    alt.Player.local.vehicle.handling.acceleration = -100 // nothing changes
// UPD: this was fixed in js module

alt.HandlingData.getForHandlingName(alt.hash("blista")) // that works, though
alt.HandlingData.getForHandlingName(alt.Player.local.vehicle.handling.handlingNameHash) // ~~error: model doesn't exist~~

Expected behaviour

Handling API should work for these vehicles.

Additional context

No response

Operating system

Windows 11

Version

13.0-dev3 & release/12.7

xxshady commented 2 years ago

@mrgharabaghi there is no difference in that

mrgharabaghi commented 2 years ago

I have a list of vehicles that get the model doesn't exist error with the below snippet.

alt.HandlingData.getForHandlingName(alt.hash('blista2'));

Updated list.txt

xxshady commented 2 years ago

@mrgharabaghi do you have no errors for issi2, blista?

mrgharabaghi commented 2 years ago

I don't have any error with blista. In fact, issi2 handling id is issi. There is no issi2 handling id in GTA V official files. Take a look at this: https://discord.com/channels/371265202378899476/748927139927031910/1003208332171034626

xxshady commented 2 years ago

I thought your list was a vehicle model names

xxshady commented 2 years ago

I think then vehicle.handling.handlingNameHash is wrong for these problematic vehicles For example vehicle model: blista handlingNameHash should be alt.hash('blista') (as you can see here) but it is negative number for some reason

изображение

xxshady commented 2 years ago

Even then alt.HandlingData.getForHandlingName(alt.hash("blista")).acceleration = -100 doesn't change anything, and i tried to restream vehicle

mrgharabaghi commented 2 years ago

In handling.meta, acceleration doesn't exist and I don't know alt:V devs how made this. Maybe the problem of blista is related to this (alt:V internal acceleration value).

mrgharabaghi commented 2 years ago

These values (Official GTA V handling.meta) works for blista without any problem. mass - brakeForce - handBrakeForce - initialDriveGears

// blista == Handing ID
let hand = alt.HandlingData.getForHandlingName(alt.hash('blista'));
hand.mass = 1200;
hand.brakeForce = 0.001;
hand.handBrakeForce = 0.002;

// Needs fresh instance
hand.initialDriveGears = 3;
mszekiel commented 5 months ago

From what I've checked it doesn't load for these vehicles:

asea2
bison2
bison3
burrito5
cavalcade
cavalcade2
emperor3
mesa3
rancherxl2
rancher // I guess that's handling name and not vehicle model
sadler2
surfer2
tornado3
faction2
moonbeam2
amazur31 commented 5 months ago

Bump. This is a really big issue for us. We can't develop any custom handlings for default cars due to this and related issues. Any streaming or Handling API calls don't work correctly on AltV. @DurtyFree recommended us to push this issue.

mrgharabaghi commented 4 days ago

@xxshady

As alt:V 16.2.5 says, vehicle.handling.acceleration is deprecated.

HandlingData.acceleration is deprecated and will be removed in future versions. Consider using HandlingData.driveBiasRear instead

You can use handling.driveBiasFront and handling.driveBiasRear without calling setupTransmission(). I tested this for blista and issi2, works fine.

And as I said in here and here, don't forgot to call setupTransmission() for initialDriveGears.

Time to close the issue.

mrgharabaghi commented 4 days ago
alt.on('enteredVehicle', (vehicle) => {
    vehicle.handling.driveBiasFront = 100;
    vehicle.handling.driveBiasRear = 0;
    vehicle.handling.initialDriveGears = 2;
    vehicle.setupTransmission();
});