From f994b95c1d4da637e2bdd5b4f0bcd2201e9b7add Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Wed, 16 Nov 2016 13:34:48 -0500 Subject: [PATCH] Add dayz_onBack to surrender --- SQF/dayz_code/actions/player_surrender.sqf | 47 +++++++++++++++++++++ SQF/dayz_code/compile/keyboard.sqf | 49 +--------------------- SQF/dayz_code/compile/player_onPause.sqf | 2 +- SQF/dayz_code/init/compiles.sqf | 1 + SQF/dayz_code/stringtable.xml | 2 +- 5 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 SQF/dayz_code/actions/player_surrender.sqf diff --git a/SQF/dayz_code/actions/player_surrender.sqf b/SQF/dayz_code/actions/player_surrender.sqf new file mode 100644 index 000000000..a7f12b180 --- /dev/null +++ b/SQF/dayz_code/actions/player_surrender.sqf @@ -0,0 +1,47 @@ +private ["_canDo","_iPos","_inVehicle","_item","_onLadder","_pistol","_primary","_removed"]; + +_inVehicle = (vehicle player != player); +_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; +_canDo = (!r_drag_sqf && !r_player_unconscious && !_onLadder && !_inVehicle); + +if (_canDo && !DZE_Surrender && !(player isKindOf "PZombie_VB")) then { + DZE_Surrender = true; + + _primary = primaryWeapon player; + _pistol = ""; + { + if (getNumber (configFile >> "CfgWeapons" >> _x >> "type") == 2) exitWith { + _pistol = _x; + }; + } count (weapons player); + + if (_primary != "" or _pistol != "" or dayz_onBack != "") then { + player playActionNow "PutDown"; + _iPos = getPosATL player; + _item = createVehicle ["WeaponHolder", _iPos, [], 1, "CAN_COLLIDE"]; + _item setposATL _iPos; + if (_primary != "") then { + _removed = ([player,_primary,1] call BIS_fnc_invRemove); + if (_removed == 1) then { + _item addWeaponCargoGlobal [_primary,1]; + }; + }; + if (_pistol != "") then { + _removed = ([player,_pistol,1] call BIS_fnc_invRemove); + if (_removed == 1) then { + _item addWeaponCargoGlobal [_pistol,1]; + }; + }; + if (dayz_onBack != "") then { + _item addWeaponCargoGlobal [dayz_onBack,1]; + dayz_onBack = ""; // Remove from back + if (!isNull findDisplay 106) then {findDisplay 106 displayCtrl 1209 ctrlSetText "";}; + }; + player reveal _item; + }; + + // set publicvariable that allows other player to access gear + player setVariable ["DZE_Surrendered", true, true]; + // surrender animation + player playMove "AmovPercMstpSsurWnonDnon"; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/keyboard.sqf b/SQF/dayz_code/compile/keyboard.sqf index 0e61520c0..0e57f5a90 100644 --- a/SQF/dayz_code/compile/keyboard.sqf +++ b/SQF/dayz_code/compile/keyboard.sqf @@ -105,54 +105,7 @@ if (isNil "keyboard_keys") then { }; }; _surrender = { - _vehicle = vehicle player; - _inVehicle = (_vehicle != player); - _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1; - _canDo = (!r_drag_sqf && !r_player_unconscious && !_onLadder && !_inVehicle); - - if (_canDo && !DZE_Surrender && !(player isKindOf "PZombie_VB")) then { - DZE_Surrender = true; - _dropPrimary = false; - _dropSecondary = false; - - _primaryWeapon = primaryWeapon player; - if (_primaryWeapon != "") then {_dropPrimary = true;}; - _secondaryWeapon = ""; - { - if ((getNumber (configFile >> "CfgWeapons" >> _x >> "Type")) == 2) exitWith { - _secondaryWeapon = _x; - }; - } count (weapons player); - if (_secondaryWeapon != "") then {_dropSecondary = true;}; - - if (_dropPrimary || _dropSecondary) then { - player playActionNow "PutDown"; - _iPos = getPosATL player; - _radius = 1; - _item = createVehicle ["WeaponHolder", _iPos, [], _radius, "CAN_COLLIDE"]; - _item setposATL _iPos; - if (_dropPrimary) then { - _iItem = _primaryWeapon; - _removed = ([player,_iItem,1] call BIS_fnc_invRemove); - if (_removed == 1) then { - _item addWeaponCargoGlobal [_iItem,1]; - }; - }; - if (_dropSecondary) then { - _iItem = _secondaryWeapon; - _removed = ([player,_iItem,1] call BIS_fnc_invRemove); - if (_removed == 1) then { - _item addWeaponCargoGlobal [_iItem,1]; - }; - }; - player reveal _item; - }; - - // set publicvariable that allows other player to access gear - player setVariable ["DZE_Surrendered", true, true]; - // surrender animation - player playMove "AmovPercMstpSsurWnonDnon"; - }; + call player_surrender; _handled = true; }; _gear = { diff --git a/SQF/dayz_code/compile/player_onPause.sqf b/SQF/dayz_code/compile/player_onPause.sqf index 54a919b6f..8142177ba 100644 --- a/SQF/dayz_code/compile/player_onPause.sqf +++ b/SQF/dayz_code/compile/player_onPause.sqf @@ -69,4 +69,4 @@ while {(!isNull _display) && !r_player_dead} do { }; TimeOutDisplayed = false; -if (r_player_dead) exitWith {_btnAbort ctrlEnable true;}; +if (r_player_dead) then {_btnAbort ctrlEnable true;}; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index 8a975b51b..de36543a5 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -184,6 +184,7 @@ if (!isDedicated) then { player_removeItems = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_removeItems.sqf"; player_removeNearby = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_removeNearby.sqf"; player_removeObject = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\remove.sqf"; + player_surrender = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_surrender.sqf"; player_traderCity = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_traderCity.sqf"; player_unlockDoor = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_unlockDoor.sqf"; player_unlockVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_unlockVault.sqf"; diff --git a/SQF/dayz_code/stringtable.xml b/SQF/dayz_code/stringtable.xml index 75ff537ee..cc913746b 100644 --- a/SQF/dayz_code/stringtable.xml +++ b/SQF/dayz_code/stringtable.xml @@ -7534,7 +7534,7 @@ Du kannst dich nicht in der Nähe eines anderen Spielers ausloggen! - You cannot abort near Zombies! + You cannot abort near zombies! Нельзя выходить находясь рядом с зомби! ¡No puedes abortar cerca de zombies! Nemůžete ukončit hru, když jsou zombie poblíž.