2015-01-16 23:21:47 +00:00
|
|
|
/**
|
|
|
|
* fn_recieveRequest.sqf
|
|
|
|
* @Descr: N/A
|
|
|
|
* @Author: Glowbal
|
|
|
|
*
|
|
|
|
* @Arguments: []
|
|
|
|
* @Return:
|
|
|
|
* @PublicAPI: false
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"];
|
|
|
|
_caller = _this select 0;
|
|
|
|
_target = _this select 1;
|
|
|
|
_requestID = _this select 2;
|
|
|
|
_requestMessage = _this select 3;
|
|
|
|
_callBack = _this select 4;
|
|
|
|
|
|
|
|
_requestID = ("ace_recieveRequest_f_id_"+_requestID);
|
|
|
|
|
|
|
|
_target setvariable [_requestID, _this];
|
|
|
|
|
|
|
|
if (isLocalized _requestMessage) then {
|
2015-01-18 19:09:19 +00:00
|
|
|
_requestMessage = format[localize _requestMessage,[_caller] call FUNC(getName)];
|
2015-01-16 23:21:47 +00:00
|
|
|
} else {
|
2015-01-18 19:09:19 +00:00
|
|
|
_requestMessage = format[_requestMessage,[_caller] call FUNC(getName)];
|
2015-01-16 23:21:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hint format["%1",_requestMessage];
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
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;
|
|
|
|
|
|
|
|
GVAR(RECIEVE_REQUEST_TIME_OUT_SCRIPT) = [time, _target, _requestID] spawn {
|
2015-01-18 19:09:19 +00:00
|
|
|
_t = (_this select 0) + 40;
|
|
|
|
_target = _this select 1;
|
|
|
|
_requestID = _this select 2;
|
|
|
|
_id = _target getvariable _requestID;
|
|
|
|
waituntil {
|
|
|
|
_id = _target getvariable _requestID;
|
2015-01-16 23:21:47 +00:00
|
|
|
|
2015-01-18 19:09:19 +00:00
|
|
|
(time > _t || isnil "_id")};
|
|
|
|
_target setvariable [_requestID, nil];
|
|
|
|
GVAR(RECIEVE_REQUEST_ID_KEY_BINDING) = nil;
|
|
|
|
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT)) then {
|
|
|
|
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT);
|
|
|
|
GVAR(RECIEVE_REQUEST_ADD_ACTION_ACCEPT) = nil;
|
|
|
|
};
|
|
|
|
if (!isnil QGVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE)) then {
|
|
|
|
_target removeAction GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE);
|
|
|
|
GVAR(RECIEVE_REQUEST_ADD_ACTION_DECLINE) = nil;
|
|
|
|
};
|
2015-01-16 23:21:47 +00:00
|
|
|
|
|
|
|
};
|