ok, step by step
Basicly is it very easy to spawn an object
just copy'n paste the script below into sannybuilder, save it, then compile and copy it into game cleo folder
then load savegame or start new game and go to Grovestreet to find the placed fire_hydrant
| CODE |
{$CLEO .cs} :OBJECTS 03A4: name_thread 'OBJS' wait 1000 //(this is a comment) dynamic.ide: 1211, fire_hydrant
029B: 1@ = init_object 1211 at 2491.7866 -1672.1202 13.3359 0A93: end_custom_thread |
1@ is a variable to define the object in the script and eventually to can handle it furthermore
1211 is id number of fire_hydrant
Cleoscripts requires to insert id numbers to spawn objects
unless you wanna spawn an object of veh_mods.ide
then you can use the model name with hash infront
| CODE |
| 029B: 1@ = init_object #spl_a_f_r at 2491.7866 -1672.1202 13.3359 |
for models of default.ide, vehicles.ide, peds.ide, veh_mods.ide can be used either id number or model name
for the others only id number
please read
Data Type MeaningSpawn a 3D modelhow to get coordinates for position?
read about
EditorNow some important informations:
You placed now fire_hydrant in Grovestreet and if you make then a savegame,
it will be stored in the savefiles of GTA San Andreas User Files
you can't remove it then unless with savgame editor maybe.
If you load now that savegame and the script runs again,
then the object will be placed twice
This fact belongs also to pickups, parked_car_genarators, icon markers,
To avoid that the script runs again when loading savegame which was done with the script,
we have this opcode:| CODE |
| 0A95: enable_thread_saving |
cleo save this then in CLEO\CLEO_SAVES folder
Use the opcode in this way:
| CODE |
{$CLEO .cs} :OBJECTS 03A4: name_thread 'OBJS' wait 1000 0A95: enable_thread_saving //(this is a comment) dynamic.ide: 1211, fire_hydrant
029B: 1@ = init_object 1211 at 2491.7866 -1672.1202 13.3359 0A93: end_custom_thread |
If you wanna provide a script for the user to place objects, you should do everything to remove the objects if they're not used anymore, before user makes a savegame
Or tell the user about the problem
The script below spawns 3 unused objects infront of CJ by keypress Backspace
Press again Backspace to remove the objects
| CODE |
{$CLEO .cs} :3_OBJECTS { 1639, od_vbnet red 1318, arrow blue 1614, nt_alarm1_01 yellow } 03A4: name_thread '3_OBJS' 0001: wait 1000 ms 00C0: set_current_time_hours_to 23 minutes_to 50
:3_OBJS_22 0001: wait 0 ms 00D6: if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @3_OBJS_22 00D6: if 0AB0: key_pressed 8//------------------key Backspace 004D: jump_if_false @3_OBJS_22 00BA: show_text_styled GXT 'FEM_ON' time 1000 style 4 // ON wait 500 0247: load_model 1639 0247: load_model 1318 0247: load_model 1614 038B: load_requested_models 04C4: store_coords_to 21@ 22@ 23@ from_actor $PLAYER_ACTOR with_offset -2.0 2.5 0.0 0107: 1@ = create_object 1318 at 21@ 22@ 23@ 04C4: store_coords_to 21@ 22@ 23@ from_actor $PLAYER_ACTOR with_offset 0.0 2.5 0.0 0107: 2@ = create_object 1614 at 21@ 22@ 23@ 04C4: store_coords_to 21@ 22@ 23@ from_actor $PLAYER_ACTOR with_offset 2.0 2.5 0.0 0107: 3@ = create_object 1639 at 21@ 22@ 23@ 0001: wait 0 ms 0249: release_model 1639 0249: release_model 1246 0249: release_model 1614 00BA: show_text_styled GXT 'FEM_OK' time 1000 style 4 // OK 0001: wait 1000 ms
:3_OBJS_276 0001: wait 0 ms 00D6: if 0256: player $PLAYER_CHAR defined 004D: jump_if_false @3_OBJS_313 00D6: if 0AB0: key_pressed 8//------------------key Backspace 004D: jump_if_false @3_OBJS_276
:3_OBJS_313 00BA: show_text_styled GXT 'FEM_OFF' time 1000 style 4 // OFF 0108: destroy_object 1@ 0108: destroy_object 2@ 0108: destroy_object 3@ 0001: wait 1000 ms 0002: jump @3_OBJS_22 |
The variables 1@, 2@, 3@, are used as handle for the objects and can be used then to remove the objects
But this is only possible while same savegame session
It is not possible to spawn the objects, make savegame, load this savegame and remove the objects.