mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
All working except module returning any.
ace_viewdistance_moduleViewDistanceLimit always returning as any. No error in the RPT relating to readSettingfromModule failing
This commit is contained in:
parent
6cda97e3a0
commit
45992e5e7f
@ -5,7 +5,7 @@ class ACE_Settings {
|
||||
displayName = "Allow View Distance Changing";
|
||||
description = "Allows clients to be able to change their view distance";
|
||||
};
|
||||
class GVAR(topViewDistanceLimit) {
|
||||
class GVAR(viewDistanceLimit) {
|
||||
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
|
||||
|
@ -3,16 +3,16 @@ class CfgVehicles {
|
||||
class ACE_ModuleViewDistance : Module_F {
|
||||
author = "$STR_ACE_Common_ACETeam";
|
||||
category = "ACE";
|
||||
displayName = "View Distance Limit";
|
||||
function = QFUNC(moduleViewDistance);
|
||||
displayName = "View Distance Limiter";
|
||||
function = QFUNC(module);
|
||||
scope = 2;
|
||||
isGlobal = 1;
|
||||
//icon = ""; // needs an icon
|
||||
class Arguments {
|
||||
class ViewDistanceLimit {
|
||||
class moduleViewDistanceLimit {
|
||||
displayName = "View Distance setting limit";
|
||||
description = "Sets the limit for how high clients can raise their view distance (< 10,000)";
|
||||
typeName = "NUMBER";
|
||||
typeName = "SCALAR";
|
||||
defaultValue = 10000;
|
||||
};
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
[] call FUNC(moduleViewDistance);
|
||||
if (!hasInterface || !GVAR(enabled)) exitWith {};
|
||||
if (!GVAR(changeAllowed)) exitWith {}; // if viewdistance is disabled from config, exit here.
|
||||
[] call FUNC(initViewDistance);
|
@ -2,8 +2,9 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(moduleViewDistance);
|
||||
PREP(module);
|
||||
PREP(returnViewDistanceValue);
|
||||
PREP(returnViewDistanceLimit);
|
||||
PREP(changeViewDistance);
|
||||
PREP(initViewDistance);
|
||||
|
||||
|
@ -13,4 +13,5 @@ class CfgPatches {
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "CfgVehicles.hpp"
|
@ -22,22 +22,14 @@ 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);
|
||||
|
||||
_view_distance_limit = [GVAR(topViewDistanceLimit)] call FUNC(returnViewDistanceValue);
|
||||
_view_distance_limit = [] call FUNC(returnViewDistanceLimit);
|
||||
|
||||
|
||||
if !GVAR(changeAllowed) then {
|
||||
_text = "You are not allowed to change the view distance!";
|
||||
[_text,2] call EFUNC(common,displayTextStructured);
|
||||
} else {
|
||||
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 {
|
||||
_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
setViewDistance _new_view_distance;
|
||||
};
|
||||
};
|
||||
|
||||
// To do: add a check against a module 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 {
|
||||
_text = composeText ["View distance successfully changed to: ",str(_new_view_distance)];
|
||||
[_text,1] call EFUNC(common,displayTextStructured);
|
||||
setViewDistance _new_view_distance;
|
||||
};
|
@ -14,9 +14,11 @@
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
["SettingChanged",{
|
||||
if (_this select 0 == QGVAR(newViewDistance)) then {
|
||||
[] call FUNC(changeViewDistance);
|
||||
|
33
addons/viewdistance/functions/fnc_module.sqf
Normal file
33
addons/viewdistance/functions/fnc_module.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Winter
|
||||
* Initialises the view distance limiter module
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
* 0: logic <OBJECT>
|
||||
* 1: Synchronised Units <ARRAY>
|
||||
* 2: Module Activated <BOOL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
PARAMS_3(_logic,_units,_activated);
|
||||
|
||||
if (!_activated) exitWith {
|
||||
diag_log text "[ACE]: View Distance Limit Module is placed but NOT active";
|
||||
};
|
||||
|
||||
GVAR(modulePresent) = true;
|
||||
|
||||
[_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
|
||||
diag_log format["[ACE]: View Distance Limit Module Initialized with limit: %1",GVAR(moduleViewDistanceLimit)];
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Author: Winter
|
||||
* Initialises the view distance limiter module
|
||||
*
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* View Distance Limit <SCALAR>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!isServer) exitWith {
|
||||
GVAR(modulePresent) = false
|
||||
};
|
||||
|
||||
PARAMS_2(_logic,_activated);
|
||||
|
||||
if !(_activated) exitWith {};
|
||||
|
||||
GVAR(modulePresent) = true;
|
||||
publicVariable QGVAR(modulePresent);
|
||||
|
||||
diag_log text "[ACE]: ViewDistance Module Initialized.";
|
@ -17,10 +17,18 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
if GVAR(modulePresent) then {
|
||||
// module always takes priority
|
||||
_view_distance_limit =
|
||||
private ["_limit"];
|
||||
|
||||
_limit = 20000; // unrealistic amount for debug
|
||||
|
||||
if (!isNil QGVAR(moduleViewDistanceLimit)) then {
|
||||
_limit = GVAR(moduleViewDistanceLimit); // module always takes priority
|
||||
} else {
|
||||
|
||||
// if 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.
|
||||
};
|
||||
// To do: add a check against a module limit.
|
||||
|
||||
hint format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit];
|
||||
diag_log format ["[VD] Limit returned from module: %2 Local Limit: %3",GVAR(modulePresent),GVAR(moduleViewDistanceLimit),_limit];
|
||||
|
||||
_limit;
|
@ -22,7 +22,6 @@ PARAMS_1(_index);
|
||||
private ["_return"];
|
||||
_return = 0;
|
||||
|
||||
|
||||
// change to if () exitWith {};?
|
||||
switch (_index) do
|
||||
{
|
||||
@ -38,7 +37,7 @@ switch (_index) do
|
||||
case 9: {_return = 8000;};
|
||||
case 10: {_return = 9000;};
|
||||
case 11: {_return = 10000;};
|
||||
default {hint "something broke!";};
|
||||
default {hint "something broke!";}; // should replace with something a bit more graceful
|
||||
};
|
||||
|
||||
_return;
|
Loading…
Reference in New Issue
Block a user