Skip to content

Commit

Permalink
Merge pull request #2884 from acemod/speedLimiterUGVFix
Browse files Browse the repository at this point in the history
fix that in UGV dont work speedLimiter
  • Loading branch information
thojkooi committed Nov 29, 2015
2 parents 081106d + 76435ec commit 02eee05
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
33 changes: 22 additions & 11 deletions addons/vehicles/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@
#include "script_component.hpp"

if (!hasInterface) exitWith {};

GVAR(isSpeedLimiter) = false;
// Add keybinds
["ACE3 Vehicles", QGVAR(speedLimiter), localize LSTRING(SpeedLimiter),
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isnotinside"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !(ACE_player == driver vehicle ACE_player &&
{vehicle ACE_player isKindOf 'Car' ||
{vehicle ACE_player isKindOf 'Tank'}}) exitWith {false};
private _connectedUAV = getConnectedUAV ACE_player;
private _uavControll = UAVControl _connectedUAV;
if ((_uavControll select 1) == "DRIVER") then {
if !(_connectedUAV isKindOf "UGV_01_base_F") exitWith {false};
GVAR(isUAV) = true;
[_uavControll select 0, _connectedUAV] call FUNC(speedLimiter);
true
} else {
// Conditions: canInteract
if !([ACE_player, objNull, ["isnotinside"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific
if !(ACE_player == driver vehicle ACE_player &&
{vehicle ACE_player isKindOf 'Car' ||
{vehicle ACE_player isKindOf 'Tank'}}) exitWith {false};

GVAR(isUAV) = false;
// Statement
[ACE_player, vehicle ACE_player] call FUNC(speedLimiter);
true
};

// Statement
[ACE_player, vehicle ACE_player] call FUNC(speedLimiter);
true
},
{false},
[211, [false, false, false]], false] call cba_fnc_addKeybind; //DELETE Key
[211, [false, false, false]], false] call CBA_fnc_addKeybind; //DELETE Key
16 changes: 13 additions & 3 deletions addons/vehicles/functions/fnc_speedLimiter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private "_maxSpeed";

params ["_driver", "_vehicle"];

if (GETGVAR(isSpeedLimiter,false)) exitWith {
if (GVAR(isSpeedLimiter)) exitWith {
[localize LSTRING(Off)] call EFUNC(common,displayTextStructured);
playSound "ACE_Sound_Click";
GVAR(isSpeedLimiter) = false;
Expand All @@ -36,8 +36,18 @@ _maxSpeed = speed _vehicle max 10;
params ["_args", "_idPFH"];
_args params ["_driver", "_vehicle", "_maxSpeed"];

if (!GVAR(isSpeedLimiter) || {_driver != driver _vehicle}) exitWith {
GVAR(isSpeedLimiter) = false;
if (GVAR(isUAV)) then {
private _uavControll = UAVControl _vehicle;
if ((_uavControll select 0) != _driver || _uavControll select 1 != "DRIVER") then {
GVAR(isSpeedLimiter) = false;
};
} else {
if (_driver != driver _vehicle) then {
GVAR(isSpeedLimiter) = false;
};
};

if (!GVAR(isSpeedLimiter)) exitWith {
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

Expand Down

0 comments on commit 02eee05

Please sign in to comment.