Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

savidge

[SA] Is this possible with CLEO?

Recommended Posts

savidge

Hey there. :)

I like the "realism" mods in San Andreas and I wanted to try and make a CLEO mod that emits a beeping (or an alert) sound if you leave the car door open. Is it possible to make it so I have a .mp3 file in a seperate folder (e.g. root/CLEO/sfx) and for it to loop if I leave a car door open?

EDIT: and is it also possible to only assign the open door beeps to cars of a certain category via cargrp.dat?

EDIT 2: This video explains what I want to achieve, but the only thing different is that this was made in GTA IV:

 

Edited by SergeantSavidge

Share this post


Link to post
Share on other sites
HeresOtis

Yes it's possible, just gotta put your mind to it.

Share this post


Link to post
Share on other sites
savidge

Yes it's possible, just gotta put your mind to it.

OK, at least I know that it's possible. Thanks for your response.

Is there a specific opcode or something that handles vehicle doors though? Or should I go about it in a different way?

EDIT: if it wasn't obvious enough, I'm kind of a n00b in terms of CLEO. :sly:

Edited by SergeantSavidge

Share this post


Link to post
Share on other sites
goodidea82

(please ignore this post)

Edited by goodidea82

Share this post


Link to post
Share on other sites
nyolc8

Check the doors rotation angles?

Share this post


Link to post
Share on other sites
savidge

I think this is how I can get it to play a sound, but I just need to find how I can get it to play when I leave a car door open:

00D6: if 0AAB:   file_exists "CLEO\sfx\ajar.mp3" 004D: jump_if_false @AJAR_11 

Share this post


Link to post
Share on other sites
savidge

These will be the need opcodes

08A7:   is_car_door_fully_open [email protected] door 20AC1: load_3d_audio_stream "sample.mp3" store_to [email protected]: set_play_3d_audio_stream_at_coordinates $hMP3 to [email protected] [email protected] [email protected]: set_audio_stream_state $hMP3 to 1

Dude, thank you so much. :^:

EDIT:

08A7:   is_car_door_fully_open [email protected] door 2

that line is wrong because Sanny Builder refuses to compile it. It says the maximum variable is [email protected], so if I change the 34 to 33 will it still work without problems?

EDIT 2: I just tried putting [email protected] but it crashes when I enter a vehicle.

EDIT 3: I removed the maximum variable limit, put it back to [email protected] and it still crashes.

EDIT 4 (so many edits, my bad): This is the current script I have, I managed to prevent it from crashing but I don't know if everything is linked up correctly. If someone could take a look at my script in this spoiler and tell me what to change to get it to work, that would be a massive help:

 

 

{$CLEO .cs}0000: NOP03A4: name_thread "AJAR" :AJAR_00001: wait 0 msif0256:   player $PLAYER_CHAR defined 004D: jump_if_false @AJAR_000D6: if and8449:   not actor $PLAYER_ACTOR in_a_car 09E7:   player $PLAYER_CHAR not_frozen 0AB0:   key_pressed 80 004D: jump_if_false @AJAR_0 if08A7:   is_car_door_fully_open [email protected] door 2004D: jump_if_false @AJAR_00AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to [email protected]: set_play_3d_audio_stream_at_coordinates $hMP3 to [email protected] [email protected] [email protected]: set_audio_stream_state $hMP3 to 1

 

 

Edited by SergeantSavidge

Share this post


Link to post
Share on other sites
HeresOtis

 

These will be the need opcodes

08A7:   is_car_door_fully_open [email protected] door 20AC1: load_3d_audio_stream "sample.mp3" store_to [email protected]: set_play_3d_audio_stream_at_coordinates $hMP3 to [email protected] [email protected] [email protected]: set_audio_stream_state $hMP3 to 1

Dude, thank you so much. :^:

EDIT:

08A7:   is_car_door_fully_open [email protected] door 2

