Jump to content
Sign in to follow this  
Gakyse

View trigger. Need some help

Recommended Posts

Hello, i am trying to make script for restricting view on my dedicated server.

What i trying to make - 
1) When player on foot inside trigger he can use 1st and 3rd person view, but when outside trigger he can only use 1st person
2) When player inside any vehicle ( ground / air / sea ) he can use any type of view ( 1-3 ) and regardless trigger effect from 1st point of topic

I am using thats script in my initPlayerLocal.sqf
 

Spoiler

h = [] spawn {
    waitUntil{ !isNull findDisplay 46 };

    findDisplay 46 displayAddEventHandler [ "KeyDown", {
        if ( inputAction "personView" > 0 && { !TAG_allowTPV } ) then {
            if !( isNil "TAG_handleTPV" ) then {
                terminate TAG_handleTPV;
            };
            TAG_handleTPV = [] spawn {
                waitUntil{ cameraView == "EXTERNAL" };
                player switchCamera "INTERNAL";
                TAG_handleTPV = nil;
            };
        };
    }];
};


_trg = rd; //<<<<<<< EDIT this

_trg triggerAttachVehicle[ player ];
_trg setTriggerActivation [ "VEHICLE", "PRESENT", true ];
_trg setTriggerStatements ["this", "
    TAG_allowTPV = true;
    if !( isnil 'TAG_handleTPV' ) then {
        terminate TAG_handleTPV;
    };
", "
    player switchCamera 'INTERNAL';
    TAG_allowTPV = false
"];

TAG_allowTPV = player inArea _trg;


It works correct for my 1st point of topic, but 2nd dont work. Can some one help me pls.

P.S. Sry for bad eng.

Share this post


Link to post
Share on other sites

The following code is untested, but iirc theres no way to toggle 1st / 3rd person availability except for the difficulty settings. 

That being said you should be able to fake it by forcing the camera into first person every frame. Its not *that* CPU intensive, but its still a loop so use with caution.

 

["forceViewEH", "onEachFrame", {

	//force to first person camera if the player is on foot, inside the trigger, and not aiming down sights
	_inTrigger = ["myTrigger",player] call BIS_fnc_inTrigger;
	if((vehicle player) == player && _inTrigger && camerView != 'GUNNER') then
    {
        (vehicle player) switchCamera "Internal"
    };

}] call BIS_fnc_addStackedEventHandler;

 

This will run constantly throughout the mission. There should be a way to make it more efficient by only having it fire from the trigger itself, but I cant remember the code. Hopefully this will be good enough to get the ball rolling for you!

Also check on the DS behavior of "addStackedEventHandler", it may need to be removed and re-added each time a player is killed / respawns.

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  

×