Jump to content
Sign in to follow this  
driftingnitro

Addaction Camera

Recommended Posts

I've been trying to create a script for a single unit in a multiplayer setting to have access to the camera's from debug panel. In order to do this I've had this code in the server's Init.sqf that are referencing a civilian unit named CameraMan.

waitUntil { alive CameraMan }; 
0 = CameraMan spawn { while {true} do { 
removeallweapons CameraMan; sleep 2};}; 
CameraMan allowDamage false;          
CameraMan addAction ["Recorder", "camera.sqs"];                     
CameraMan addAction ["Camera", "[] call BIS_fnc_camera"] 

There are two problems with this code:

1. The addaction dissapears when respawning

and 2. other players can acess the "addAction"s by using scroll wheel on the civilian himself.

An earlier version of this I put the code in the init of the unit but it didn't work in a multiplayer setting, when it was in the Init of the unit I had "player addAction" instead of "this addAction" which is probably why problem #2 wasn't apparent in the first iteration. I don't know how to reference both the unit and the player simultaneously.

Share this post


Link to post
Share on other sites

I was able to get some help and devised this solution to problem #2, but I still can't get the actions to come up after respawning.

waitUntil { alive CameraMan};
fnc_MyCamera =
{
   waitUntil { alive CameraMan};
   0 = player spawn
       {
           while {alive player} do
           {
               removeallweapons player;
               sleep 0.1;
           };
           _null = player call fnc_MyCamera;
       };
   player allowDamage false;
   player addAction ["Recorder", "camera.sqs",[],0,false,false,"","(vehicle _target == vehicle _this)"];
   player addAction ["Camera", "[] call BIS_fnc_camera",[],0,false,false,"","(vehicle _target == vehicle _this)"];
};
_null = CameraMan call fnc_MyCamera;

Share this post


Link to post
Share on other sites

Use a respawn eventHandler to run the function again.

player addEventHandler ["respawn",{ _null = (_this select 0) call fnc_MyCamera; }];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×