nordi Posted April 11, 2014 Share Posted April 11, 2014 (edited) Hey I got some errors when running my script, but I have a hard time, to find a solution: I get no error, on visual studio: only on scripthook log: 2014-04-11 16:57:22 - Error during NetHook.Tick: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Scripting.NativeContext2.Invoke(SByte* name, NativeContext2* cxt) at GTA.Native.Function.BaseCall(String Name, Parameter[] Arguments) at GTA.Native.Function.Call(String Name, Parameter[] Arguments) at GTA.Native.Template.Invoke() at GTA.ScriptDomain.RemoteEvent(RemoteEventArgs ev) at GTA.ScriptDomain.ProcessRemoteEvents() at GTA.ScriptDomain.Tick() at GTA.NetHook.Tick() Thanks. Edited April 13, 2014 by nordi Link to comment Share on other sites More sharing options...
pedro2555 Posted April 11, 2014 Share Posted April 11, 2014 I would imagine that GET_SOUND_ID would either need a sound name to look for or a sound played before a call to it. Link to comment Share on other sites More sharing options...
nordi Posted April 11, 2014 Author Share Posted April 11, 2014 Not according to this tutorial: http://gtaxscripting.blogspot.fr/2013/03/tut-playing-native-sounds-and-external.html GET_SOUND_ID must be before the native playing the sound ! Link to comment Share on other sites More sharing options...
pedro2555 Posted April 11, 2014 Share Posted April 11, 2014 BTW, just noticed. an if statement executes the code if the test expression returns true. This: if (call_setup == false){} equals this: if (!call_setup){} And since you know the state of call_setup, you can do it like this, to execute once: if (!call_setup){ call_setup = !call_setup;} Link to comment Share on other sites More sharing options...
pedro2555 Posted April 11, 2014 Share Posted April 11, 2014 Try: soundID = GTA.Native.Function.Call<int>("GET_SOUND_ID"); If it keeps happening, just wait for JulioNIB to come by, he is the man behind the mask. Link to comment Share on other sites More sharing options...
pedro2555 Posted April 11, 2014 Share Posted April 11, 2014 (edited) I was just, again, looking at your code... that is a bit messy I think. Is that method the one called on the tick event ? is it like this: this.Tick += new EventHandler(APA_calls); Edited April 11, 2014 by pedro2555 Link to comment Share on other sites More sharing options...
nordi Posted April 11, 2014 Author Share Posted April 11, 2014 (edited) BTW, just noticed. an if statement executes the code if the test expression returns true. This: if (call_setup == false){} equals this: if (!call_setup){} And since you know the state of call_setup, you can do it like this, to execute once: if (!call_setup){ call_setup = !call_setup;} Thanks for the tips Try: soundID = GTA.Native.Function.Call<int>("GET_SOUND_ID"); If it keeps happening, just wait for JulioNIB to come by, he is the man behind the mask. Still not working ... I was just, again, looking at your code... that is a bit messy I think. Is that method the one called on the tick event ? is it like this: this.Tick += new EventHandler(APA_calls); Indeed; Everything is working: the blip is created,at the specified location, but like I said everything under soundID isn't working ... Messy: I don't know, I make sure the blip isn't already placed on the map, and the sound isn't playing, if not I place the blip, and play the sound, and when the player reach the position I delete the blip. Edited April 13, 2014 by nordi Link to comment Share on other sites More sharing options...
pedro2555 Posted April 11, 2014 Share Posted April 11, 2014 I was just, again, looking at your code... that is a bit messy I think. Is that method the one called on the tick event ? is it like this: this.Tick += new EventHandler(APA_calls); Indeed: this.Interval = 10;this.Tick += new EventHandler(AFA_calls); Everything is working: the blip is created,at the specified location, but like I said everything under soundID isn't working ... Messy: I don't know, I make sure the blip isn't already placed on the map, and the sound isn't playing, if not I place the blip, and play the sound, and when the player reach the position I delete the blip. Then I suggest you to really learn more about the language, your code looks totally wrong. Do you realize that interval at 10, means run this 100 times every second ? Back in the days, when I used to be learning programming, 100 times a second sounded like something that is way to fast do really happen, but believe me, the cheapest Intel laptop processor is capable of way more than that. I can't really see what you are trying to achieve so I will not suggest anything. Link to comment Share on other sites More sharing options...
julionib Posted April 11, 2014 Share Posted April 11, 2014 (edited) the soundID is declared as integer? this line should work fine, i imagine (i use vb.net that is a little different): soundID = GTA.Native.Function.Call<Int32>("GET_SOUND_ID"); you can add a Game.Console.Print(soundID.ToString) after this line to see what you receive from this call, must be bigger or equal 0, also, you need to obtain this sound ID only one time per use, game has a limit that fills very fast, in some seconds you will not get more sound IDs , to keep obtaining sound IDs you need to use RELEASE_SOUND_ID method before get sound id againso, in the startup of your Code you can do the line that get sound ID:soundID = GTA.Native.Function.Call<Int32>("GET_SOUND_ID");and just use it later in the Tick/Loop/Whatever you want if the sound dont need to be stopped (like yours) you can use -1 as sound ID in the playback method: GTA.Native.Function.Call("PLAY_SOUND_FROM_POSITION", -1, "BURGULAR_ALARM_BELL_LOOP", LocationX, LocationY, LocationZ); Edited April 11, 2014 by julionib Link to comment Share on other sites More sharing options...
nordi Posted April 12, 2014 Author Share Posted April 12, 2014 (edited) the soundID is declared as integer? this line should work fine, i imagine (i use vb.net that is a little different): soundID = GTA.Native.Function.Call<Int32>("GET_SOUND_ID"); you can add a Game.Console.Print(soundID.ToString) after this line to see what you receive from this call, must be bigger or equal 0, also, you need to obtain this sound ID only one time per use, game has a limit that fills very fast, in some seconds you will not get more sound IDs , to keep obtaining sound IDs you need to use RELEASE_SOUND_ID method before get sound id again so, in the startup of your Code you can do the line that get sound ID: soundID = GTA.Native.Function.Call<Int32>("GET_SOUND_ID"); and just use it later in the Tick/Loop/Whatever you want if the sound dont need to be stopped (like yours) you can use -1 as sound ID in the playback method: GTA.Native.Function.Call("PLAY_SOUND_FROM_POSITION", -1, "BURGULAR_ALARM_BELL_LOOP", LocationX, LocationY, LocationZ); Alright, using "Print(soundID.ToString)", displayed 0 on the screen, so this would mean SoundID isn't the source of the error, then, but what cause this error, the PLAY_SOUND_FROM_POSITION ? I got the name of the song "BURGULAR_ALARM_BELL_LOOP" by going though audio file at SFX/resident, is it because it has to be in hexadecimal or something ? right now, the only other source of the issue, can only be the song name, nothing else ! Edited April 12, 2014 by nordi Link to comment Share on other sites More sharing options...
julionib Posted April 12, 2014 Share Posted April 12, 2014 in that tutorial you will find a Sounds Demo script and a sounds list file, look for "The Sounds demo script and the sounds list" and you will find the files and more instructions, based on that script you can try to play the sound before use it, some sounds cant be played. I extracted the sound names from a file that list sounds in game (cant remember the name now) Link to comment Share on other sites More sharing options...
nordi Posted April 13, 2014 Author Share Posted April 13, 2014 in that tutorial you will find a Sounds Demo script and a sounds list file, look for "The Sounds demo script and the sounds list" and you will find the files and more instructions, based on that script you can try to play the sound before use it, some sounds cant be played. I extracted the sound names from a file that list sounds in game (cant remember the name now) Ok, I managed to play the sound from position, using the audio name on your tutorial: "GENERAL_WEAPONS_ROCKET_LOOP". But I can not find the correct sound name to use through the SCOCL files, for: "BURGULAR_ALARM_BELL_LOOP" (SFR\resident\general\amb_resident), or "ALARM_SIREN_24K". Link to comment Share on other sites More sharing options...
julionib Posted April 13, 2014 Share Posted April 13, 2014 you can use filters in that script, this makes easy find some sounds. the SCO file use this audio name? if he does you should use same native call to play it (from_position, from_ped, etc.) 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