fastman92 Posted January 6, 2015 Share Posted January 6, 2015 How to properly add car generators with CLEO script? Tutorial for GTA SA. For many years there was a problem with car generators in CLEO script. CLEO script would run everytime you load the game and car generators made with SCM would then be written to savefile the next time you save the game. Therefore, it may be desirable to make car generators temporary and prevent them from being saved. {$CLEO}// Create a car generator for infernus014B: [email protected] = init_car_generator #INFERNUS color -1 -1 force_spawn 1 alarm 0 door_lock 0 min_delay 0 max_delay 10000 at 2492.0278 -1665.8153 13.3437 angle 90.0014C: set_parked_car_generator [email protected] cars_to_generate_to 1010AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator [email protected]// Make a CLEO script no longer execute.0A93: end_custom_thread//////////////////////////////////////////////////////////////:DisableCarGeneratorFromBeingSaved{Description:Disables car generator from being written into savefile.Fixes a corruption of savefile because of car generators used in CLEO.Parameters:Passed:[email protected] - car generator indexExample:0AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator [email protected]}// Is invalid generator [email protected] == -1then0AB2: ret 0end0A8D: [email protected] = read_memory 0x6F32AA size 1 virtual_protect false // CCarGenerator_size0AA7: call_function 0x479D60 num_params 1 pop 1 [email protected] store_result_to [email protected] // CCarGenerator* [email protected] >= 0x30 // is CCarGenerator_extended [email protected] += 0x220A8C: write_memory [email protected] size 2 value 0xFFFF virtual_protect false // [email protected] += 0x1C0A8C: write_memory [email protected] size 1 value 0xFF virtual_protect false // iplFileend0AB2: ret 0When you made a car generator, you just have to call function @DisableCarGeneratorFromBeingSaved 3 lines of code 014B: [email protected] = init_car_generator #INFERNUS color -1 -1 force_spawn 1 alarm 0 door_lock 0 min_delay 0 max_delay 10000 at 2492.0278 -1665.8153 13.3437 angle 90.0014C: set_parked_car_generator [email protected] cars_to_generate_to 1010AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator [email protected]You need to copy my function DisableCarGeneratorFromBeingSaved into your CLEO script and put it to the end of file. _onyx_, Neddo, Silent and 6 others 9 Link to comment Share on other sites More sharing options...
OrionSR Posted January 10, 2015 Share Posted January 10, 2015 (edited) Interesting, but how does this function... function? I've had some experience with unallocating gargens using cleo by removing the allocation flag. It occurred to me that I might be able to make the cargens temporary by also setting an IPL flag and letting the vehicle get discarded when CJ leaves the area. This strategy sounds like it would leave a more persistent vehicle during that play. I had an idea for another strategy for managing the problem of persistent cargens: Add whatever you want using standard opcodes and when you are unhappy with the results dump the entire cargen pool and put the standards and favorites back the way you want them. All vehicles can be displayed and then the reward vehicle hidden based on mission variables and stats. I made reasonably good progress on a hide car script and I think I worked out everything except how to tease out the export vehicles mid-mission, which is probably manageable but wasn't necessary for the task at hand. And that task was to put the cars back but do it better. Like nudge a few so they spawn properly, reduce the locks on combines, add a few force spawn and player owned flags, and make the export vehicles be displayed all the time. Or put the cars back in a Chain Game configuration with the export vehicles auto-exporting in the export circle - fun trick. Or, here's the gargen pool in a nutshell, knock yourself out. Need more cargens? Spawn and remove your custom cargen based on county, city, or zone. Anyway, that project got sidetracked when I lost access to my phone, but perhaps I should revisit it for PC. Added: Sorry, I forgot I was in the tutorial section when I posted. Feel free to manage this post as you feel necessary. Edited January 10, 2015 by OrionSR Link to comment Share on other sites More sharing options...
fastman92 Posted January 10, 2015 Author Share Posted January 10, 2015 (edited) Interesting, but how does this function... function? I've had some experience with unallocating gargens using cleo by removing the allocation flag. It occurred to me that I might be able to make the cargens temporary by also setting an IPL flag and letting the vehicle get discarded when CJ leaves the area. This strategy sounds like it would leave a more persistent vehicle during that play. I had an idea for another strategy for managing the problem of persistent cargens: Add whatever you want using standard opcodes and when you are unhappy with the results dump the entire cargen pool and put the standards and favorites back the way you want them. All vehicles can be displayed and then the reward vehicle hidden based on mission variables and stats. I made reasonably good progress on a hide car script and I think I worked out everything except how to tease out the export vehicles mid-mission, which is probably manageable but wasn't necessary for the task at hand. And that task was to put the cars back but do it better. Like nudge a few so they spawn properly, reduce the locks on combines, add a few force spawn and player owned flags, and make the export vehicles be displayed all the time. Or put the cars back in a Chain Game configuration with the export vehicles auto-exporting in the export circle - fun trick. Or, here's the gargen pool in a nutshell, knock yourself out. Need more cargens? Spawn and remove your custom cargen based on county, city, or zone. Anyway, that project got sidetracked when I lost access to my phone, but perhaps I should revisit it for PC. Added: Sorry, I forgot I was in the tutorial section when I posted. Feel free to manage this post as you feel necessary. My function is very simple:it sets the IPL ID to 0xFF or 0xFFFF, later when you make a savefile, only car generators where IPL ID is 0 (SCM) will be saved. When IPL ID is not 0, then car generator won't be saved. Your project sounds too complicated. Edited January 10, 2015 by fastman92 Link to comment Share on other sites More sharing options...
OrionSR Posted January 11, 2015 Share Posted January 11, 2015 (edited) Please provide a compatibility link for the extended cargen records. Yes, very simple. I think I understand now: Cargens created with this function will persist as long as the player isn't using the maximum number of streaming IPL files, then these cargens will be discarded when that stream goes inactive (I haven't really tested this but I think this is how the streaming cargens work). How can I manually enable or disable an IPL stream by number? Or, can this function be adapted to apply the proper IPL number so the vehicles are discarded when CJ leaves the area? Is it possible to tap into the standard streaming cargen procedure and let it do all the work? Why? Say I wanted to create stream-like cargens whenever CJ entered certain areas. I could track my cargens by index and unallocate them individually to free up room for the next area but that's a lot of work and I quickly run out of locals. It would be much easier to toggle an IPL flag (truth's farm for lack of number control) and dump the whole lot at once. Or, spawn them with proper IPL ids so they disappear on their own. Fire and forget cargens, I just can't get so carried away that I run out of room in the cargen pool for the standard streaming vehicles. The index gets passed, so I think I'll move that cars_to_generate code into the function and disable display afterwards if for some strange reason I don't want to see my temp cargen all the time. If I may have a little fun with imperfect analogies: Our projects employ different strategies towards a similar goal, preventing the unwanted pregnancy of cargen pools. Your strategy encourages proper prevention - like a condom. But you know how young modders are, they're going to take risks and get into trouble. My project is more like a morning after pill. An overall cargen health care program would want to combine multiple strategies to be most effective. The Plan B project is on hold due to lack of interest. Edited January 11, 2015 by OrionSR Link to comment Share on other sites More sharing options...
_RJSingh_ Posted January 11, 2015 Share Posted January 11, 2015 It works perfect! Thanks Fastman92. Link to comment Share on other sites More sharing options...
Neddo Posted January 11, 2015 Share Posted January 11, 2015 Wonderful! Will cleo or asi scripts ever be able to add vehicles with function (cops, taxis...)? Link to comment Share on other sites More sharing options...