Skip to content

engineRequestModel("vehicle") doesn't load default GTA scripts #1861

Open
@Xenius97

Description

@Xenius97
Contributor

Describe the bug
engineRequestModel("vehicle") doesn't load default GTA scripts
I've tested with Towtruck, Tractor, Police Maverick (light doesn't work), Seasparrow (can't fire), Packer etc.

To reproduce
engineRequestModel("vehicle", 525)

Version
Multi Theft Auto v1.5.8-release-20732

Activity

changed the title [-]engineRequestModel("vehicle") doesn't work with utiliy vehicles[/-] [+]engineRequestModel("vehicle") doesn't load default GTA scripts[/+] on Nov 22, 2020
AlexTMjugador

AlexTMjugador commented on Nov 23, 2020

@AlexTMjugador
Member

#1701 explicitly states that this kind of behaviours do not work:

Does not work:

  • Сhassis
  • Turrets
  • ZR-350 opening headlights
  • Rhino, Hydra, Skimmer, Seasparrow
  • Some specific effects like a dust effect from some helicopters, smoke effects from bikes.
  • Another hardcoded stuff

I guess this is caused because somewhere in GTA code they are limited to a specific vehicle ID. If that's the case, for these to work, the affected methods would need to be patched.

qaisjp

qaisjp commented on Nov 23, 2020

@qaisjp
Contributor

The wiki should be updated to include this information. That article is also missing correct versioning usage

Xenius97

Xenius97 commented on Nov 27, 2020

@Xenius97
ContributorAuthor

Trains doesn't work too.

Fernando-A-Rocha

Fernando-A-Rocha commented on Oct 24, 2021

@Fernando-A-Rocha
Contributor

🤔 Is it possible to fix this at this stage?

Pirulax

Pirulax commented on Nov 11, 2021

@Pirulax
Contributor

Would require to patch tons of code, so no, not really.
Special features are hard coded based on modelID.

TheNormalnij

TheNormalnij commented on Nov 11, 2021

@TheNormalnij
Member

I think it's still hackable. When i added vehicle allocation i thought about a setVehicleModelFeatureState function

lopezloo

lopezloo commented on Mar 9, 2023

@lopezloo
Member

I think it could be implemented like that:

// Check if this vehicle is allowed to process swinging doors.
static DWORD dwSwingingDoorAutomobile;
static const DWORD dwSwingingRet1 = 0x6A9DB6;
static const DWORD dwSwingingRet2 = 0x6AA1DA;
static bool AllowSwingingDoors()
{
SClientEntity<CVehicleSA>* pVehicleClientEntity = pGameInterface->GetPools()->GetVehicle((DWORD*)dwSwingingDoorAutomobile);
CVehicle* pVehicle = pVehicleClientEntity ? pVehicleClientEntity->pEntity : nullptr;
if (pVehicle == 0 || pVehicle->AreSwingingDoorsAllowed())
return true;
else
return false;
}
void _declspec(naked) HOOK_CAutomobile__ProcessSwingingDoor()
{
_asm
{
mov dwSwingingDoorAutomobile, esi
mov ecx, [esi+eax*4+0x648]
pushad
}
if (AllowSwingingDoors())
{
_asm
{
popad
jmp dwSwingingRet1
}
}
else
{
_asm
{
popad
jmp dwSwingingRet2
}
}
}

Hooking in place of these ID checks and calling vehicle entity method to check if specific feature is enabled for specific vehicle element.

So MTA API might look like this:

setVehicleFeatureEnabled(vehicle theVehicle, string feature, bool enabled)

In some places there might be no vehicle entity available though in theory. It would be great to document all the missing features.

Fernando-A-Rocha

Fernando-A-Rocha commented on Sep 8, 2023

@Fernando-A-Rocha
Contributor

Bumping this. A lot of people have messaged me in regards to my resource newmodels saying that added vehicles can't have features like attaching trailers, having water hose etc... It's a popular demand

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @qaisjp@Xenius97@TheNormalnij@lopezloo@AlexTMjugador

        Issue actions

          engineRequestModel("vehicle") doesn't load default GTA scripts · Issue #1861 · multitheftauto/mtasa-blue