Jump to content

Making space for more vehicles


Recommended Posts

I would really like to allocate some more space for vehicles, to extend the initial limit so I can add some more custom vehicles, however I am a bit unsure how to do this, so I went:



if(!dwAlloc) MessageBox(0,"Vehicle Allocation Failed","SA Limit Executer",NULL);

char* cVehicles = (char*)&dwAlloc;

BYTE bVehicles[] = { cVehicles[0], cVehicles[1], cVehicles[2], cVehicles[3] };











However that would crash the game, and it would crash on a call to a function that wasn't pointed to, so I figured that the vehicle slots were actually a class, so then I just copied the array memory from the original array, to the newly allocated array, still no go.


So what am I doing wrong here?

Link to comment
Share on other sites

yes, it's a class (Cvehicle)

contact me in pm! tounge.gif


there is another way:

you can change the number of possible vehicles changing the max vehicles before the game allocates space, so when the game will allocate space will allocate how much space you want!

Link to comment
Share on other sites

There's more to consider there...


1. There's the vehicle pool... which has all the CVehicles spawned in the world. You don't need to do anything to this, but I'm mentioning for the sake of completeness.


2. There's the vehicle model info pool... which defines all the CVehicleModelInfos... and this is what you're trying to relocate/resize. (you almost got it)


3. There's the CModelInfo index table... which you didn't consider.


Now for (2)...


You're trying to patch the pointer to 0xB1F650... which is good. But at 0xB1F650, there's only the number of Vehicle Infos. You will also have to patch the pointers to 0xB1F654, which is where the CVehicleModelInfos start. Note that there are 3 xrefs to this, but only 2 of them need to be relocated... the last one is related to (3).


And (3)...


At 0xA9B0C8, is an index table for all the ModelInfos loaded by the game, which defines a model id -> CModelInfo mapping. At index 400, you should find the ptr to the first CVehicleModelInfo, and so on. In order to do what you want to do... you could try finding out what models occupy the ModelInfo index table after the vehicles (so after index 612), and relocate them to somewhere where it doesn't matter (like after all the other ModelInfos)... and hope that the game doesn't care about where they are. Then you can start using 613, etc as new model ids.


Note that some parts of the vehicles are hardcoded to work with specific model ids (like the tank turrets, forklifts, etc).


Good luck!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.