kalikokyle Posted January 31 Share Posted January 31 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 More sharing options...
OrionSR Posted February 1 Share Posted February 1 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. kalikokyle 1 Link to comment Share on other sites More sharing options...
OrionSR Posted February 1 Share Posted February 1 (edited) 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 February 1 by OrionSR kalikokyle 1 Link to comment Share on other sites More sharing options...
kalikokyle Posted February 1 Author Share Posted February 1 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now