summaryrefslogtreecommitdiffstats
path: root/Client/Functions/Client_RespawnBag.sqf
blob: dd205273ce94556328865d9a4900249931399e84 (plain)
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
private ["_add"];

if !(isNil 'respawnBag') then {
	_add = false;
	/* Player did purchase a backpack and have one by default */
	if !(isNull (unitBackPack player)) then {
		/* If the backpack type is different from the current one, then we remove it */
		if (typeOf (unitBackPack player) != respawnBag) then {
			removeBackpack player;
			_add = true;
		};
	} else {
		_add = true;
	};

	/* We give a new backpack to the player */
	if (_add) then {player addBackpack respawnBag};
	
	/* We clear the new backpack content */
	clearMagazineCargo (unitBackpack player);
	
	/* We add the player's backpack content inside the new one */
	if (count (respawnBagContent select 0) > 0) then {
		for '_u' from 0 to count(respawnBagContent select 0)-1 do {
			(unitBackpack player) addMagazineCargo [(respawnBagContent select 0) select _u, (respawnBagContent select 1) select _u];
		};
	};
} else {
	/* Player did not purchase a backpack but have one by default */
	if !(isNull (unitBackPack player)) then {
		removeBackpack player;
	};
};