celery 8 Posted October 5, 2010 Is there a way of detecting loading a savegame or going to the ESC menu and back other than comparing time and diag_tickTime? Share this post Link to post Share on other sites
st_dux 26 Posted October 5, 2010 There is no "official" way to do this as far as I know, but you could take advantage of the fact that animated objects (e.g., a door in a house) get reset when loading a game. At the beginning of your mission, open some door away from the mission area with the animate command. Then, create a trigger that checks to see if the door closes (use the animationPhase command to do this). If it does, you know that the game has been loaded (and thus, all object animations reset). Share this post Link to post Share on other sites
kylania 568 Posted October 5, 2010 You can't detect the ESC menu display id? Share this post Link to post Share on other sites
moricky 211 Posted October 5, 2010 (edited) pauseOnLoad.sqf This script is executed every time pause menu is opened, with _this select 0 being display. It works like onPlayerKilled.sqf, just create file with that name in mission directory. However, this solution works only in single-player. For MP, you can set path to script in description.ext using following param: onPauseScript = "myScript.sqf"; As for detecting load: _loadSpawn = [] spawn {disableSerialization; waituntil {false};} waituntil {scriptDone _loadSpawn}; hint "Game loaded"; You execute spawn with uncompletable condition, but disableSerialization command prevents it from continuing after load, which you can easily detect. Edited October 5, 2010 by Moricky 1 Share this post Link to post Share on other sites
st_dux 26 Posted October 5, 2010 Very tricky. I'll have to remember that one. Share this post Link to post Share on other sites
UNN 0 Posted October 5, 2010 You execute spawn with uncompletable condition, but disableSerialization command prevents it from continuing after load, which you can easily detect. Nice. or going to the ESC menu and back You can also use displayEvent handlers to capture the key press: (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1)==1) then {player sidechat 'Esc key pressed!'}"]; Although the event handler method is more for addon based scripts. Share this post Link to post Share on other sites
celery 8 Posted October 5, 2010 Awesome! Thanks Gaia! This will allow me to make a script that resumes music tracks where they were when the game was paused or saved (normally pausing causes the track to skip and saves don't remember the track at all). But I hope that it will be fixed officially since the previous games didn't have the skipping bug at least. :) ---------- Post added at 01:07 ---------- Previous post was at 00:25 ---------- Is it normal that the pauseOnLoad script doesn't take kindly to variables? I wanted to set a variable as true but I get this kind of error: Error in expression <private ['_dummy']; _dummy = _this call compile preprocessFile 'pau> Error position: <= _this call compile preprocessFile 'pau> Error Generic error in expression Doesn't give me that when I put just a normal command like hint in the script. Share this post Link to post Share on other sites
AZCoder 921 Posted October 6, 2010 How are you doing it Celery? I found that if I define a custom script through description.ext: onPauseScript = "pause.sqf"; then I can set a variable without an error message. The pauseOnLoad script seemed to work with "setVariable" but would toss an error otherwise. Share this post Link to post Share on other sites
moricky 211 Posted October 6, 2010 Error in expression <private ['_dummy']; _dummy = _this call compile preprocessFile 'pau> Error position: <= _this call compile preprocessFile 'pau> Error Generic error in expression As you can see, script is called, which requires it to return some value. Just put simple true to the last line and it should be fine. Share this post Link to post Share on other sites
scifer 10 Posted April 28, 2011 (edited) pauseOnLoad.sqf This script is executed every time pause menu is opened, with _this select 0 being display. It works like onPlayerKilled.sqf, just create file with that name in mission directory. However, this solution works only in single-player. It didn't work for me in Arma2 single-player :( I was trying to sum a global variable. ---------- Post added at 06:01 ---------- Previous post was at 05:41 ---------- Nice.You can also use displayEvent handlers to capture the key press: (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1)==1) then {player sidechat 'Esc key pressed!'}"]; Although the event handler method is more for addon based scripts. I pretended to assign diag_tickTime to a variable but if I press ESC again to exit the menu, would it assign the variable again? Why is it more addon oriented? Edited April 28, 2011 by scifer Share this post Link to post Share on other sites