forked from LexTheGreat/TLX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createfunctions.sqf
132 lines (114 loc) · 3.17 KB
/
createfunctions.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
INV_CreateGunboxLocal = {};
INV_CreateFort = {
_this spawn {
private ["_class", "_kind", "_logic", "_vehicle", "_vehicle_name"];
_logic = _this select 0;
_class = _this select 1;
_kind = _this select 2;
if (not(alive player)) exitWith {};
liafu = true;
_vehicle = createVehicle [_class, (getPosATL _logic), [], 0, "NONE"];
switch _kind do {
case "Static" do {
_vehicle_name = format["%1_%2_%3", _kind, player, round(time)];
xorE=true;
_vehicle setVehicleInit format[
'
liafu = true;
this setVehicleVarName "%1";
%1 = this;
this lock false;', _vehicle_name];
processInitCommands;
};
case "Fort" do {};
case "Box" do {
clearBackpackCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearWeaponCargoGlobal _vehicle;
};
};
};
};
INV_CreateWeapon = {
private["_class", "_amount", "_crate"];
_class = _this select 0;
_amount = _this select 1;
_crate = _this select 2;
_in_hands = if (count _this > 3) then { _this select 3 } else { false };
if (_in_hands) then {
player addWeapon _class;
player action ["switchweapon", player, player, 0];
}
else {
_crate addweaponCargoGlobal [_class,_amount];
};
};
INV_CreateMag = {
liafu = true;
private["_class", "_amount", "_crate"];
_class = _this select 0;
_amount = _this select 1;
_crate = _this select 2;
_crate addmagazineCargoGlobal [_class,_amount];
};
INV_CreatePack = {
liafu = true;
private["_class", "_amount", "_crate"];
_class = _this select 0;
_amount = _this select 1;
_crate = _this select 2;
_in_hands = if (count _this > 3) then { _this select 3 } else { false };
if (_in_hands) then {
player addBackpack _class;
}
else {
_crate addBackpackCargoGlobal [_class, _amount];
};
//remove the backpack's contents
[] spawn {
sleep 1;
private["_backpack"];
_backpack = unitBackpack player;
if (isNil "_backpack") exitWith {};
clearWeaponCargoGlobal _backpack;
clearMagazineCargoGlobal _backpack;
};
};
INV_CreateItem = {
liafu = true;
private["_object", "_class", "_amount", "_storage"];
_object = _this select 0;
_class = _this select 1;
_amount = _this select 2;
_storage = _this select 3;
[_object, _class, _amount, _storage] call INV_AddItemStorage;
};
INV_IsPlayerVehicle = {
private["_isPlayerVehicle", "_vehicle"];
_vehicle = _this select 0;
if (isNil "_vehicle") exitWith { false };
_isPlayerVehicle = _vehicle getVariable "isPlayerVehicle";
if (isNil "_isPlayerVehicle") exitWith { false };
if (typeName _isPlayerVehicle != "BOOL") exitWith { false };
_isPlayerVehicle
};
INV_LocateClosestVehicle = {
private["_i", "_list", "_vehicle", "_distance"];
_distance = _this select 0;
if (isNil "_distance") exitWith {nil};
if (typeName _distance != "SCALAR") exitWith { nil };
_list = nearestObjects [player, ["LandVehicle", "Air"], _distance];
//player groupChat format["_list = %1", _list];
_i = (count _list - 1);
_vehicle = nil;
while { _i >= 0 } do {
private["_current", "_found"];
_current = _list select _i;
//player groupChat format["_current = %1", _current];
if (alive(_current) && ([_current] call INV_IsPlayerVehicle)) then {
_vehicle = _current;
};
_i = _i - 1;
};
_vehicle
};