that line is wrong because Sanny Builder refuses to compile it. It says the maximum variable is [email protected], so if I change the 34 to 33 will it still work without problems?

EDIT 2: I just tried putting [email protected] but it crashes when I enter a vehicle.

EDIT 3: I removed the maximum variable limit, put it back to [email protected] and it still crashes.

EDIT 4 (so many edits, my bad): This is the current script I have, I managed to prevent it from crashing but I don't know if everything is linked up correctly. If someone could take a look at my script in this spoiler and tell me what to change to get it to work, that would be a massive help:

 

 

{$CLEO .cs}0000: NOP03A4: name_thread "AJAR" :AJAR_00001: wait 0 msif0256:   player $PLAYER_CHAR defined 004D: jump_if_false @AJAR_000D6: if and8449:   not actor $PLAYER_ACTOR in_a_car 09E7:   player $PLAYER_CHAR not_frozen 0AB0:   key_pressed 80 004D: jump_if_false @AJAR_0 if08A7:   is_car_door_fully_open [email protected] door 2004D: jump_if_false @AJAR_00AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to [email protected]: set_play_3d_audio_stream_at_coordinates $hMP3 to [email protected] [email protected] [email protected]: set_audio_stream_state $hMP3 to 1

 

 

 

You really are a beginner. No worries, everyone has to start somewhere. :^:

You never defined a vehicle the player is in.

[email protected] is only used in mission scripts. You need to use a variable less than [email protected]

Share this post


Link to post
Share on other sites
savidge

You really are a beginner. No worries, everyone has to start somewhere. :^:

You never defined a vehicle the player is in.

[email protected] is only used in mission scripts. You need to use a variable less than [email protected]

heh, yeah. I guess it was obvious to see I'm a bit of a n00b.

So, anything less than [email protected] is fine then?

Share this post


Link to post
Share on other sites
HeresOtis

 

You really are a beginner. No worries, everyone has to start somewhere. :^:

You never defined a vehicle the player is in.

[email protected] is only used in mission scripts. You need to use a variable less than [email protected]

heh, yeah. I guess it was obvious to see I'm a bit of a n00b.

So, anything less than [email protected] is fine then?

 

Yes indeed (to both sentences).

Share this post


Link to post
Share on other sites
savidge

Yes indeed (to both sentences).

I tried putting [email protected] but nothing changes. It doesn't crash but no sound is played when I open a car door.

Share this post


Link to post
Share on other sites
uokka

It can get quite annoying if the doors don't completely close and the sound plays on and on.

 

The following code is based on my modified script from the BTTF mod mixed with yours.

NOTE: Totally untested.

 

 

{$CLEO .cs}0000: NOP03A4: name_thread "AJAR" 0AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to [email protected] WHILE TRUE    wait 250    if Player.Defined($PLAYER_CHAR)    jf CONTINUE     if and        0449: actor $PLAYER_ACTOR in_a_car        09E7: player $PLAYER_CHAR not_frozen     jf CONTINUE     if 0AB0: key_pressed 80    then CONTINUE    end     03C0: [email protected] = actor $PLAYER_ACTOR car     if Car.Wrecked([email protected])    then CONTINUE    end     if 08A7:   car [email protected] componentB 2 opened_or_not_present    then 0006: [email protected] = 1    else 0006: [email protected] = 0    end    if 08A7:   car [email protected] componentB 3 opened_or_not_present    then 0006: [email protected] = 1    else 0006: [email protected] = 0    end     095F: get_car [email protected] componentA 2 rotation_to [email protected]    095F: get_car [email protected] componentA 3 rotation_to [email protected]     // left door    if [email protected] == 0    then        if not [email protected] == 0.0        then            if not [email protected] >= 0.2            then                0AC5: link_3d_audiostream [email protected] to_vehicle [email protected]                0AAD: set_mp3 [email protected] perform_action 1            end            [email protected] = 1        end    else        if [email protected] == 0.0        then            [email protected] = 0            0AAD: set_mp3 [email protected] perform_action 0        else            [email protected] /= -1.256637            if and                [email protected] >= 0.25                not [email protected] >= 1.00            then                [email protected] += 0.1                08A6: set_car [email protected] componentB 2 rotation_to [email protected]            end        end    end     //right door    if [email protected] == 0    then        if not [email protected] == 0.0        then            if not [email protected] >= 0.2            then                   // play sound                0AC5: link_3d_audiostream [email protected] to_vehicle [email protected]                0AAD: set_mp3 [email protected] perform_action 0                0ABC: set_audiostream [email protected] volume 0.5                0AAD: set_mp3 [email protected] perform_action 1            end            [email protected] = 1        end    else        if [email protected] == 0.0        then            [email protected] = 0            0AAD: set_mp3 [email protected] perform_action 0        else            [email protected] /= 1.256637            if and                [email protected] >= 0.25                not [email protected] >= 1.00            then                [email protected] += 0.1                08A6: set_car [email protected] componentB 3 rotation_to [email protected]            end        end    end END

