deltadude Posted August 2, 2005 Share Posted August 2, 2005 I am trying to get a wav file to play (sound_security_alarm) when CJ walks into a marker. here is my code can u help me :WAV03A4: name_thread 'WAVI'0001: wait $default_wait_time ms00D6: if 000FF: actor $PLAYER_ACTOR 0 ()near_point_on_foot 2263.559 -1260.789 23.97656 radius 2.0 2.0 2.0004D: jump_if_false ££WAV03CF: load_wav 42801 as 103D1: play_wav 1004E: end_thread any help is much apreciated Link to comment Share on other sites More sharing options...
Demarest Posted August 2, 2005 Share Posted August 2, 2005 That's not how the original code did it. Do it the way the original code did it. This will include a loop to see if the wav is loaded before you play it. Also, you're limited to WAVs the game came with or ones named just like them. Link to comment Share on other sites More sharing options...
deltadude Posted August 3, 2005 Author Share Posted August 3, 2005 Ok i changed the coding to match some coding I found ingame and it froze after the cutscene at the start of a new game. :audio003A4: name_thread 'audio'00D6: if 000FF: actor $PLAYER_ACTOR 0 ()near_point_on_foot 2263.559 -1260.789 23.97656 radius 2.0 2.0 2.0004D: jump_if_false ££audio0:audio03CF: load_wav 42801 as 1:audio200D6: if 083D0: NOT wav 1 loaded004D: jump_if_false ££audio20001: wait 0 ms00D6: if 08256: NOT player $PLAYER_CHAR defined004D: jump_if_false ££audio30002: jump ££audio4:audio30002: jump ££audio2:audio403D1: play_wav 1004E: end_thread Any ideas why? Link to comment Share on other sites More sharing options...
Opius Posted August 3, 2005 Share Posted August 3, 2005 All loops require a wait command, even if it's 0 milliseconds. Whenever there's an if statement that could loop back on itself, insert a wait command before it. Also, your audio2 label is going to loop ONLY when the wav is loaded, completely defeating the point of the whole loading process. Change that to the normal wav_loaded opcode. Same deal with the player defined check. Just out of interest, are you able to actually read the code and follow the path it could take? Because if you can't troubleshoot basic things like this on your own you're going to have a lot of problems with scripting. Link to comment Share on other sites More sharing options...
deltadude Posted August 3, 2005 Author Share Posted August 3, 2005 Thanks, I can see where the code is going etc. It was just stupid mistake by me that i didn't see some of the errors in it. Link to comment Share on other sites More sharing options...
Demarest Posted August 3, 2005 Share Posted August 3, 2005 Thanks, I can see where the code is going etc. It was just stupid mistake by me that i didn't see some of the errors in it. Yeah, we all run into that. But when it's crashing that's when it's time to take a closer look at it. I'll try and help you grasp the path a bit better. Here's the way your code should look. It contains OP's suggestions and a few of my own. Can you spot the differences? Do you understand why? If not, just ask :audio03A4: name_thread 'audio':audio10001: wait 250 ms00D6: if 00256: player $PLAYER_CHAR defined004D: jump_if_false ££audio100D6: if 000FF: actor $PLAYER_ACTOR 0 ()near_point_on_foot 2263.559 -1260.789 23.97656 radius 2.0 2.0 2.0004D: jump_if_false ££audio103CF: load_wav 42801 as 1:audio20001: wait 0 ms00D6: if 003D0: wav 1 loaded004D: jump_if_false ££audio203D1: play_wav 1004E: end_thread Link to comment Share on other sites More sharing options...
deltadude Posted August 3, 2005 Author Share Posted August 3, 2005 (edited) I already made one that works for me, without the player defined op code. It ain't as complexe, but it will work for me (i added the unload_wav in because I was afraid without it, the game would crash....) :AUDIO_103A4: name_thread 'AUDIO'00D6: if 000FF: actor $PLAYER_ACTOR 0 ()near_point_on_foot 2239.094 -1264.577 24.24618 radius 2.0 2.0 2.00001: wait 0 ms004D: jump_if_false ££AUDIO_103CF: load_wav 1155 as 1:AUDIO_700D6: if 083D0: NOT wav 1 loaded004D: jump_if_false ££AUDIO_120001: wait 0 ms0002: jump ££AUDIO_7:AUDIO_1203D1: play_wav 1040D: unload_wav 1004E: end_thread I know I can make it better but i'm gonna try some other cool things with coding etc. Edited August 3, 2005 by deltadude Link to comment Share on other sites More sharing options...
Demarest Posted August 3, 2005 Share Posted August 3, 2005 I already made one that works for me, without the player defined op code. Doesn't mean it's right. And the player defined check wasn't all that I did. For one, you'll notice that my if loaded check is cleaner, etc. Your code loops the name thread command, you have a wait inside an if... Including the unload wav is a good idea, but if it's the only one you're going to employ, why bother? 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