Richards.D 761 Posted January 26, 2015 Hello everyone: I need a script for a mission I'm working on, I did it in A2 but now I don't have that mission and cannot remember for the life of me what I need to do. And yes, for something so seemingly simple I searched the forums, but everyone is making threads about spectate upon death. I had no idea that was so big. Anyways, I just want to enter a spectate mode through addaction on a static object. I cannot figure out how to do it anymore, I tried Keygets modified script but it doesn't seem to work for my purposes. Anyone help me here, would be appreciated. Cheers Share this post Link to post Share on other sites
dreadedentity 278 Posted January 26, 2015 Have you tried selectPlayer or switchCamera? If those 2 don't suit your needs, you're going to need to mess with camera commands Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 Last time I just used some pre-made spectate script with it all done and just used an addaction, so I'm not to familiar with these. If I use select player / switch camera how exactly does it allow me to select which player to spectate? Does A3 have some kind of built in UI for such, or is it done manually through scripting? Share this post Link to post Share on other sites
SilentSpike 84 Posted January 26, 2015 (edited) Is there a way to manually run the seagull spectate template script? If so, that is already configured to allow this. I'd investigate that. Edited January 26, 2015 by SilentSpike Got the wrong spectator type Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 Perhaps there is.. but that script is really not ideal for what I need. I don't want to fly around slowly looking for what to spectate; I need a quick, fast way to snap to each player, nothing too complicated. Is there any way I can adapt Keygets script for an Addaction interaction instead of upon death? Share this post Link to post Share on other sites
SilentSpike 84 Posted January 26, 2015 The BIS spectator mode does exactly that. BIS_fnc_respawnSpectator is the function name. You can disable the free camera by setting "RscSpectator_allowFreeCam" to false (oh and use the arrow keys to switch between players). It's not perfect though. I actually just opened a feedback ticket with suggestions to improve it: http://feedback.arma3.com/view.php?id=22461 Share this post Link to post Share on other sites
giallustio 770 Posted January 26, 2015 I'm making one that maybe could fit your needs, I need to find time to finish it though. What it does: when a player dies he respawns at "respawn_marker" and he can't play anymore. A little UI is open and the player has the option to change the target of his view and the camera mode (1st person, 3d person an free, all editable in param) Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 I like the look of the RespawnSpectator Function, but I cannot remember how to call a function anymore. Is it through a trigger, or such? Also, will this work for MP? I am making an MP mission, I should have clarified such. This is what I have now: this addAction ["BIS_fnc_respawnSpectator.sqf"]; But that, does nothing at all. Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 this addAction ["Spectate",{[] call BIS_fnc_respawnSpectator;},nil,6,true,true,"",""] Share this post Link to post Share on other sites
giallustio 770 Posted January 26, 2015 this addAction ["Spectating", {[] call BIS_fnc_respawnSpectator.sqf}]; Check the fnc name and param, I can't check by my self atm Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 That works just fine, but I have no idea how to exit the script now. Escape does not work Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 Check the fnc name and param, I can't check by my self atm Problem is that the wiki doesn't give any params, and I don't have time to go into the FncViewer atm. ---------- Post added at 12:38 ---------- Previous post was at 12:37 ---------- That works just fine, but I have no idea how to exit the script now. Escape does not work May be able to do it with a different parameter coming into the function, but read my statement just above this, and then check in the function viewer in the editor to see if there is an enable/disable param for the function. Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 text Alright, I just checked with the func viewer, and as far as I can see there is no disable line of code. This is the entire function: _unit = [_this,0,objnull,[objnull]] call bis_fnc_param; _respawn = [_this,2,-1,[0]] call bis_fnc_param; _layer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer; if (!alive _unit) then { _layer cutrsc ["RscSpectator","plain"]; } else { if (_respawn == 1) then { //--- Open waituntil {missionnamespace getvariable ["BIS_fnc_feedback_allowDeathScreen",true]}; BIS_fnc_feedback_allowPP = false; //(["HealthPP_black"] call bis_fnc_rscLayer) cutText ["","BLACK IN",1]; _layer cutrsc ["RscSpectator","plain"]; } else { //--- Close _layer cuttext ["","plain"]; }; }; Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 Try: [player,nil,2] call BIS_fnc_respawnSpectator;//where player is the unit you want to effect, change if necessary I'm sort of guessing/hoping it will work, it may not :). Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 Haha, I tried putting that in the init of a unit, changed the name but it didn't seem to do anything. Also, what is all that "6,6,true,1,2 etc etc" stuff at the end of the line? The viewer doesn't show me any parameters Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 For the addAction line? Those are all the possible parameters you can pass when executing the addAction command. See what they are and what they do here: https://community.bistudio.com/wiki/addAction And what I gave you as an example should "close" the spectator, I think, change the 2 to a 1, to "open" it, hopefully :p. Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 I tried adding it to a unit and naming it correctly yes, but it still does nothing. this addAction ["[player1,nil,2] call BIS_fnc_respawnSpectator;"] Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 (edited) Take a closer look at the addAction page, the spectate function needs to go in the "code" parameter for addAction not the Action Name: this addAction ["Spectate",{[player,nil,2] call BIS_fnc_respawnSpectator;},nil,6,true,true,"",""]; Edited January 26, 2015 by JShock Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 Take a closer look at the addAction page, the spectate function needs to go in the "code" parameter for addAction not the Action Name: Code: this addAction ["Spectate",{[player,nil,2] call BIS_fnc_respawnSpectator;},nil,6,true,true,"",""] Excellent, I see that now. Unfortunately, that still does not do anything. It does not even enter spectate mode with that code. Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 Ok, just for due diligence before I'm out of ideas try: this addAction ["Spectate",{[(_this select 2),nil,1] call BIS_fnc_respawnSpectator;},nil,6,true,true,"",""]; Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 That does indeed launch the spectate script, but it returns the error: #0: 4 is type scalar, needs to be type object Oh and you still cannot exit. Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 (edited) Hmm, weird error, may be the nil being passed try a "0" or "objNull" there to see if that helps. As far as exiting I'm thinking a keyDown display EH with the following code, this display EH would be applied by the action and removed from the player within the code ran in the EH: (findDisplay 46) displayAddEventHandler {"KeyDown", { if ((_this select 1) isEqualTo someDIKcode) then {[player,0,2] call BIS_fnc_respawnSpectator; true}; (findDisplay 46) displayRemoveEventHandler (_this select 0); true; } };//the DIK codes can be found here: https://community.bistudio.com/wiki/DIK_KeyCodes EDIT: Derp moment, brain dead as hell today, change the (_this select 2) within the action code to (_this select 1), and leave the "nil" as is. Edited January 26, 2015 by JShock Share this post Link to post Share on other sites
Richards.D 761 Posted January 26, 2015 Alright.. Now I am not on my PC at the moment. Is an eventhandler something I can place on the map or? Or would it be a hpp /sqf I could write and paste that code above in? Richards Share this post Link to post Share on other sites
jshock 513 Posted January 26, 2015 I'm actually on my phone currently as well, give me a bit to get to a computer as well and I'll put something together. ---------- Post added at 16:14 ---------- Previous post was at 14:50 ---------- Ok so the following should theoretically put the player in spectate mode, and then when the player hits the "escape" key, the player should exit spectator (all untested): this addAction [ "Spectate", { [(_this select 1),nil,1] call BIS_fnc_respawnSpectator; glb_SpectateDisplayEH = (findDisplay 46) displayAddEventHandler [ "KeyDown", { _handle = false; if ((_this select 1) isEqualTo 0x01) then //currently looking for the ESC key { [player,0,2] call BIS_fnc_respawnSpectator; (findDisplay 46) displayRemoveEventHandler ["KeyDown",glb_SpectateDisplayEH]; _handle = true; }; _handle; } ]; }, nil, 6, true, true, "", "" ]; Share this post Link to post Share on other sites
bearbison 10 Posted January 26, 2015 try the below that I created for my basic training mission, stops the unit moving when in spectator script and exits using Ctrl + T. Probably not the best way of doing it but only way I could figure it out. On object this addAction ["<t color='#00FF00'>Spectator</t>", "scripts\Cameras\Spectator.sqf", [], -4, false, true, "", "_this distance _target < 3"]; scripts\Cameras\Spectator.sqf /* Spectator camera script - v0.2 Runs spectator camera Created by BearBison */ /* Private variables */ private ["_Key","_RscLayer"]; /* Prevents unit moving */ (_this select 1) enableSimulation false; /* Prevents free spectator camera */ RscSpectator_allowFreeCam = false; /* Disable post processing effects for spectator */ BIS_fnc_feedback_allowPP = false; /* Runs spectator script */ _RscLayer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer; _RscLayer cutrsc ["RscSpectator","plain"]; /* Exits spectator camera using the Ctrl + T key */ BEARB_SpectatorKeyDown = { _Key = _this select 1; if ((_Key == 20) && (_this select 3)) then { /* Enables post processing effects for spectator */ BIS_fnc_feedback_allowPP = true; /* Stops spectator script */ ("BIS_fnc_respawnSpectator" call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; /* Removes event handlers detecting key press */ (findDisplay 46) displayRemoveEventHandler ["KeyDown", BEARB_SpectatorEH]; /* Allows unit moving */ player enableSimulation true; }; }; /* Ensures the primary display is found */ waitUntil {!isNull(findDisplay 46)}; /* Adds event handlers to detect key press */ BEARB_SpectatorEH = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call BEARB_SpectatorKeyDown"]; Share this post Link to post Share on other sites