Share this post


Link to post
Share on other sites
savidge

 

It can get quite annoying if the doors don't completely close and the sound plays on and on.

 

The following code is based on my modified script from the BTTF mod mixed with yours.

NOTE: Totally untested.

 

 

 

{$CLEO .cs}0000: NOP03A4: name_thread "AJAR" 0AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to [email protected] WHILE TRUE    wait 250    if Player.Defined($PLAYER_CHAR)    jf CONTINUE     if and        0449: actor $PLAYER_ACTOR in_a_car        09E7: player $PLAYER_CHAR not_frozen     jf CONTINUE     if 0AB0: key_pressed 80    then CONTINUE    end     03C0: [email protected] = actor $PLAYER_ACTOR car     if Car.Wrecked([email protected])    then CONTINUE    end     if 08A7:   car [email protected] componentB 2 opened_or_not_present    then 0006: [email protected] = 1    else 0006: [email protected] = 0    end    if 08A7:   car [email protected] componentB 3 opened_or_not_present    then 0006: [email protected] = 1    else 0006: [email protected] = 0    end     095F: get_car [email protected] componentA 2 rotation_to [email protected]    095F: get_car [email protected] componentA 3 rotation_to [email protected]     // left door    if [email protected] == 0    then        if not [email protected] == 0.0        then            if not [email protected] >= 0.2            then                0AC5: link_3d_audiostream [email protected] to_vehicle [email protected]                0AAD: set_mp3 [email protected] perform_action 1            end            [email protected] = 1        end    else        if [email protected] == 0.0        then            [email protected] = 0            0AAD: set_mp3 [email protected] perform_action 0        else            [email protected] /= -1.256637            if and                [email protected] >= 0.25                not [email protected] >= 1.00            then                [email protected] += 0.1                08A6: set_car [email protected] componentB 2 rotation_to [email protected]            end        end    end     //right door    if [email protected] == 0    then        if not [email protected] == 0.0        then            if not [email protected] >= 0.2            then                   // play sound                0AC5: link_3d_audiostream [email protected] to_vehicle [email protected]                0AAD: set_mp3 [email protected] perform_action 0                0ABC: set_audiostream [email protected] volume 0.5                0AAD: set_mp3 [email protected] perform_action 1            end            [email protected] = 1        end    else        if [email protected] == 0.0        then            [email protected] = 0            0AAD: set_mp3 [email protected] perform_action 0        else            [email protected] /= 1.256637            if and                [email protected] >= 0.25                not [email protected] >= 1.00            then                [email protected] += 0.1                08A6: set_car [email protected] componentB 3 rotation_to [email protected]            end        end    end END

 

 

Hi uokka, thanks for helping (I love your BTTF script btw ;)) but it crashes at the end of the loading screen.

