Buying property

From GTAMods Wiki
Jump to navigation Jump to search

This is a code snippet of a property for sale in Sanny Builder's format and should work in Vice City and San Andreas. This gives you the basic and compact code to create a working script without creating a mission for it. Remember to read the tutorial on how to create a thread before proceeding to implement this code.

 1 :BUY
 2 0006: 1@ = 100 // set price
 3 0007: 2@ = 308.7745 // x-coordinate of pickup
 4 0007: 3@ = -1298.623 // y-coordinate of pickup
 5 0007: 4@ = 11.07 // z-coordinate of pickup
 6 0518: 0@ = create_available_asset_pickup 'PROP_3' at 2@ 3@ 4@ price 1@ // Press ~k~~PED_ANSWER_PHONE~ to buy this property for $~1~.
 7 03A4: name_thread 'BUY' 
 8 
 9 :BUY_10
10 0001: wait 250 ms 
11 00D6: if 
12 0256:   player $PLAYER_CHAR defined 
13 004D: jump_if_false @BUY_10 
14 00D6: if 
15 0038:   $ONMISSION == 0 
16 004D: jump_if_false @BUY_10 
17 00D6: if 
18 0214:   pickup 0@ picked_up 
19 004D: jump_if_false @BUY_10 
20 01B4: set_player $PLAYER_CHAR frozen_state 0 
21 03BF: set_player $PLAYER_CHAR ignored_by_everyone_to 1 
22 02A3: toggle_widescreen 1 
23 015F: set_camera_position 468.3571 1259.458 21.8848 0.0 0.0 0.0 // set your camera location
24 0160: point_camera 469.2978 1259.797 21.8834 2 // set your camera target location
25 00BA: text_styled 'BUYPRO' 5000 ms 2 // Property bought!
26 0394: play_music 1 
27 0001: wait 5000 ms 
28 00D6: if 
29 8256:   not player $PLAYER_CHAR defined 
30 004D: jump_if_false @BUY_176 
31 004E: end_thread 
32 
33 :BUY_176
34 00BE: text_clear_all 
35 0373: set_camera_directly_behind_player 
36 02EB: restore_camera_with_jumpcut 
37 01B4: set_player $PLAYER_CHAR frozen_state 1 
38 03BF: set_player $PLAYER_CHAR ignored_by_everyone_to 0 
39 02A3: toggle_widescreen 0 
40 004E: end_thread

Full Code

Here is a full code to buy a property based on the code in Vice City. The process to buy a property in Vice City and San Andreas involves starting a mission.

Find:

DEFINE MISSIONS

Increment the number of missions by one.

Find the last defined mission and add:

DEFINE MISSION ## AT @BUYPRO

Find:

create_thread

Add above:

create_thread @BUY

Find:

//-------------Mission 0---------------

Add above:

 1 :BUY
 2 0006: 1@ = 100 // set price
 3 0007: 2@ = 308.7745 // x-coordinate of pickup
 4 0007: 3@ = -1298.623 // y-coordinate of pickup
 5 0007: 4@ = 11.07 // z-coordinate of pickup
 6 0518: 0@ = create_available_asset_pickup 'PROP_3' at 2@ 3@ 4@ price 1@ // Press ~k~~PED_ANSWER_PHONE~ to buy this property for $~1~.
 7 03A4: name_thread 'BUY' 
 8 
 9 :BUY_10
10 0001: wait 250 ms 
11 00D6: if 
12 0256:   player $PLAYER_CHAR defined 
13 004D: jump_if_false @BUY_87 
14 00D6: if 
15 0038:   $ONMISSION == 0 
16 004D: jump_if_false @BUY_87 
17 00D6: if 
18 03EE:   player $PLAYER_CHAR controllable 
19 004D: jump_if_false @BUY_87 
20 00D6: if 
21 0214:   pickup 0@ picked_up 
22 004D: jump_if_false @BUY_87 
23 0417: start_mission BUYPRO 
24 004E: end_thread 
25 
26 :BUY_87
27 0002: jump @BUY_10

