Prevent changing clothes while wearing a backback

Also removed 10m restriction on other players nearby
This commit is contained in:
[VB]AWOL
2013-12-10 17:30:09 -06:00
parent 9071cf2e9c
commit 66e1a9b10f
3 changed files with 105 additions and 161 deletions

View File

@@ -10,8 +10,8 @@ _dialog = findDisplay 106;
_created = false; _created = false;
if ( isNull _dialog ) then { if ( isNull _dialog ) then {
//startLoadingScreen [""]; //startLoadingScreen [""];
createGearDialog [player, "RscDisplayGear"]; createGearDialog [player, "RscDisplayGear"];
_dialog = findDisplay 106; _dialog = findDisplay 106;
_created = true; _created = true;
}; };

View File

@@ -7,10 +7,6 @@ private ["_item","_onLadder","_hasclothesitem","_config","_text","_myModel","_it
if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_83") , "PLAIN DOWN"] }; if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_83") , "PLAIN DOWN"] };
DZE_ActionInProgress = true; DZE_ActionInProgress = true;
// cannot change clothes when another player is nearby
_playerNear = {isPlayer _x} count (player nearEntities ["CAManBase", 12]) > 1;
if(_playerNear) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_84") , "PLAIN DOWN"]; };
_item = _this; _item = _this;
call gear_ui_init; call gear_ui_init;
@@ -21,9 +17,11 @@ _hasclothesitem = _this in magazines player;
_config = configFile >> "CfgMagazines"; _config = configFile >> "CfgMagazines";
_text = getText (_config >> _item >> "displayName"); _text = getText (_config >> _item >> "displayName");
if (!_hasclothesitem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"wear"] , "PLAIN DOWN"]}; if (!_hasclothesitem) exitWith { DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"wear"] , "PLAIN DOWN"]};
if (vehicle player != player) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_85"), "PLAIN DOWN"]}; if (vehicle player != player) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_85"), "PLAIN DOWN"]};
if (!isNull (unitBackpack player)) exitWith { DZE_ActionInProgress = false; cutText ["\n\nUnable to change clothes while still hearing backpack.", "PLAIN DOWN"] };
_myModel = (typeOf player); _myModel = (typeOf player);
_itemNew = "Skin_" + _myModel; _itemNew = "Skin_" + _myModel;

View File