Share this post


Link to post
Share on other sites
uokka

Yeah, I didn't expect it to work. q:

But it might help you understand cleo scripts a little more (like not overwiting variables before they were used). Also I thought you need a more complex loop.

Share this post


Link to post
Share on other sites
HeresOtis

Untested.

{$CLEO}0000:const    DRIVER_DOOR             = 2    PASSGR_DOOR             = 3        DoorAudio1              = [email protected]    DoorAudio2              = [email protected]    Plyr_Veh                = [email protected]    fDoorAngle              = [email protected]    IsDriverDoorAlreadyOpen = [email protected]    IsPassgrDoorAlreadyOpen = [email protected]    DidPlayerSwitchVehicles = [email protected]    end // const0AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to DoorAudio10AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to DoorAudio2while true    wait 0    if        0256:   is_player_playing $PLAYER_CHAR    then        if            $ACTIVE_INTERIOR == 0        then            0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]            [email protected] += 0x58C // Last/current driven car            0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]            if                [email protected] > 0            then                    0AEB: get_vehicle_pointer_handle [email protected] store_to Plyr_Veh                if                    8119:   NOT is_car_dead Plyr_Veh                then                    IsDriverDoorAlreadyOpen = false                    IsPassgrDoorAlreadyOpen = false                    DidPlayerSwitchVehicles = false                                    while true                        wait 0                        if and                            0256:   is_player_playing $PLAYER_CHAR                            $ACTIVE_INTERIOR == 0                        then                            gosub @CheckIfDrivenVehicleSwitched                            if                                DidPlayerSwitchVehicles == true                            then                                break                            end                            if                                8119:   NOT is_car_dead Plyr_Veh                            then                                if                                    IsDriverDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio1 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio1 to 1                                        0AAD: set_audio_stream_state DoorAudio1 to 1    // play                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                                    end                                end                                 if                                    IsPassgrDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio2 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio2 to 1                                        0AAD: set_audio_stream_state DoorAudio2 to 1    // play                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                                    end                                end                                        else                                break                            end                        else                            break                        end                    end                    0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                    0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                    01C3: mark_car_as_no_longer_needed Plyr_Veh                end            end        end    endend                    :CheckIfDrivenVehicleSwitchedif    DidPlayerSwitchVehicles == falsethen    0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]    [email protected] += 0x58C // Last/current driven car    0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]    if        [email protected] > 0    then            0AEB: get_vehicle_pointer_handle [email protected] store_to [email protected]        if            8119:   NOT is_car_dead [email protected]        then            if                803B:   Plyr_Veh <> [email protected]            then                DidPlayerSwitchVehicles = true            end        end    endendreturn

Share this post


Link to post
Share on other sites
savidge

Untested.

 

 

