ACE3/addons/common/functions/fnc_receiveRequest.sqf

82 lines
2.4 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-09-18 23:50:17 +00:00
/*
* Author: Glowbal
* N/A
2015-01-16 23:21:47 +00:00
*
2015-09-18 23:50:17 +00:00
* Arguments:
* 0: caller <OBJECT>
* 1: target <OBJECT>
* 2: requestID <STRING>
* 3: Message <STRING>
* 4: callback (NOT USED) <CODE>
2015-09-18 23:50:17 +00:00
*
* Return Value:
* None
*
* Example:
* [bob, kevin, "ID", "Message", {Callback}] call ace_common_fnc_receiveRequest
*
2015-09-18 23:50:17 +00:00
* Public: No
2015-01-16 23:21:47 +00:00
*/
2015-09-18 23:50:17 +00:00
params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
2015-01-16 23:21:47 +00:00
_requestID = ("ace_recieveRequest_f_id_"+_requestID);
2015-09-18 23:50:17 +00:00
_target setVariable [_requestID, _this];
2015-01-16 23:21:47 +00:00
if (isLocalized _requestMessage) then {
_requestMessage = format [localize _requestMessage, [_caller, false, true] call FUNC(getName)];
2015-01-16 23:21:47 +00:00
} else {
_requestMessage = format [_requestMessage, [_caller, false, true] call FUNC(getName)];
2015-01-16 23:21:47 +00:00
};
2015-09-18 23:50:17 +00:00
hint format ["%1", _requestMessage]; // @todo ?
2020-02-11 22:42:08 +00:00
if (!isNil QGVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT)) then {
2015-01-18 19:09:19 +00:00
terminate GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT);
2015-01-16 23:21:47 +00:00
};
2015-09-18 23:50:17 +00:00
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
2015-01-18 19:09:19 +00:00
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT);
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = nil;
2015-01-16 23:21:47 +00:00
};
2015-09-18 23:50:17 +00:00
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
2015-01-18 19:09:19 +00:00
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE);
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = nil;
2015-01-16 23:21:47 +00:00
};
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = _target addAction ["Accept", compile format["[player,'%1', true] call FUNC(onAnswerRequest);", _requestID]];
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = _target addAction ["Decline", compile format["[player,'%1', false] call FUNC(onAnswerRequest);", _requestID]];
GVAR(RECIEVE_REQUEST_ID_KEY_BINDING) = _requestID;
2016-03-02 10:01:39 +00:00
GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT) = [CBA_missionTime, _target, _requestID] spawn { // @todo
2015-09-18 23:50:17 +00:00
params ["_time", "_target", "_requestID"];
_time = _time + 40;
private _id = _target getVariable _requestID;
2015-09-18 23:50:17 +00:00
2015-11-30 16:28:01 +00:00
waitUntil {
2015-09-18 23:50:17 +00:00
_id = _target getVariable _requestID;
2016-03-02 10:01:39 +00:00
(CBA_missionTime > _time || isNil "_id")
2015-09-18 23:50:17 +00:00
};
_target setVariable [_requestID, nil];
2015-01-16 23:21:47 +00:00
2015-01-18 19:09:19 +00:00
GVAR(RECIEVE_REQUEST_ID_KEY_BINDING) = nil;
2015-09-18 23:50:17 +00:00
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
2015-01-18 19:09:19 +00:00
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT);
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = nil;
};
2015-09-18 23:50:17 +00:00
if (!isNil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
2015-01-18 19:09:19 +00:00
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE);
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = nil;
};
2015-09-18 23:50:17 +00:00
};