Added working limiter (config based)

This commit is contained in:
SAM 2015-05-08 14:49:52 +02:00
parent 6b604c101c
commit a5d68f122d
3 changed files with 36 additions and 37 deletions

View File

@ -3,18 +3,19 @@ class ACE_Settings {
typeName = "BOOL";
value = 1;
displayName = "Allow View Distance Changing";
description = "Enables changing in game view distance";
description = "Allows clients to be able to change their view distance";
};
class GVAR(top_limit) {
class GVAR(topViewDistanceLimit) {
typeName = "SCALAR";
value = 11; // setting the highest number in the array below means no limit.
values[] = {0,1,2,3,4,5,6,7,8,9,10,11}; // correspond to the index values
displayName = "View Distance Limit";
displayName = "Change View Distance Limit";
description = "Sets the top limit for all clients";
};
class GVAR(newViewDistance) {
typeName = "SCALAR";
isClientSettable = 1;
//value = 1;
value = 0; // not sure what to set this to.
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"};
displayName = "Change View Distance";
description = "Changes in game view distance";

View File

@ -17,25 +17,21 @@
#include "script_component.hpp"
private ["_new_view_distance_index","_new_view_distance"];
private ["_new_view_distance","_new_view_distance_limit"];
_new_view_distance_index = GVAR(newViewDistance);
_new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue);
_view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue);
_new_view_distance = [_new_view_distance_index] call FUNC(returnViewDistanceValue);
if !GVAR(changeAllowed) then {
hint "You are not allowed to change the view distance!";
} else {
if (_new_view_distance > _view_distance_limit) then {
hint format ["That option is not allowed! The limit is: %1m",_view_distance_limit];
}
else {
hint format ["View distance successfully changed to: %1m",_new_view_distance];
setViewDistance _new_view_distance;
};
};
/*
hint format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance];
diag_log format ["DEBUG: Player: %1 new view distance index: %2 new view distance value: %3",(name player),_new_view_distance_index,_new_view_distance];
*/
// To do: add a check against a sever or module top limit here.
if !GVAR(changeAllowed) then
{
hint "You cannot change the view distance!"
}
else
{
setViewDistance _new_view_distance;
};
// To do: add a check against a module limit.

View File

@ -4,10 +4,10 @@
*
*
* Arguments:
* 0: View Distance Index (SCALAR)
* 0: View Distance Index <SCALAR>
*
* Return Value:
* View Distance (SCALAR)
* View Distance <SCALAR>
*
* Example:
* [2] call ace_viewdistance_fnc_returnViewDistanceValue;
@ -22,20 +22,22 @@ private ["_index","_return"];
_index = _this select 0;
_return = 0;
// change to if () exitWith {};?
switch (_index) do
{
case 0: {_return = 1500};
case 1: {_return = 2000};
case 2: {_return = 2500};
case 3: {_return = 3000};
case 4: {_return = 3500};
case 5: {_return = 4000};
case 6: {_return = 5000};
case 7: {_return = 6000};
case 8: {_return = 7000};
case 9: {_return = 8000};
case 10: {_return = 9000};
case 11: {_return = 10000};
case 0: {_return = 1500;};
case 1: {_return = 2000;};
case 2: {_return = 2500;};
case 3: {_return = 3000;};
case 4: {_return = 3500;};
case 5: {_return = 4000;};
case 6: {_return = 5000;};
case 7: {_return = 6000;};
case 8: {_return = 7000;};
case 9: {_return = 8000;};
case 10: {_return = 9000;};
case 11: {_return = 10000;};
default {hint "something broke!";};
};