Merge pull request #2009 from jokoho48/codeCleanupVehicle

Code cleanup Vehicle module
This commit is contained in:
PabstMirror 2015-08-06 13:24:35 -05:00
commit 7ef13cd546
2 changed files with 41 additions and 24 deletions

View File

@ -1,10 +1,24 @@
// by commy2
/*
* Author: commy2
* Toggle speed limiter for Driver in Vehicle.
*
* Arguments:
* 0: Driver <OBJECT>
* 1: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, car] call ace_vehicles_fnc_speedLimiter
*
* Public: No
*/
#include "script_component.hpp"
private ["_driver", "_vehicle"];
private "_maxSpeed";
_driver = _this select 0;
_vehicle = _this select 1;
params ["_driver", "_vehicle"];
if (GETGVAR(isSpeedLimiter,false)) exitWith {
[localize LSTRING(Off)] call EFUNC(common,displayTextStructured);
@ -16,19 +30,15 @@ if (GETGVAR(isSpeedLimiter,false)) exitWith {
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;
params ["_args", "_idPFH"];
_args params ["_driver", "_vehicle", "_maxSpeed"];
if (!GVAR(isSpeedLimiter) || {_driver != driver _vehicle}) exitWith {
GVAR(isSpeedLimiter) = false;
[_this select 1] call CBA_fnc_removePerFrameHandler;
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
private "_speed";

View File

@ -1,23 +1,30 @@
// by commy2
/*
* Author: commy2
* Delays engine start of vehicle.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Is Engine on <BOOL>
*
* Return Value:
* None
*
* Example:
* [vehicle player, false] call ace_vehicle_fnc_startEngine
*
* Public: No
*/
#include "script_component.hpp"
private ["_vehicle", "_isEngineOn"];
_vehicle = _this select 0;
_isEngineOn = _this select 1;
params ["_vehicle", "_isEngineOn"];
if (!_isEngineOn || {floor abs speed _vehicle > 0}) exitWith {};
[{
private ["_vehicle", "_time", "_direction"];
params ["_args", "_idPFH"];
_args params ["_vehicle", "_time", "_direction"];
_vehicle = _this select 0 select 0;
_time = _this select 0 select 1;
_direction = _this select 0 select 2;
if (ACE_time > _time) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
if (ACE_time > _time) exitWith { [_idPFH] call CBA_fnc_removePerFrameHandler; };
_vehicle setVelocity [0, 0, 0];
_vehicle setVectorDirAndUp _direction;