Scroll all the way to the end of the script and add:

 1 //-------------Mission ##---------------
 2 
 3 :BUYPRO
 4 03A4: name_thread 'BUYPRO' 
 5 0004: $ONMISSION = 1
 6 0169: set_fade_color 0 0 1 
 7 016A: fade 0 500 ms 
 8 01B4: set_player $PLAYER_CHAR frozen_state 0 
 9 03BF: set_player $PLAYER_CHAR ignored_by_everyone_to 1 
10 03F4: set_all_vehicles_apply_damage_rules 0 
11 
12 :BUYPRO_50
13 00D6: if 
14 016B:   fading 
15 004D: jump_if_false @BUYPRO_92 
16 0001: wait 0 ms 
17 00D6: if 
18 8256:   not player $PLAYER_CHAR defined 
19 004D: jump_if_false @BUYPRO_85 
20 004E: end_thread 
21 
22 :BUYPRO_85
23 0002: jump @BUYPRO_50 
24 
25 :BUYPRO_92
26 02A3: toggle_widescreen 1 
27 0169: set_fade_color 0 0 1 
28 016A: fade 1 500 ms 
29 015F: set_camera_position 468.3571 1259.458 21.8848 0.0 0.0 0.0 // set your camera location
30 0160: point_camera 469.2978 1259.797 21.8834 2 // set your camera target location
31 
32 :BUYPRO_162
33 00D6: if 
34 016B:   fading 
35 004D: jump_if_false @BUYPRO_204 
36 0001: wait 0 ms 
37 00D6: if 
38 8256:   not player $PLAYER_CHAR defined 
39 004D: jump_if_false @BUYPRO_197 
40 004E: end_thread 
41 
42 :BUYPRO_197
43 0002: jump @BUYPRO_162 
44 
45 :BUYPRO_204
46 00BA: text_styled 'BUYPRO' 5000 ms 2 // Property bought!
47 0394: play_music 1 
48 043C: set_game_sounds_disable_on_fade 0 
49 0001: wait 5000 ms 
50 0169: set_fade_color 0 0 1 
51 016A: fade 0 500 ms 
52 
53 :BUYPRO_247
54 00D6: if 
55 016B:   fading 
56 004D: jump_if_false @BUYPRO_293 
57 0001: wait 0 ms 
58 00D6: if 
59 8256:   not player $PLAYER_CHAR defined 
60 004D: jump_if_false @BUYPRO_286 
61 043C: set_game_sounds_disable_on_fade 1 
62 004E: end_thread 
63 
64 :BUYPRO_286
65 0002: jump @BUYPRO_247 
66 
67 :BUYPRO_293
68 0373: set_camera_directly_behind_player 
69 02EB: restore_camera_with_jumpcut 
70 01B4: set_player $PLAYER_CHAR frozen_state 1 
71 03BF: set_player $PLAYER_CHAR ignored_by_everyone_to 0 
72 03F4: set_all_vehicles_apply_damage_rules 1 
73 02A3: toggle_widescreen 0 
74 0169: set_fade_color 0 0 1 
75 
76 :BUYPRO_327
77 016A: fade 1 500 ms 
78 00D6: if 
79 016B:   fading 
80 004D: jump_if_false @BUYPRO_358 
81 0001: wait 0 ms 
82 0002: jump @BUYPRO_327 
83 
84 :BUYPRO_358
85 00D6: if 
86 0256:   player $PLAYER_CHAR defined 
87 004D: jump_if_false @BUYPRO_379 
88 011C: actor $PLAYER_ACTOR clear_objective 
89 
90 :BUYPRO_379
91 043C: set_game_sounds_disable_on_fade 1 
92 0004: $ONMISSION = 0 
93 00D8: mission_cleanup 
94 004E: end_thread 
95 0051: return