Usually the beginner scripter starts with a small and simple script to spawn a vehicle with a parked generator. It is recommend because not much knowledge is needed - however, as I have seen all over GTAForums, that people are actually confused about how the generator parameter (014c's last parameter) works, let me explain:
0 means the vehicle will never spawn. 101 or greater means the vehicle will always spawn for a unlimited amount of time. Where-as say for example 20, would make the vehicle spawn 20 times, so 1 would make it spawn 1 time, and 99 would make it spawn 99 times.
Now when spawning a vehicle, it is not necessary to pay attention to the 32@, 33@ (local timers) rule. These may even be used as a handler for the parked car generator. (32@ is available anywhere, even if the thread is big I guess.)
And it's still correct as:
Would be.
As such, car generators is(-are) different from actually scripting a handler, and you can not use these cars to perform a task, say you want the car to drive, or you want to destroy it. You NEVER need to load a model of the vehicle when using a parked car generator, and you NEVER need to check if weather the player is in range to spawn the vehicle.
If you want to create a car normally, and can actually use the car for things then use the opcode 00a5:
There exist 4 opcodes, to-do with the parked generators, (014b, sets-up the car, 09e2 is the same only you can add your own custom number plate, 014c makes the vehicle generate, and 0a17, sets the parked car as player-owned).
In a CLEO script, most scripter's usually save there vehicle, so that it is always present within your save-game file. For this you can add the opcode 0a95 at the start of the script:
And so it would be like this:
As in a CLEO script, some may wanna use global variables, to make there code more readable, if you wanna disable the car for example, then global variables, will come in handy. Although if it's parking is handled by a separate thread, you may use a local variable.
For making your code even more readable, without using the global variables, you can use the const..end function:
Like that:
There is a limit of how many parked cars can be placed within the game, that limit is 500(185 in Vice City), including the vehicles already in the original main.scm(if you have it that is). Analogous to GTA 4 the opcode 014c = SWITCH_CAR_GENERATOR and 014B = CREATE_CAR_GENERATOR You can read more information about the parked car generator opcodes at GTAModding.com.
0 means the vehicle will never spawn. 101 or greater means the vehicle will always spawn for a unlimited amount of time. Where-as say for example 20, would make the vehicle spawn 20 times, so 1 would make it spawn 1 time, and 99 would make it spawn 99 times.
Now when spawning a vehicle, it is not necessary to pay attention to the 32@, 33@ (local timers) rule. These may even be used as a handler for the parked car generator. (32@ is available anywhere, even if the thread is big I guess.)
- Code:
014b: 32@ = init_parked_car_generator #BULLET color -1 -1 1 alarm 0 door_lock 0 0 10000 at x y z angle <p>
014c: set_parked_car_generator 32@ cars_to_generate_to 3 // spawn 3 times
And it's still correct as:
- Code:
014b: 0@ = init_parked_car_generator #BULLET color -1 -1 1 alarm 0 door_lock 0 0 10000 at x y z angle <p>
014c: set_parked_car_generator 0@ cars_to_generate_to 3 // spawn 3 times
Would be.
As such, car generators is(-are) different from actually scripting a handler, and you can not use these cars to perform a task, say you want the car to drive, or you want to destroy it. You NEVER need to load a model of the vehicle when using a parked car generator, and you NEVER need to check if weather the player is in range to spawn the vehicle.
If you want to create a car normally, and can actually use the car for things then use the opcode 00a5:
- Code:
#INFERNUS.load
repeat
wait 0
until #INFERNUS.Available
04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 0.0 5.0 1.2
0395: clear_area 1 at 0@ 1@ 2@ radius 5.0
00A5: 3@ = create_car #INFERNUS at 0@ 1@ 2@
#INFERNUS.Destroy
01C3: remove_references_to_car 3@
There exist 4 opcodes, to-do with the parked generators, (014b, sets-up the car, 09e2 is the same only you can add your own custom number plate, 014c makes the vehicle generate, and 0a17, sets the parked car as player-owned).
In a CLEO script, most scripter's usually save there vehicle, so that it is always present within your save-game file. For this you can add the opcode 0a95 at the start of the script:
- Code:
0A95: enable_thread_saving
And so it would be like this:
- Code:
{$CLEO}
0A95: enable_thread_saving
014b: 0@ = init_parked_car_generator #BULLET color -1 -1 1 alarm 0 door_lock 0 0 10000 at x y z angle <p>
014c: set_parked_car_generator 0@ cars_to_generate_to 101 // unlimited spawn limit
0A93: end_custom_thread
As in a CLEO script, some may wanna use global variables, to make there code more readable, if you wanna disable the car for example, then global variables, will come in handy. Although if it's parking is handled by a separate thread, you may use a local variable.
For making your code even more readable, without using the global variables, you can use the const..end function:
- Code:
const
MY_CAR1 = 0@
end
Like that:
- Code:
{$CLEO}
const
MY_CAR1 = 0@
end
0A95: enable_thread_saving
014b: MY_CAR1 = init_parked_car_generator #BULLET color -1 -1 1 alarm 0 door_lock 0 0 10000 at x y z angle <p>
014c: set_parked_car_generator MY_CAR1 cars_to_generate_to 101 // unlimited spawn limit
0A93: end_custom_thread
There is a limit of how many parked cars can be placed within the game, that limit is 500(185 in Vice City), including the vehicles already in the original main.scm(if you have it that is). Analogous to GTA 4 the opcode 014c = SWITCH_CAR_GENERATOR and 014B = CREATE_CAR_GENERATOR You can read more information about the parked car generator opcodes at GTAModding.com.