2015-01-16 13:20:41 +00:00
|
|
|
// by commy2
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_driver", "_vehicle"];
|
|
|
|
|
|
|
|
_driver = _this select 0;
|
|
|
|
_vehicle = _this select 1;
|
|
|
|
|
|
|
|
if (GETGVAR(isSpeedLimiter,false)) exitWith {
|
2015-05-28 19:59:04 +00:00
|
|
|
[localize LSTRING(Off)] call EFUNC(common,displayTextStructured);
|
2015-01-16 13:20:41 +00:00
|
|
|
playSound "ACE_Sound_Click";
|
|
|
|
GVAR(isSpeedLimiter) = false;
|
|
|
|
};
|
|
|
|
|
2015-05-28 19:59:04 +00:00
|
|
|
[localize LSTRING(On)] call EFUNC(common,displayTextStructured);
|
2015-01-16 13:20:41 +00:00
|
|
|
playSound "ACE_Sound_Click";
|
|
|
|
GVAR(isSpeedLimiter) = true;
|
|
|
|
|
|
|
|
private "_maxSpeed";
|
|
|
|
_maxSpeed = speed _vehicle max 10;
|
|
|
|
|
|
|
|
[{
|
|
|
|
private ["_driver", "_vehicle", "_maxSpeed"];
|
|
|
|
|
|
|
|
_driver = _this select 0 select 0;
|
|
|
|
_vehicle = _this select 0 select 1;
|
|
|
|
_maxSpeed = _this select 0 select 2;
|
|
|
|
|
|
|
|
if (!GVAR(isSpeedLimiter) || {_driver != driver _vehicle}) exitWith {
|
|
|
|
GVAR(isSpeedLimiter) = false;
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
private "_speed";
|
|
|
|
_speed = speed _vehicle;
|
|
|
|
|
|
|
|
if (_speed > _maxSpeed) then {
|
2015-04-18 15:42:13 +00:00
|
|
|
_vehicle setVelocity ((velocity _vehicle) vectorMultiply ((_maxSpeed / _speed) - 0.00001)); // fix 1.42-hotfix PhysX libraries applying force in previous direction when turning
|
2015-01-16 13:20:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} , 0, [_driver, _vehicle, _maxSpeed]] call CBA_fnc_addPerFrameHandler;
|