Tutorials

 Reply to this postStart new topic

[GTA SA] How to properly add car generators with CLEO script?

fastman92
post Jan 6 2015, 04:51 PM
Post #1


Trained Member

Posts: 77
Joined: 25-October 10



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.




CODE
{$CLEO}

// Create a car generator for infernus
014B: 0@ = 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.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
0AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator 0@

// 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:
     0@ - car generator index

Example:
  0AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator 6@
}

// Is invalid generator ID?
if
    0@ == -1
then
    0AB2: ret 0
end

0A8D: 1@ = read_memory 0x6F32AA size 1 virtual_protect false    // CCarGenerator_size

0AA7: call_function 0x479D60 num_params 1 pop 1 0@ store_result_to 2@    // CCarGenerator* ptr

if
    1@ >= 0x30  // is CCarGenerator_extended ?
then
    2@ += 0x22
    0A8C: write_memory 2@ size 2 value 0xFFFF virtual_protect false     // exIplFile          
else
    2@ += 0x1C
    0A8C: write_memory 2@ size 1 value 0xFF virtual_protect false       // iplFile
end

0AB2: ret 0


When you made a car generator, you just have to call function @DisableCarGeneratorFromBeingSaved

3 lines of code
CODE
014B: 0@ = 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.0
014C: set_parked_car_generator 0@ cars_to_generate_to 101
0AB1: call_scm_func @DisableCarGeneratorFromBeingSaved 1 car_generator 0@


You need to copy my function DisableCarGeneratorFromBeingSaved into your CLEO script and put it to the end of file.
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: