mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Reworked limiting system
Module limit still not being set properly.
This commit is contained in:
parent
bba216ebd2
commit
2dfaaa047a
@ -2,11 +2,17 @@ class ACE_Settings {
|
||||
class GVAR(viewDistance) {
|
||||
typeName = "SCALAR";
|
||||
isClientSettable = 1;
|
||||
value = 0; // not sure what to set this to.
|
||||
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnViewDistanceValue.sqf
|
||||
value = 11; // index, NOT value // not sure what to set this to.
|
||||
values[] = {"1500","2000","2500","3000","3500","4000","5000","6000","7000","8000","9000","10000"}; // Values also need to be changed in functions/fnc_returnValue.sqf
|
||||
displayName = "Change View Distance";
|
||||
description = "Changes in game view distance";
|
||||
};
|
||||
class GVAR(limit) {
|
||||
typeName = "SCALAR";
|
||||
value = 10000; // Value, NOT index.
|
||||
displayName = "View Distance Limit";
|
||||
description = "Limit for client's view distance set here and can overridden by module";
|
||||
};
|
||||
};
|
||||
|
||||
// To do: include string table style displayName & description.
|
@ -13,7 +13,7 @@ class CfgVehicles {
|
||||
displayName = "View Distance setting limit";
|
||||
description = "Sets the limit for how high clients can raise their view distance (< 10000)";
|
||||
typeName = "SCALAR";
|
||||
defaultValue = 10000;
|
||||
defaultValue = 5000;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -3,9 +3,8 @@
|
||||
ADDON = false;
|
||||
|
||||
PREP(module);
|
||||
PREP(returnViewDistanceValue);
|
||||
PREP(returnViewDistanceLimit);
|
||||
PREP(changeViewDistance);
|
||||
PREP(init);
|
||||
PREP(returnValue);
|
||||
PREP(changeViewDistance);
|
||||
|
||||
ADDON = true;
|
@ -20,17 +20,17 @@
|
||||
private ["_text","_new_view_distance","_view_distance_limit"];
|
||||
|
||||
// Change the received index number into an actual view distance number as set in the config:
|
||||
_new_view_distance = [GVAR(newViewDistance)] call FUNC(returnViewDistanceValue);
|
||||
_new_view_distance = [GVAR(viewDistance)] call FUNC(returnValue);
|
||||
|
||||
// Grab the limit, either from the module OR if the module is not valid, the config.
|
||||
_view_distance_limit = [] call FUNC(returnViewDistanceLimit);
|
||||
_view_distance_limit = GVAR(limit); // Grab the limit
|
||||
|
||||
if (_new_view_distance > _view_distance_limit) then {
|
||||
_text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
}
|
||||
else {
|
||||
if (_new_view_distance <= _view_distance_limit) then {
|
||||
_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
setViewDistance _new_view_distance;
|
||||
setObjectViewDistance (0.8 * _new_view_distance); // maybe make this 0.8 a constant?
|
||||
}
|
||||
else {
|
||||
_text = composeText ["That option is not allowed! The limit is: ",str(_view_distance_limit)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
};
|
@ -21,7 +21,7 @@ if (!hasInterface) exitWith {};
|
||||
|
||||
// Set the EH which waits for the View Distance setting to be changed
|
||||
["SettingChanged",{
|
||||
if (_this select 0 == QGVAR(newViewDistance)) then {
|
||||
if (_this select 0 == QGVAR(viewDistance)) then {
|
||||
[] call FUNC(changeViewDistance);
|
||||
};
|
||||
},true] call ace_common_fnc_addEventHandler;
|
@ -25,9 +25,6 @@ if (!_activated) exitWith {
|
||||
diag_log text "[ACE]: View Distance Limit Module is placed but NOT active.";
|
||||
};
|
||||
|
||||
GVAR(modulePresent) = true;
|
||||
diag_log text "[ACE]: View Distance Limit Module Initialized.";
|
||||
|
||||
[_logic, QGVAR(moduleViewDistanceLimit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule);
|
||||
|
||||
hint format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)]; // only used for debug, GVAR(moduleViewDistanceLimit) keeps returning as ANY. Remember to remove before finalising the module.
|
||||
diag_log format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)];
|
||||
[_logic, QGVAR(limit),"moduleViewDistanceLimit"] call EFUNC(common,readSettingFromModule);
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Author: Winter
|
||||
* Returns the view distance limit depending on either the config or (if present) the module.
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* View Distance Limit <SCALAR>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_viewdistance_fnc_returnViewDistanceLimit;
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_limit"];
|
||||
|
||||
_limit = 20000; // unrealistic amount since A3 max is 10000, helps in debug
|
||||
|
||||
if (!isNil QGVAR(moduleViewDistanceLimit)) then {
|
||||
_limit = GVAR(moduleViewDistanceLimit); // module value always takes priority over config
|
||||
} else {
|
||||
// If the module is not present, take the value from the config instead
|
||||
_limit = [GVAR(viewDistanceLimit)] call FUNC(returnViewDistanceValue); // this function converts the array index in the config to it's relevant scalar value.
|
||||
};
|
||||
|
||||
hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo
|
||||
diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit]; // only used for debug, trying to get the module to work. Remember to remove before finalising pbo
|
||||
|
||||
_limit;
|
Loading…
Reference in New Issue
Block a user