Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Forum Support

    3. Suggestions

[SA] Vanilla Car Generator Spawner?


kalikokyle
 Share

Recommended Posts

kalikokyle

Hello! I've done some searching throughout the forum and other mod websites, and can't seem to find what I'm looking for.

 

I was trying to add some car generator spawners to my game, and by that i mean set spawns for certain vehicles (Add-on cars in this case) to have a set spawn location. I have added a few cars that don't fit into traffic and would like to spawn them in a certain area, similar to the vanilla sandking. I have edited other car spawning scripts myself, but they seem to spawn the car in at all times which end up eating into RAM by the time I have them all added. If anyone knows a method, or could point me in the direction of a spawner that will unload the cars properly like the vanilla game, I would be much appreciative! Thanks a bunch!

Link to comment
Share on other sites

Based on some of your other topics, I'm assuming that you have a great deal of control over your added vehicles and that they will spawn normally using standard opcodes. 

014B: $PARKED_RHINO = init_car_generator #RHINO color -1 -1 force_spawn 1 alarm 0 door_lock 0 min_delay 0 max_delay 10000 at 2435.302 -1671.848 12.8007 angle 90.0
09E2: $PARKED_IMPEXPM_CARS[0] = parked_car_generator_w_numberplate #EUROS colors -1 -1 force_spawn 0 alarm 50 door_lock 0 min_delay 0 max_delay 10000 plate "IMPEXP__" at 0.0 0.0 0.0 angle 180.0

 

Please show a version of your script with only a few added vehicles so I know what formats to use.

How many cargens are you trying to create?

 

A common issue with cleo scripts that add cargens is that the cargens are added each time the save is loaded, then saved, and re-added again and again. Eventually the 500 (standard) gargen limit is reached and there's no room left for all the binary cargens that are streamed in and out as CJ moves about the map. Consider using this new Cleo+ opcode to prevent your added cargens from being saved.

 

0E02: set_car_generator [email protected] no_save

 

There are 208 "SCM" car generators in a standard game. You'll want to keep a buffer of about 100 (guestimate) free slots for normal streaming. So if you want more than 200 added cargens you'll need to be creative.

 

SCM cargens are always active, but they won't spawn a vehicle until the player is near.
 

 

Link to comment
Share on other sites

This custom cleo function provides the solution you we asking for; it'll delete SCM cargens. It should be safe to use on No_Save cargens.

:DeleteCarGenerator
{
   DeleteCarGenerator - a custom SCM function
   by OrionSR
   Adapted from fastman92's DisableCarGeneratorFromBeingSaved function
   Example: 0AB1: call_scm_func @DeleteCarGenerator 1 cargen_index [email protected]
}
// Is invalid generator ID?
if or
  -1 >= [email protected]
  [email protected] >= 500
then
  0AB2: ret 0
end

0A8D: [email protected] = read_memory 0x6F32AA size 1 virtual_protect false // CCarGenerator_size
0AA7: call_function 0x479D60 num_params 1 pop 1 [email protected] store_result_to [email protected] // CCarGenerator* ptr
if
  [email protected] >= 0x30 // is CCarGenerator_extended?
then
  [email protected] += 0x24 // *** untested ***  
  0A8C: write_memory [email protected] size 2 value 0x0 virtual_protect false // exIplFile
else
  [email protected] += 0x1D
  0A8C: write_memory [email protected] size 1 value 0x0 virtual_protect false // iplFile
end
0AB2: ret 0

Include the function at the end of your script where it can't execute unless called using the Example provided. The variable passed in the example, [email protected], is the handle of the car generator to be deleted. 

 

The main problem with this strategy is the limited number of script variables available to manage the cargen handles. A crude alternative, if you can verify your main.scm as mostly normal, you could delete all cargens before the first and after the last standard cargens. (See CarGenFix.cs)

Edited by OrionSR
Link to comment
Share on other sites

kalikokyle

Appreciate the reply, will work on this script and let you know. Also very appreciative of the info on how the SCM handles it. I'm only needing maybe 20-30 cargens, as the rest should spawn with traffic!

 

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
 Share

  • 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.