summaryrefslogtreecommitdiffstats
path: root/Client/Functions/Client_OnRespawnHandler.sqf
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.pro>2026-06-11 19:38:09 +0300
committerhybrid <hybrid@hybridlabs.pro>2026-06-11 19:38:09 +0300
commita3a91d4f45b22fd487ecbc954ad979be5d03efdd (patch)
treea554ab159a347dcd6c00ca1c7c26c1ec3ac0a6bd /Client/Functions/Client_OnRespawnHandler.sqf
downloada2wf_chernarus-main.tar.gz
a2wf_chernarus-main.tar.bz2
a2wf_chernarus-main.zip
Diffstat (limited to 'Client/Functions/Client_OnRespawnHandler.sqf')
-rw-r--r--Client/Functions/Client_OnRespawnHandler.sqf78
1 files changed, 78 insertions, 0 deletions
diff --git a/Client/Functions/Client_OnRespawnHandler.sqf b/Client/Functions/Client_OnRespawnHandler.sqf
new file mode 100644
index 0000000..fe6c57d
--- /dev/null
+++ b/Client/Functions/Client_OnRespawnHandler.sqf
@@ -0,0 +1,78 @@
+Private ["_buildings","_charge","_funds","_loadDefault","_listbp","_mode","_price","_safeArray","_skip","_spawn","_spawnInside","_temp","_unit","_weaps"];
+
+_unit = _this select 0;
+_spawn = _this select 1;
+_loadDefault = true;
+
+//--- Respawn.
+_spawnInside = false;
+if ((typeOf _spawn) in (Format ["WFBE_%1AMBULANCES",sideJoinedText] Call GetNamespace) && alive _spawn) then {
+ if (_spawn emptyPositions "cargo" > 0 && !(locked _spawn)) then {_unit moveInCargo _spawn;_spawnInside = true};
+};
+
+if !(_spawnInside) then {_unit setPos ([getPos _spawn,10,20] Call GetRandomPosition)};
+
+//--- Loadout.
+if (!isNil "respawnWeapons" && !WFBE_RespawnDefaultGear) then {
+ _mode = 'WFBE_RESPAWNPENALTY' Call GetNamespace;
+
+ if (_mode in [0,2,3,4,5]) then {
+ //--- Calculate the price/funds.
+ if (_mode != 0) then {
+ _price = 0;
+
+ //--- Get the mode pricing.
+ switch (_mode) do {
+ case 2: {_price = respawnGearCost};
+ case 3: {_price = round(respawnGearCost/2)};
+ case 4: {_price = round(respawnGearCost/4)};
+ case 5: {_price = respawnGearCost};
+ };
+
+ //--- Are we charging only on mobile respawn?
+ _charge = true;
+ if (_mode == 5) then {
+ _buildings = (sideJoinedText) Call GetSideStructures;
+ if (_spawn in _buildings || _spawn == ((sideJoinedText) Call GetSideHQ)) then {_charge = false};
+ };
+
+ if (_charge) then {
+ //--- Charge if possible.
+ _funds = Call GetPlayerFunds;
+ if (_funds < _price) then {
+ // Just take it down to zero.
+ _price = _funds;
+ };
+ -(_price) Call ChangePlayerFunds;
+ (Format[localize 'STR_WF_CHAT_Gear_RespawnCharge',_price]) Call GroupChatMessage;
+ };
+ };
+
+ //--- Use the respawn loadout.
+ if(WF_ACE) then
+ {
+ [player, respawnWeapons, respawnAmmo] Call EquipLoadout;
+ player setVariable ["ACE_weapononback", respawnWeaponOnBack];
+ _safeArray = respawnAceRuckContents select 1;
+ player setVariable ["ACE_RuckMagContents", +_safeArray];
+ _safeArray = respawnAceRuckContents select 0;
+ player setVariable ["ACE_RuckWepContents", +_safeArray];
+ }
+ else
+ {
+ _temp = +(respawnWeapons);
+ _listbp = 'WFBE_BACKPACKS' Call GetNamespace;
+ {if (_x in _listbp) then {_temp = _temp - [_x]}} forEach respawnWeapons;
+ _weaps = _temp;
+
+ [_unit,_weaps,respawnAmmo] Call EquipLoadout;
+ if !(WF_A2_Vanilla) then {Call RespawningBag};
+ };
+ _loadDefault = false;
+ };
+};
+
+//--- Load the default loadout.
+if (_loadDefault) then {
+ player Call EquipDefaultLoadout;
+}; \ No newline at end of file