@@ -1,4 +1,4 @@
private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_newBackpackType","_backpackWpn","_backpackMag","_backpackWpnTypes","_backpackWpnQtys","_countr","_backpackmagTypes","_backpackmagQtys","_playerObjName"]; private ["_class","_position","_dir","_group","_oldUnit","_newUnit","_currentWpn","_muzzles","_currentAnim","_playerUID","_weapons","_magazines","_primweapon","_secweapon","_playerObjName","_wpnType","_ismelee"];
_class = _this; _class = _this;
_position = getPosATL player; _position = getPosATL player;
@@ -8,59 +8,42 @@ _currentAnim = animationState player;
//Get PlayerID //Get PlayerID
private ["_playerUID"]; _playerUID = "";
_playerUID = ""; if (count playableUnits == 0 and isServer) then {
if (count playableUnits == 0 and isServer) then {
//In Single Player //In Single Player
isSinglePlayer = true; isSinglePlayer = true;
player sidechat "Single player Mode detected!"; player sidechat "Single player Mode detected!";
//_id = [42,"SinglePlayer"] spawn server_onPlayerConnect; //_id = [42,"SinglePlayer"] spawn server_onPlayerConnect;
_playerUID = "42"; _playerUID = "42";
} else { } else {
_playerUID = getPlayerUID player; _playerUID = getPlayerUID player;
}; };
//BackUp Weapons and Mags //BackUp Weapons and Mags
private ["_weapons","_magazines","_primweapon","_secweapon"];
_weapons = weapons player;
_magazines = call player_countmagazines; //magazines player;
if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]}; _weapons = weapons player;
_magazines = call player_countmagazines; //magazines player;
if ( (_playerUID == dayz_playerUID) && (count _magazines == 0) && (count (magazines player) > 0 )) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]};
// if ( count _magazines == 0 ) exitWith {cutText [(localize "str_epoch_player_17"), "PLAIN DOWN"]}; _primweapon = primaryWeapon player;
_secweapon = secondaryWeapon player;
_primweapon = primaryWeapon player; //Checks
_secweapon = secondaryWeapon player; if(!(_primweapon in _weapons) && _primweapon != "") then {
//Checks
if(!(_primweapon in _weapons) && _primweapon != "") then {
_weapons = _weapons + [_primweapon]; _weapons = _weapons + [_primweapon];
}; };
if(!(_secweapon in _weapons) && _secweapon != "") then { if(!(_secweapon in _weapons) && _secweapon != "") then {
_weapons = _weapons + [_secweapon]; _weapons = _weapons + [_secweapon];
}; };
// if(count _magazines == 0) then {
// _magazines = magazines player;
// };
//BackUp Backpack
private ["_newBackpackType","_backpackWpn","_backpackMag"];
dayz_myBackpack = unitBackpack player;
_newBackpackType = (typeOf dayz_myBackpack);
if(_newBackpackType != "") then {
_backpackWpn = getWeaponCargo unitBackpack player;
_backpackMag = getMagazineCargo unitBackpack player;
};
//Get Muzzle //Get Muzzle
_currentWpn = currentWeapon player; _currentWpn = currentWeapon player;
_muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles"); _muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
if (count _muzzles > 1) then { if (count _muzzles > 1) then {
_currentWpn = currentMuzzle player; _currentWpn = currentMuzzle player;
}; };
//Debug Message //Debug Message
/* /*
@@ -70,41 +53,40 @@ diag_log str(_magazines);
diag_log (str(_backpackWpn)); diag_log (str(_backpackWpn));
diag_log (str(_backpackMag)); diag_log (str(_backpackMag));
*/ */
//Secure Player for Transformation //Secure Player for Transformation
player setPosATL dayz_spawnPos; player setPosATL dayz_spawnPos;
//BackUp Player Object //BackUp Player Object
_oldUnit = player; _oldUnit = player;
/***********************************/ /***********************************/
//DONT USE player AFTER THIS POINT //DONT USE player AFTER THIS POINT
/***********************************/ /***********************************/
//Create New Character //Create New Character
//[player] joinSilent grpNull; //[player] joinSilent grpNull;
_group = createGroup west; _group = createGroup west;
_newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"]; _newUnit = _group createUnit [_class,dayz_spawnPos,[],0,"NONE"];
_newUnit setPosATL _position; _newUnit setPosATL _position;
_newUnit setDir _dir; _newUnit setDir _dir;
//Clear New Character //Clear New Character
{_newUnit removeMagazine _x;} forEach magazines _newUnit; {_newUnit removeMagazine _x;} forEach magazines _newUnit;
removeAllWeapons _newUnit; removeAllWeapons _newUnit;
//Equip New Charactar //Equip New Charactar
{ {
if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x }; if (typeName _x == "ARRAY") then {_newUnit addMagazine [_x select 0,_x select 1] } else { _newUnit addMagazine _x };
//sleep 0.05; } forEach _magazines;
} forEach _magazines;
{ {
_newUnit addWeapon _x; _newUnit addWeapon _x;
//sleep 0.05; } forEach _weapons;
} forEach _weapons;
//Check and Compare it //Check and Compare it
if(str(_weapons) != str(weapons _newUnit)) then { if(str(_weapons) != str(weapons _newUnit)) then {
//Get Differecnce //Get Differecnce
{ {
_weapons = _weapons - [_x]; _weapons = _weapons - [_x];
@@ -113,69 +95,33 @@ diag_log (str(_backpackMag));
//Add the Missing //Add the Missing
{ {
_newUnit addWeapon _x; _newUnit addWeapon _x;
//sleep 0.2;
} forEach _weapons; } forEach _weapons;
}; };
if(_primweapon != (primaryWeapon _newUnit)) then { if(_primweapon != (primaryWeapon _newUnit)) then {
_newUnit addWeapon _primweapon; _newUnit addWeapon _primweapon;
}; };
if (_primweapon == "MeleeCrowbar") then { if (_primweapon == "MeleeCrowbar") then {
_newUnit addMagazine 'crowbar_swing'; _newUnit addMagazine 'crowbar_swing';
}; };
if (_primweapon == "MeleeSledge") then { if (_primweapon == "MeleeSledge") then {
_newUnit addMagazine 'sledge_swing'; _newUnit addMagazine 'sledge_swing';
}; };
if (_primweapon == "MeleeHatchet_DZE") then { if (_primweapon == "MeleeHatchet_DZE") then {
_newUnit addMagazine 'Hatchet_Swing'; _newUnit addMagazine 'Hatchet_Swing';
}; };
if (_primweapon == "MeleeMachete") then { if (_primweapon == "MeleeMachete") then {
_newUnit addMagazine 'Machete_swing'; _newUnit addMagazine 'Machete_swing';
}; };
if (_primweapon == "MeleeFishingPole") then { if (_primweapon == "MeleeFishingPole") then {
_newUnit addMagazine 'Fishing_Swing'; _newUnit addMagazine 'Fishing_Swing';
}; };
if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then { if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
_newUnit addWeapon _secweapon; _newUnit addWeapon _secweapon;
}; };
//Add and Fill BackPack
if (!isNil "_newBackpackType") then {
if (_newBackpackType != "") then {
_newUnit addBackpack _newBackpackType;
//_oldBackpack = dayz_myBackpack;
dayz_myBackpack = unitBackpack _newUnit;
//Fill backpack contents
//Weapons
_backpackWpnTypes = [];
_backpackWpnQtys = [];
if (count _backpackWpn > 0) then {
_backpackWpnTypes = _backpackWpn select 0;
_backpackWpnQtys = _backpackWpn select 1;
};
_countr = 0;
{
dayz_myBackpack addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
_countr = _countr + 1;
} forEach _backpackWpnTypes;
//magazines
_backpackmagTypes = [];
_backpackmagQtys = [];
if (count _backpackmag > 0) then {
_backpackmagTypes = _backpackMag select 0;
_backpackmagQtys = _backpackMag select 1;
};
_countr = 0;
{
dayz_myBackpack addmagazineCargoGlobal [_x,(_backpackmagQtys select _countr)];
_countr = _countr + 1;
} forEach _backpackmagTypes;
};
};
//Debug Message //Debug Message
/* /*
diag_log "Swichtable Unit Created. Equipment:"; diag_log "Swichtable Unit Created. Equipment:";
@@ -185,38 +131,38 @@ diag_log str(getWeaponCargo unitBackpack _newUnit);
diag_log str(getMagazineCargo unitBackpack _newUnit); diag_log str(getMagazineCargo unitBackpack _newUnit);
*/ */
//Make New Unit Playable //Make New Unit Playable
addSwitchableUnit _newUnit; addSwitchableUnit _newUnit;
setPlayable _newUnit; setPlayable _newUnit;
selectPlayer _newUnit; selectPlayer _newUnit;
//Clear and delete old Unit //Clear and delete old Unit
removeAllWeapons _oldUnit; removeAllWeapons _oldUnit;
{_oldUnit removeMagazine _x;} forEach magazines _oldUnit; {_oldUnit removeMagazine _x;} forEach magazines _oldUnit;
deleteVehicle _oldUnit; deleteVehicle _oldUnit;
//Move player inside //Move player inside
// player switchCamera = _currentCamera; // player switchCamera = _currentCamera;
if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;}; if(_currentWpn != "") then {_newUnit selectWeapon _currentWpn;};
[objNull, player, rSwitchMove,_currentAnim] call RE; [objNull, player, rSwitchMove,_currentAnim] call RE;
//dayz_originalPlayer attachTo [_newUnit]; //dayz_originalPlayer attachTo [_newUnit];
player disableConversation true; player disableConversation true;
player setVariable ["bodyName",dayz_playerName,true]; player setVariable ["bodyName",dayz_playerName,true];
_playerUID=getPlayerUID player; _playerUID=getPlayerUID player;
_playerObjName = format["player%1",_playerUID]; _playerObjName = format["player%1",_playerUID];
call compile format["%1 = player;",_playerObjName]; call compile format["%1 = player;",_playerObjName];
publicVariable _playerObjName; publicVariable _playerObjName;
//melee check //melee check
_wpnType = primaryWeapon player; _wpnType = primaryWeapon player;
_ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee")); _ismelee = (gettext (configFile >> "CfgWeapons" >> _wpnType >> "melee"));
if (_ismelee == "true") then { if (_ismelee == "true") then {
call dayz_meleeMagazineCheck; call dayz_meleeMagazineCheck;
}; };
//reveal all near objects. //reveal all near objects.
{player reveal _x} forEach (nearestObjects [getPosATL player, ["All"], 75]); {player reveal _x} forEach (nearestObjects [getPosATL player, ["All"], 50]);
//All is arbitrary and will need to be changed to ["AllVehicles","WeaponHolder","tentStorage"] ++ others (stashes etc.) //All is arbitrary and will need to be changed to ["AllVehicles","WeaponHolder","tentStorage"] ++ others (stashes etc.)