Nico Posted October 11, 2022 Share Posted October 11, 2022 (edited) I've been messing with the Trucks with Trailers script to add functionality to other trucks I added, and I also want to add variety to the cars pulled by the tow trucks. For that specific feature, this CLEO script uses this opcode: 0209: [email protected] = random_int_in_ranges 604 606 IDs 604 and 605 correspond to the wrecked versions of Glendale and Sadler. I want to extend this and include other beater cars like Clover, Tampa and others I added, but they are not consecutive IDs with these two. How can I do that? Edited October 11, 2022 by Nico Did you see the frightened ones? Did you hear the falling bombs? Did you ever wonder... ...why we had to run for shelter when the promise of a brave new world unfurled beneath a clear blue sky? Link to comment Share on other sites More sharing options...
Wesser Posted October 12, 2022 Share Posted October 12, 2022 (edited) This can be easily accomplished using arrays but then you must deal with the limited amount of local variables available, especially in CLEO. For starters, SWITCH_START (2161) and SWITCH_CONTINUED (2162) commands would do the trick unless you like something more advanced, limitless and equally as compact: arraytest.txt // Switch to GTA:SA SCR mode. {$CLEO} // Guarantee a 4-byte alignment. goto @script_start hex FF end /* int aWreckedCars[4] = { MI_CLOVER, MI_TAMPA, MI_GLENsh*t, MI_SADLsh*t }; */ :_aWreckedCars hex 1E020000 25020000 5C020000 5D020000 end :script_start var [email protected]: Int [email protected]: Int [email protected]: Int end 0A9F: get_pointer_to_this_script [email protected] 0A8E: [email protected] = [email protected] + 0x10 // offsetof(CRunningScript, m_pStartAddress) 0A8D: read_memory [email protected] size 4 vp FALSE store_to [email protected] [email protected] += 0x3C // offsetof(CRunningScript, m_aLocalVariables[0]) [email protected] -= @_aWreckedCars [email protected] -= [email protected] [email protected] /= 4 while true 0209: generate_random_int_in_range 0 4 store_to [email protected] [email protected] += [email protected] [email protected] = 0 repeat 0001: wait 0 03F0: use_text_commands TRUE 0342: set_text_center TRUE 045A: display_text_with_number 320.0 300.0 tkey 'NUMBER' number [email protected]([email protected],1i) // ~1~ until [email protected] >= 3000 end Edited October 12, 2022 by Wesser 012 345 678 9A BCD EFG HIJK LMN OPQR STUV WX YZ Link to comment Share on other sites More sharing options...
Nico Posted October 12, 2022 Author Share Posted October 12, 2022 (edited) In your example, the beater cars are represented by hex values, right? Is it possible to recall them by their model ID instead? The script I want to edit picks vehicles based on their ID rather than hex values. I'm gonna post the entire script I want to edit: Spoiler // This file was decompiled using SASCM.ini published on 2021-07-05 {$CLEO .cs} script_name 'NONAME' :NONAME_11 wait 0 if Player.Defined($PLAYER_CHAR) jf @NONAME_11 068D: get_camera_position_to [email protected] [email protected] [email protected] if get_random_car_in_sphere_no_save_recursive [email protected] = random_vehicle_near_point [email protected] [email protected] [email protected] in_radius 1000.0 find_next 0 pass_wrecked 1 jf @NONAME_11 :NONAME_76 wait 0 if not Car.Wrecked([email protected]) jf @NONAME_911 03F3: get_car [email protected] primary_color_to [email protected] secondary_color_to [email protected] 0A12: get_car [email protected] tertiary_color_to [email protected] quaternary_color_to [email protected] if not [email protected] == 6 jf @NONAME_911 if Car.Model([email protected]) == #RDTRAIN jf @NONAME_227 [email protected] = 515 [email protected] = 7 0209: [email protected] = random_int_in_ranges 0 2 if [email protected] = 0 jf @NONAME_212 [email protected] = 450 jump @NONAME_524 :NONAME_212 [email protected] = 591 jump @NONAME_524 :NONAME_227 if Car.Model([email protected]) == #LINERUN jf @NONAME_242 [email protected] = 403 [email protected] = 435 [email protected] = 7 jump @NONAME_524 :NONAME_242 if Car.Model([email protected]) == #PULVER jf @NONAME_276 [email protected] = 12574 [email protected] = 435 [email protected] = 7 jump @NONAME_524 :NONAME_276 if Car.Model([email protected]) == #PETRO jf @NONAME_291 [email protected] = 514 [email protected] = 584 [email protected] = 7 jump @NONAME_524 :NONAME_291 if Car.Model([email protected]) == #CERBERUS jf @NONAME_325 [email protected] = 12519 [email protected] = 12520 [email protected] = 7 jump @NONAME_524 :NONAME_325 if Car.Model([email protected]) == #TRACTOR jf @NONAME_378 [email protected] = 531 [email protected] = 610 0209: [email protected] = random_int_in_ranges 157 163 jump @NONAME_524 :NONAME_378 if Car.Model([email protected]) == #TOWTRUCK jf @NONAME_430 [email protected] = 525 0209: [email protected] = random_int_in_ranges 604 606 [email protected] = 50 jump @NONAME_524 :NONAME_430 if Car.Model([email protected]) == #UTILITY jf @NONAME_479 [email protected] = 552 [email protected] = 611 [email protected] = 50 jump @NONAME_524 :NONAME_479 if Car.Model([email protected]) == #BAGGAGE jf @NONAME_494 [email protected] = 485 0209: [email protected] = random_int_in_ranges 606 609 [email protected] = 16 jump @NONAME_524 :NONAME_494 if Car.Model([email protected]) == #BOBTAIL jf @NONAME_509 [email protected] = 12512 0209: [email protected] = random_int_in_ranges 606 609 [email protected] = 16 jump @NONAME_524 :NONAME_509 if Car.Model([email protected]) == #TUG jf @NONAME_512 [email protected] = 583 [email protected] = 608 [email protected] = 16 jump @NONAME_524 :NONAME_512 if Car.Model([email protected]) == #ARTICT3 jf @NONAME_911 [email protected] = 591 [email protected] = 435 [email protected] = 16 :NONAME_524 wait 0 get_vehicle_pointer [email protected] = vehicle [email protected] 0A8E: [email protected] = [email protected] + 1188 // int read_memory [email protected] = read_memory [email protected] size 1 virtual_protect 0 if and not [email protected] == 2 87AB: not car -1 has_attached_trailer [email protected] jf @NONAME_948 0407: store_coords_to [email protected] [email protected] [email protected] from_car [email protected] with_offset 0.0 0.0 0.0 [email protected] = Car.Angle([email protected]) 046C: [email protected] = car [email protected] driver Model.Load([email protected]) Model.Load([email protected]) Model.Load([email protected]) if and Model.Available([email protected]) Model.Available([email protected]) Model.Available([email protected]) jf @NONAME_524 0395: clear_area 1 at [email protected] [email protected] [email protected] radius 3.0 wait 0 Car.Create([email protected], [email protected], [email protected], [email protected], [email protected]) Car.Angle([email protected]) = [email protected] 0229: set_car [email protected] primary_color_to [email protected] secondary_color_to [email protected] 0A11: set_car [email protected] tertiary_color_to [email protected] quaternary_color_to 6 0294: set_car [email protected] sprayable 0 0407: store_coords_to [email protected] [email protected] [email protected] from_car [email protected] with_offset 0.0 -5.0 0.0 0395: clear_area 1 at [email protected] [email protected] [email protected] radius 3.0 Car.Create([email protected], [email protected], [email protected], [email protected], [email protected]) Car.Angle([email protected]) = [email protected] 0893: put_trailer [email protected] on_cab [email protected] Model.Destroy([email protected]) Model.Destroy([email protected]) wait 0 if not [email protected] == -1 jf @NONAME_901 Actor.CreateAsDriver([email protected], PedType.Mission1, [email protected], [email protected]) Car.SetDriverBehaviour([email protected], CarMission.Cruise) 00AE: set_car [email protected] traffic_behaviour_to 4 cleo_set_car_engine_on [email protected] engine_state_to 1 Model.Destroy([email protected]) Actor.RemoveReferences([email protected]) :NONAME_901 Car.RemoveReferences([email protected]) Car.RemoveReferences([email protected]) :NONAME_911 not get_random_car_in_sphere_no_save_recursive [email protected] = random_vehicle_near_point [email protected] [email protected] [email protected] in_radius 1000.0 find_next 1 pass_wrecked 1 jf @NONAME_76 jump @NONAME_11 :NONAME_948 wait 0 0A11: set_car [email protected] tertiary_color_to [email protected] quaternary_color_to 6 0294: set_car [email protected] sprayable 0 jump @NONAME_911 Edited October 12, 2022 by Nico Did you see the frightened ones? Did you hear the falling bombs? Did you ever wonder... ...why we had to run for shelter when the promise of a brave new world unfurled beneath a clear blue sky? 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