ACE3/addons/viewdistance/functions/fnc_changeViewDistance.sqf

49 lines
1.9 KiB
Plaintext
Raw Normal View History

2015-05-08 07:28:48 +00:00
/*
* Author: Winter
* Sets the player's current view distance according to allowed values.
*
*
* Arguments:
* 0: View Distance setting INDEX <SCALAR>
* 1: Show Prompt <BOOL>
2015-05-08 07:28:48 +00:00
*
* Return Value:
* None
*
* Example:
2015-05-08 12:14:15 +00:00
* [] call ace_viewdistance_fnc_changeViewDistance;
2015-05-08 07:28:48 +00:00
*
2015-05-08 13:36:47 +00:00
* Public: Yes
2015-05-08 07:28:48 +00:00
*/
#include "script_component.hpp"
2015-05-14 15:44:35 +00:00
private ["_text","_new_view_distance","_view_distance_limit","_object_view_distance_coeff"];
PARAMS_2(_index_requested,_show_prompt);
2015-05-08 12:49:52 +00:00
_new_view_distance = [_index_requested] call FUNC(returnValue); // change the index into an actual view distance value
2015-05-14 15:44:35 +00:00
_object_view_distance_coeff = [GVAR(objectViewDistanceCoeff)] call FUNC(returnObjectCoeff);
_view_distance_limit = GVAR(limitViewDistance); // Grab the limit
2015-05-08 12:49:52 +00:00
if (_new_view_distance <= _view_distance_limit) then {
2015-05-14 15:44:35 +00:00
if (_show_prompt) then {
//_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
_text = format ["View distance successfully changed to: %1, Object View Distance Coefficient is: %2",str(_new_view_distance),str(_object_view_distance_coeff)];
[_text,3] call EFUNC(common,displayTextStructured);
};
setViewDistance _new_view_distance;
2015-05-14 15:44:35 +00:00
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _new_view_distance);
};
}
else {
2015-05-14 15:44:35 +00:00
if (_show_prompt) then {
//_text = composeText ["That option is invalid! The limit is: ",str(_view_distance_limit)];
_text = format ["That option is invalid! The limit is: %1, Object View Distance Coefficient is: %2",str(_view_distance_limit),str(_object_view_distance_coeff)];
[_text,3] call EFUNC(common,displayTextStructured);
setViewDistance _view_distance_limit;
2015-05-14 15:44:35 +00:00
if (_object_view_distance_coeff > 0) then {
setObjectViewDistance (_object_view_distance_coeff * _view_distance_limit);
};
};
};