{$CLEO}0000:const    DRIVER_DOOR             = 2    PASSGR_DOOR             = 3        DoorAudio1              = [email protected]    DoorAudio2              = [email protected]    Plyr_Veh                = [email protected]    fDoorAngle              = [email protected]    IsDriverDoorAlreadyOpen = [email protected]    IsPassgrDoorAlreadyOpen = [email protected]    DidPlayerSwitchVehicles = [email protected]    end // const0AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to DoorAudio10AC1: load_3d_audio_stream "CLEO/sfx/ajar.mp3" store_to DoorAudio2while true    wait 0    if        0256:   is_player_playing $PLAYER_CHAR    then        if            $ACTIVE_INTERIOR == 0        then            0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]            [email protected] += 0x58C // Last/current driven car            0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]            if                [email protected] > 0            then                    0AEB: get_vehicle_pointer_handle [email protected] store_to Plyr_Veh                if                    8119:   NOT is_car_dead Plyr_Veh                then                    IsDriverDoorAlreadyOpen = false                    IsPassgrDoorAlreadyOpen = false                    DidPlayerSwitchVehicles = false                                    while true                        wait 0                        if and                            0256:   is_player_playing $PLAYER_CHAR                            $ACTIVE_INTERIOR == 0                        then                            gosub @CheckIfDrivenVehicleSwitched                            if                                DidPlayerSwitchVehicles == true                            then                                break                            end                            if                                8119:   NOT is_car_dead Plyr_Veh                            then                                if                                    IsDriverDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio1 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio1 to 1                                        0AAD: set_audio_stream_state DoorAudio1 to 1    // play                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                                    end                                end                                 if                                    IsPassgrDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio2 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio2 to 1                                        0AAD: set_audio_stream_state DoorAudio2 to 1    // play                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                                    end                                end                                        else                                break                            end                        else                            break                        end                    end                    0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                    0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                    01C3: mark_car_as_no_longer_needed Plyr_Veh                end            end        end    endend                    :CheckIfDrivenVehicleSwitchedif    DidPlayerSwitchVehicles == falsethen    0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]    [email protected] += 0x58C // Last/current driven car    0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]    if        [email protected] > 0    then            0AEB: get_vehicle_pointer_handle [email protected] store_to [email protected]        if            8119:   NOT is_car_dead [email protected]        then            if                803B:   Plyr_Veh <> [email protected]            then                DidPlayerSwitchVehicles = true            end        end    endendreturn

 

 

That crashes at the end of the loading screen too. Thanks for trying to help me, I'll try to look into CLEO a bit more. :D

Share this post


Link to post
Share on other sites
uokka

Focus on HeresOtis' script.

Nice layout. Good readability.

 

--

 

EDIT: Do you have that sound file already in place? If so, might be bad audio format. If not, I think it shouldn't crash.

 

Oh, needs CLEO 4 and v1.0 US exe.

Edited by uokka

Share this post


Link to post
Share on other sites
savidge

EDIT: Do you have that sound file already in place? If so, might be bad audio format. If not, I think it shouldn't crash.

 

Oh, needs CLEO 4 and v1.0 US exe.

yeah, I made a folder within the CLEO folder called "sfx". And I don't really know how to find out specific facts about an audio file (if you do then tell me and I'll give you the info) but from clicking on Properties I can see that it's an 128kbps MP3. Should it be in WAV format or is MP3 acceptable for CLEO use?

Share this post


Link to post
Share on other sites
savidge

Thats OK. But same as here:

http://gtaforums.com/topic/669520-sarel-mod-loader/?p=1066190016

 

16 bit PCM

OK, I'll convert it and see if it makes a difference. Thanks for the help too. :)

 

