Save pickup

From GTAMods Wiki
Jump to navigation Jump to search

This is a code snippet for a save pickup in Sanny Builder's format for Vice City and San Andreas. The code is based on the save pickup script in Vice City.

const
PICKUP_1_X = 0.0  // set your pickup x position
PICKUP_1_Y = 0.0  // set your pickup y position
PICKUP_1_Z = 0.0  // set your pickup z position
SET_PLAYER_1_X = 0.0  // set your player x position
SET_PLAYER_1_Y = 0.0  // set your player y position
SET_PLAYER_1_Z = 0.0  // set your player z position
SET_PLAYER_1_ANGLE = 0.0  // set your player angle
PICKUP_1 = [email protected]
PICKUP_1_CREATED = [email protected]
end

PICKUP_1_CREATED = false
while true
    wait 250
    if
        0256:   player $PLAYER_CHAR defined
    then
        if
            03EE:   player $PLAYER_CHAR controllable
        then
            if
                $ONMISSION == 0
            then
                if
                    PICKUP_1_CREATED == false
                then
                    0213: PICKUP_1 = create_pickup #PICKUPSAVE type 3 at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
                    PICKUP_1_CREATED = true
                end
                if
                    0214:   pickup PICKUP_1 picked_up
                then
                    gosub @SAVE_BEGIN
                    if
                        0256:   player $PLAYER_CHAR defined
                    then
                        0215: destroy_pickup PICKUP_1
                        0213: PICKUP_1 = create_pickup #PICKUPSAVE type 3 at PICKUP_1_X PICKUP_1_Y PICKUP_1_Z
                        016A: fade 1 1000 ms
                        0395: clear_area 1 at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z radius 1.0
                        00A1: put_actor $PLAYER_ACTOR at SET_PLAYER_1_X SET_PLAYER_1_Y SET_PLAYER_1_Z
                        0173: set_actor $PLAYER_ACTOR z_angle_to SET_PLAYER_1_ANGLE
                    end
                    gosub @SAVE_END
                end
            else
                if
                    PICKUP_1_CREATED == true
                then
                    0215: destroy_pickup PICKUP_1
                    PICKUP_1_CREATED = false
                end
            end
        end
    end
end

:SAVE_BEGIN
$ONMISSION = 1
01B4: set_player $PLAYER_CHAR can_move 0
03D8: show_save_screen
wait 0
while if 83D9:   not save_done
    wait 0
end
0169: set_fade_color 0 0 0
016A: fade 0 1000 ms
if
    0256:   player $PLAYER_CHAR defined
then
    0222: set_player $PLAYER_CHAR health_to 200
    01B4: set_player $PLAYER_CHAR can_move 0
end
return

:SAVE_END
if
    0256:   player $PLAYER_CHAR defined
then
    02EB: restore_camera_with_jumpcut
    0373: set_camera_directly_behind_player
end
wait 500
if
    0256:   player $PLAYER_CHAR defined
then
    01B4: set_player $PLAYER_CHAR can_move 1
    $ONMISSION = 0
end
return

If you want to add this code into the main.scm, read the tutorial on how to create a script.