2015-05-08 12:14:15 +00:00
/*
* Author: Winter
2015-05-09 12:51:23 +00:00
* Assigns the Event Handler which triggers when a player adjusts their view distance in the menu
2015-05-08 12:14:15 +00:00
*
*
* Arguments:
2015-05-08 13:36:47 +00:00
* None
2015-05-08 12:14:15 +00:00
*
* Return Value:
* None
*
* Example:
2015-05-08 13:36:47 +00:00
* [] call ace_viewdistance_fnc_initViewDistance;
2015-05-08 12:14:15 +00:00
*
2015-05-08 13:36:47 +00:00
* Public: Yes
2015-05-08 12:14:15 +00:00
*/
2015-05-08 16:30:28 +00:00
2015-05-08 12:14:15 +00:00
#include "script_component.hpp"
2015-05-08 16:30:28 +00:00
if (!hasInterface) exitWith {};
2015-05-10 10:00:19 +00:00
if (viewDistance > GVAR(limitViewDistance)) then {
setViewDistance GVAR(limitViewDistance); // force the view distance down to the limit.
setObjectViewDistance (0.8 * GVAR(limitViewDistance));
} else {
2015-05-10 10:15:34 +00:00
[true] call FUNC(adaptViewDistance); // adapt view distance in the beginning according to whether client is on foot or vehicle.
2015-05-10 10:00:19 +00:00
};
2015-05-10 10:15:34 +00:00
// Set the EH which waits for any of the view distance settings to be changed, avoids the player having to enter or leave a vehicle for the changes to have effect.
2015-05-08 12:14:15 +00:00
["SettingChanged",{
2015-05-10 10:00:19 +00:00
if ((_this select 0 == QGVAR(viewDistanceOnFoot)) || (_this select 0 == QGVAR(viewDistanceLandVehicle)) || (_this select 0 == QGVAR(viewDistanceAirVehicle))) then {
2015-05-10 10:15:34 +00:00
[true] call FUNC(adaptViewDistance);
2015-05-08 12:14:15 +00:00
};
2015-05-10 10:00:19 +00:00
},true] call ace_common_fnc_addEventHandler;
// Set the EH which waits for a vehicle change to automatically swap to On Foot/In Land Vehicle/In Air Vehicle
2015-05-10 10:15:34 +00:00
["playerVehicleChanged",{[false] call FUNC(adaptViewDistance)},true] call ace_common_fnc_addEventHandler;