mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
parent
6ee5c6d9f8
commit
20a5c79431
@ -1,25 +1,23 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Remove a map marker creation event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: ID of the event handler (Number)
|
||||
* Arguments:
|
||||
* 0: ID of the event handler <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actionsVar", "_currentId", "_actionIDs", "_actions"];
|
||||
|
||||
PARAMS_1(_id);
|
||||
params ["_id"];
|
||||
|
||||
private "_actionsVar";
|
||||
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_MapMarker", [-1, [], []]];
|
||||
|
||||
_currentId = _actionsVar select 0;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_currentId", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _actionIDs find _id;
|
||||
|
||||
|
@ -1,25 +1,23 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Remove a scroll wheel event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: ID of the event handler (Number)
|
||||
* Arguments:
|
||||
* 0: ID of the event handler <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* None.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actionsVar", "_currentId", "_actionIDs", "_actions"];
|
||||
|
||||
PARAMS_1(_id);
|
||||
params ["_id"];
|
||||
|
||||
private "_actionsVar";
|
||||
_actionsVar = missionNamespace getVariable ["ACE_EventHandler_ScrollWheel", [-1, [], []]];
|
||||
|
||||
_currentId = _actionsVar select 0;
|
||||
_actionIDs = _actionsVar select 1;
|
||||
_actions = _actionsVar select 2;
|
||||
_actionsVar params ["_currentId", "_actionIDs", "_actions"];
|
||||
|
||||
_id = _actionIDs find _id;
|
||||
|
||||
|
@ -2,68 +2,77 @@
|
||||
* Author: esteldunedain
|
||||
* Removes a magazine from the unit that has an specific ammo count
|
||||
*
|
||||
* Argument:
|
||||
* 0: Player <OBJECT>
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Magazine <STRING>
|
||||
* 2: Ammo count <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_3_PVT(_this,_player,_magazineType,_ammoCount);
|
||||
params ["_unit", "_magazineType", "_ammoCount"];
|
||||
|
||||
private ["_isRemoved", "_magazines", "_index"];
|
||||
|
||||
private ["_magazines","_index","_isRemoved"];
|
||||
_isRemoved = false;
|
||||
|
||||
// Check uniform
|
||||
_magazines = [magazinesAmmoCargo uniformContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
_magazines = [magazinesAmmoCargo uniformContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType, _ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromUniform (_x select 0);
|
||||
} forEach _magazines;
|
||||
_unit removeItemFromUniform (_x select 0);
|
||||
false
|
||||
} count _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(uniformContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
(uniformContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
false
|
||||
} count _magazines;
|
||||
};
|
||||
|
||||
// Check vest
|
||||
_magazines = [magazinesAmmoCargo vestContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_magazines = [magazinesAmmoCargo vestContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromVest (_x select 0);
|
||||
} forEach _magazines;
|
||||
_unit removeItemFromVest (_x select 0);
|
||||
false
|
||||
} count _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(vestContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
(vestContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
false
|
||||
} count _magazines;
|
||||
};
|
||||
|
||||
// Check backpack
|
||||
_magazines = [magazinesAmmoCargo backpackContainer _player, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_magazines = [magazinesAmmoCargo backpackContainer _unit, {_this select 0 == _magazineType}] call FUNC(filter);
|
||||
_index = _magazines find [_magazineType,_ammoCount];
|
||||
if (_index > -1) exitWith {
|
||||
{
|
||||
_player removeItemFromBackpack (_x select 0);
|
||||
} forEach _magazines;
|
||||
_unit removeItemFromBackpack (_x select 0);
|
||||
false
|
||||
} count _magazines;
|
||||
|
||||
{
|
||||
if (!_isRemoved && (_x isEqualTo [_magazineType,_ammoCount])) then {
|
||||
_isRemoved = true;
|
||||
} else {
|
||||
(backpackContainer _player) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
(backpackContainer _unit) addMagazineAmmoCargo [_x select 0, 1, _x select 1];
|
||||
};
|
||||
} forEach _magazines;
|
||||
false
|
||||
} count _magazines;
|
||||
};
|
||||
|
@ -1,27 +1,28 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
*
|
||||
* Remove a synced event handler
|
||||
*
|
||||
* Argument:
|
||||
* 0: Name (String)
|
||||
* Arguments:
|
||||
* 0: Name <STRING>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* Boolean of success
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_name);
|
||||
|
||||
private ["_data", "_eventId"];
|
||||
params ["_name"];
|
||||
|
||||
if (!HASH_HASKEY(GVAR(syncedEvents),_name)) exitWith {
|
||||
ACE_LOGERROR("Synced event key not found.");
|
||||
false
|
||||
};
|
||||
|
||||
private ["_data", "_eventId"];
|
||||
|
||||
_data = HASH_GET(GVAR(syncedEvents),_name);
|
||||
_eventId = _data select 3;
|
||||
|
||||
[_eventId] call ace_common_fnc_removeEventHandler;
|
||||
[_eventId] call FUNC(removeEventHandler);
|
||||
HASH_REM(GVAR(syncedEvents),_name);
|
||||
|
Loading…
Reference in New Issue
Block a user