EDIT: Looks like 16 bit PCM is only for WAV files, can WAV files still be read by CLEO (I'll change the file path to ajar.wav in the script)?

Edited by SergeantSavidge

Share this post


Link to post
Share on other sites
uokka

Doh! Silly me.
128kbps and any Hz (I use 22050 but 44k works as well) .mp3 files. Maybe mono is required.
WAVE I don't know. Have fun finding out. q:

Edited by uokka

Share this post


Link to post
Share on other sites
savidge

Doh! Silly me.

128kbps and any Hz (I use 22050 but 44k works as well) .mp3 files. Maybe mono is required.

WAVE I don't know. Have fun finding out. q:

oh, well it's a WAV file now, hehe. but it still crashes at the end of the loadscreen so I don't think it matters if it's an MP3 or WAV.

Share this post


Link to post
Share on other sites
uokka

For testing, use a sound file that you know it works (like bttf keypad "beeps").

Then maybe SCRLog can help to make the script snippet usable.

Share this post


Link to post
Share on other sites
savidge

I have no idea how to use that. :O

Share this post


Link to post
Share on other sites
uokka

Yeah, noticed that, too. Personally, I find the new names kinda confusing so I just rearranged the parameters for some opcodes to prevent it from crashing.

 

Tested result based on HeresOtis' script but changed the behavior a tiny bit:

 

 

{$CLEO}0000:const    DOOR_FL                 = 2    DOOR_FR                 = 3    DOOR_RL                 = 4    DOOR_RR                 = 5        DoorAudio               = [email protected]    Player_Veh              = [email protected]    DidPlayerSwitchVehicles = [email protected]    fDoorAngle              = [email protected]    IsAllDoorsClosed        = [email protected]    end // const0AC1: DoorAudio = load_3d_audio_stream "CLEO\AUDIO\1.mp3"WHILE TRUE    wait 0    if        0256:   is_player_playing $PLAYER_CHAR    then        if            $ACTIVE_INTERIOR == 0        then            0A96: [email protected] = get_char_pointer $PLAYER_ACTOR            [email protected] += 0x58C // Last/current driven car            0A8D: [email protected] = read_memory [email protected] size 4 vp 0            if                [email protected] > 0            then                    0AEB: Player_Veh = get_vehicle_pointer_handle [email protected]                if                    8119:   NOT is_car_dead Player_Veh                then                    DidPlayerSwitchVehicles = false                                    WHILE TRUE                        wait 750                        if and                            0256:   is_player_playing $PLAYER_CHAR                            $ACTIVE_INTERIOR == 0                        then                            gosub @CheckIfDrivenVehicleSwitched                            if                                DidPlayerSwitchVehicles == true                            then                                break                            end                            if                                8119:   NOT is_car_dead Player_Veh                            then                                gosub @CheckIfVehicleDoorsClosed                                if                                    IsAllDoorsClosed == false                                then                                    0AC5: set_play_3d_audio_stream_at_car DoorAudio car Player_Veh                                    0AAD: set_audio_stream_state DoorAudio to 1    // play                                else                                    0AAD: set_audio_stream_state DoorAudio to 0    // stop                                end                             else                                break                            end                        else                            break                        end                    END // WHILE                    0AAD: set_audio_stream_state DoorAudio to 0    // stop                    01C3: mark_car_as_no_longer_needed Player_Veh                end            end        end    endEND // WHILE                    :CheckIfDrivenVehicleSwitchedif    DidPlayerSwitchVehicles == falsethen    0A96: [email protected] = get_char_pointer $PLAYER_ACTOR     [email protected] += 0x58C // Last/current driven car    0A8D: [email protected] = read_memory [email protected] size 4 vp 0    if        [email protected] > 0    then            0AEB: [email protected] = get_vehicle_pointer_handle [email protected]        if            8119:   NOT is_car_dead [email protected]        then            if                803B:   Player_Veh <> [email protected]            then                DidPlayerSwitchVehicles = true            end        end    endendreturn:CheckIfVehicleDoorsClosed095F: get_door_angle_ratio Player_Veh door DOOR_FL store_to fDoorAngle // Front Leftif fDoorAngle < 0.0then IsAllDoorsClosed = falseelse    095F: get_door_angle_ratio Player_Veh door DOOR_FR store_to fDoorAngle // Front Right    if fDoorAngle > 0.0    then IsAllDoorsClosed = false    else        095F: get_door_angle_ratio Player_Veh door DOOR_RL store_to fDoorAngle // Rear Left        if fDoorAngle < 0.0        then IsAllDoorsClosed = false        else            095F: get_door_angle_ratio Player_Veh door DOOR_RR store_to fDoorAngle // Rear Right            if fDoorAngle > 0.0            then IsAllDoorsClosed = false            else                IsAllDoorsClosed = true            end        end    endendreturn

 

Share this post


Link to post
Share on other sites
savidge

Yeah, noticed that, too. Personally, I find the new names kinda confusing so I just rearranged the parameters for some opcodes to prevent it from crashing.

 

Tested result based on HeresOtis' script but changed the behavior a tiny bit:

 

 

{$CLEO}0000:const    DOOR_FL                 = 2    DOOR_FR                 = 3    DOOR_RL                 = 4    DOOR_RR                 = 5        DoorAudio               = [email protected]    Player_Veh              = [email protected]    DidPlayerSwitchVehicles = [email protected]    fDoorAngle              = [email protected]    IsAllDoorsClosed        = [email protected]    end // const0AC1: DoorAudio = load_3d_audio_stream "CLEO\AUDIO\1.mp3"WHILE TRUE    wait 0    if        0256:   is_player_playing $PLAYER_CHAR    then        if            $ACTIVE_INTERIOR == 0        then            0A96: [email protected] = get_char_pointer $PLAYER_ACTOR            [email protected] += 0x58C // Last/current driven car            0A8D: [email protected] = read_memory [email protected] size 4 vp 0            if                [email protected] > 0            then                    0AEB: Player_Veh = get_vehicle_pointer_handle [email protected]                if                    8119:   NOT is_car_dead Player_Veh                then                    DidPlayerSwitchVehicles = false                                    WHILE TRUE                        wait 750                        if and                            0256:   is_player_playing $PLAYER_CHAR                            $ACTIVE_INTERIOR == 0                        then                            gosub @CheckIfDrivenVehicleSwitched                            if                                DidPlayerSwitchVehicles == true                            then                                break                            end                            if                                8119:   NOT is_car_dead Player_Veh                            then                                gosub @CheckIfVehicleDoorsClosed                                if                                    IsAllDoorsClosed == false                                then                                    0AC5: set_play_3d_audio_stream_at_car DoorAudio car Player_Veh                                    0AAD: set_audio_stream_state DoorAudio to 1    // play                                else                                    0AAD: set_audio_stream_state DoorAudio to 0    // stop                                end                             else                                break                            end                        else                            break                        end                    END // WHILE                    0AAD: set_audio_stream_state DoorAudio to 0    // stop                    01C3: mark_car_as_no_longer_needed Player_Veh                end            end        end    endEND // WHILE                    :CheckIfDrivenVehicleSwitchedif    DidPlayerSwitchVehicles == falsethen    0A96: [email protected] = get_char_pointer $PLAYER_ACTOR     [email protected] += 0x58C // Last/current driven car    0A8D: [email protected] = read_memory [email protected] size 4 vp 0    if        [email protected] > 0    then            0AEB: [email protected] = get_vehicle_pointer_handle [email protected]        if            8119:   NOT is_car_dead [email protected]        then            if                803B:   Player_Veh <> [email protected]            then                DidPlayerSwitchVehicles = true            end        end    endendreturn:CheckIfVehicleDoorsClosed095F: get_door_angle_ratio Player_Veh door DOOR_FL store_to fDoorAngle // Front Leftif fDoorAngle < 0.0then IsAllDoorsClosed = falseelse    095F: get_door_angle_ratio Player_Veh door DOOR_FR store_to fDoorAngle // Front Right    if fDoorAngle > 0.0    then IsAllDoorsClosed = false    else        095F: get_door_angle_ratio Player_Veh door DOOR_RL store_to fDoorAngle // Rear Left        if fDoorAngle < 0.0        then IsAllDoorsClosed = false        else            095F: get_door_angle_ratio Player_Veh door DOOR_RR store_to fDoorAngle // Rear Right            if fDoorAngle > 0.0            then IsAllDoorsClosed = false            else                IsAllDoorsClosed = true            end        end    endendreturn

 

Yay, it works perfectly! I can't thank you enough, I wish there was a "Love this" button, hahaha.

Share this post


Link to post
Share on other sites
HeresOtis

And here's my updated script, tested and working, for both the driver and passenger doors, independently. Still need to update your ini defintions.

{$CLEO}0000:const    DRIVER_DOOR             = 2    PASSGR_DOOR             = 3        DoorAudio1              = [email protected]    DoorAudio2              = [email protected]    Plyr_Veh                = [email protected]    fDoorAngle              = [email protected]    IsDriverDoorAlreadyOpen = [email protected]    IsPassgrDoorAlreadyOpen = [email protected]    DidPlayerSwitchVehicles = [email protected]    end // const0AC1: load_3d_audio_stream "CLEO/alarm.mp3" store_to DoorAudio10AC1: load_3d_audio_stream "CLEO/alarm.mp3" store_to DoorAudio2while true    wait 0    if        0256:   is_player_playing $PLAYER_CHAR    then        if            $ACTIVE_INTERIOR == 0        then            0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]            [email protected] += 0x58C // Last/current driven car            0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]            if                [email protected] > 0            then                    0AEB: get_vehicle_pointer_handle [email protected] store_to Plyr_Veh                if                    8119:   NOT is_car_dead Plyr_Veh                then                    IsDriverDoorAlreadyOpen = false                    IsPassgrDoorAlreadyOpen = false                    DidPlayerSwitchVehicles = false                                    while true                        wait 0                        if and                            0256:   is_player_playing $PLAYER_CHAR                            $ACTIVE_INTERIOR == 0                        then                            gosub @CheckIfDrivenVehicleSwitched                            if                                DidPlayerSwitchVehicles == true                            then                                break                            end                            if                                8119:   NOT is_car_dead Plyr_Veh                            then                                if                                    IsDriverDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    0097: abs_lvar_float fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio1 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio1 to 1                                        0AAD: set_audio_stream_state DoorAudio1 to 1    // play                                        IsDriverDoorAlreadyOpen = true                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door DRIVER_DOOR store_to fDoorAngle                                    0097: abs_lvar_float fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                                        IsDriverDoorAlreadyOpen = false                                    end                                end                                 if                                    IsPassgrDoorAlreadyOpen == false                                then                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    0097: abs_lvar_float fDoorAngle                                    if                                        fDoorAngle > 0.0                                    then                                        0AC5: set_play_3d_audio_stream_at_car DoorAudio2 car Plyr_Veh                                        0AC0: set_audio_stream_looped DoorAudio2 to 1                                        0AAD: set_audio_stream_state DoorAudio2 to 1    // play                                        IsPassgrDoorAlreadyOpen = true                                    end                                else                                    095F: get_door_angle_ratio Plyr_Veh door PASSGR_DOOR store_to fDoorAngle                                    0097: abs_lvar_float fDoorAngle                                    if                                        fDoorAngle == 0.0                                    then                                        0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                                        IsPassgrDoorAlreadyOpen = false                                    end                                end                                        else                                break                            end                        else                            break                        end                    end                    0AAD: set_audio_stream_state DoorAudio1 to 0    // stop                    0AAD: set_audio_stream_state DoorAudio2 to 0    // stop                    01C3: mark_car_as_no_longer_needed Plyr_Veh                end            end        end    endend                    :CheckIfDrivenVehicleSwitchedif    DidPlayerSwitchVehicles == falsethen    0A96: get_char_pointer $PLAYER_ACTOR store_to [email protected]    [email protected] += 0x58C // Last/current driven car    0A8D: read_memory [email protected] size 4 vp 0 store_to [email protected]    if        [email protected] > 0    then            0AEB: get_vehicle_pointer_handle [email protected] store_to [email protected]        if            8119:   NOT is_car_dead [email protected]        then            if                803B:   Plyr_Veh <> [email protected]            then                DidPlayerSwitchVehicles = true            end        end    endendreturn

Share this post


Link to post
Share on other sites
uokka

[...], I wish there was a "Love this" button, hahaha.

I know that phrase.. (:

My pleasure. Have fun!

 

 

EDIT:

 

[...], for both the driver and passenger doors, independently. [...]

I really like the code layout you use so I edited yours instead of mine to include rear doors for four door vehicles and also I don't see a reason for multible beep sounds.

Edited by uokka

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.