Login Fix 3.0

Bypass BI's SetUnitLoadout used on Items in Clothings, because it is not
correct working atm
This commit is contained in:
He-Man 2017-10-11 19:16:32 +02:00
parent 28adb8942d
commit cc04eac4fb
4 changed files with 108 additions and 90 deletions

View File

@ -0,0 +1,88 @@
/*
Author: He-Man - EpochMod.com
Contributors:
Description:
Player Login
Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_SetUnitLoadout.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_type"];
//[[[end]]]
params ["_newPlyr","_loadout"];
// _loadout params ["_primaryarr","_secondaryarr","_handgunarr","_uniformarr","_vestarr","_bpackarr","_HeadGear","_Glasses","_Rangefinderarr","_LinedItemsarr"];
_loadout params ["","","","_uniformarr","_vestarr","_bpackarr","","","",""];
_loadout set [3,[]];
_loadout set [4,[]];
_loadout set [5,[]];
_newPlyr setunitloadout _loadout;
_uniformarr params [["_uniform",""],["_uniformitems",[]]];
_vestarr params [["_vest",""],["_vestitems",[]]];
_bpackarr params [["_bpack",""],["_bpackitems",[]]];
if !(_uniform isequalto "") then {
_newPlyr forceadduniform _uniform;
};
if !(_vest isequalto "") then {
_newPlyr addVest _vest;
};
if !(_bpack isequalto "") then {
_newPlyr addBackpack _bpack;
};
{
_x params ["_container","_items"];
if !(isnull _container) then {
clearitemcargoglobal _container;
clearbackpackcargoglobal _container;
clearmagazinecargoglobal _container;
clearweaponcargoglobal _container;
{
if (count _x > 2) then {
_container addMagazineAmmoCargo _x;
}
else {
if ((_x select 0) isequaltype []) then {
_x params ["_arr","_cnt"];
_type = _arr deleteat 0;
_container addWeaponcargoglobal [_type,_cnt];
{
if !(_x isequalto "" || _x isequalto []) then {
if (_x isequaltype []) then {
_container addMagazineAmmoCargo [_x select 0,1,_x select 1];
}
else {
_container addItemCargoGlobal [_x,1];
};
};
} foreach _arr;
}
else {
_x params [["_type",""],["_cnt",1]];
if !(_cnt isequaltype 1) then {
_cnt = 1;
};
if (_type iskindof "Bag_Base") then {
_container addBackpackCargoGlobal [_type,_cnt];
}
else {
_container addItemCargoGlobal [_type,_cnt];
};
};
};
} foreach _items;
};
} foreach [
[Uniformcontainer _newPlyr, _uniformitems],
[Vestcontainer _newPlyr, _vestitems],
[BackpackContainer _newPlyr, _bpackitems]
];
true

View File

@ -212,28 +212,8 @@ if (!isNull _player) then {
_currentWeapon = _apperance param [4,""]; _currentWeapon = _apperance param [4,""];
// _newPlyr setUnitLoadout [_loadout, false]; // _newPlyr setUnitLoadout [_loadout, false];
// Workaround for Client / Server synchronizing issue in unitloadout // Workaround for Client / Server synchronizing issue in SetUnitLoadout
_Primary = _loadout select 0; [_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
if !(_Primary isequalto []) then {
_loadout set [0,[]];
_newPlyr setunitloadout _loadout;
_primaryweapon = _Primary deleteat 0;
{
if (_x isequaltype []) then {
_newPlyr addMagazine _x;
};
} foreach _Primary;
_newPlyr addweapon _primaryweapon;
removeAllPrimaryWeaponItems _newPlyr;
{
if (_x isequaltype "") then {
_newPlyr addPrimaryWeaponItem _x;
};
} forEach _Primary;
}
else {
_newPlyr setunitloadout _loadout;
};
diag_log format["DEBUG: loaded player %1 with new schema Version %2", _newPlyr, _schemaVersion]; diag_log format["DEBUG: loaded player %1 with new schema Version %2", _newPlyr, _schemaVersion];

View File

@ -13,7 +13,7 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_loadout","_CorpseCrypto","_PlayerCrypto","_attachments","_cIndex","_class","_currwh","_deleteprimary","_deletesecondary","_dir","_droppedPrimary","_droppedSecondary","_droppedWeapons","_equipped","_group","_location","_newPlyr","_playerGroup","_playerUID","_primaryWeapon","_secondaryWeapon","_token","_type","_vars","_wMags","_wMagsArray","_weapon","_wh","_kIndex","_reviver","_reviverCStats","_reviverKarma","_reviverKarmaAdj"]; private ["_loadout","_CorpseCrypto","_PlayerCrypto","_attachments","_cIndex","_class","_currwh","_deleteprimary","_deletesecondary","_dir","_droppedPrimary","_droppedSecondary","_droppedWeapons","_equipped","_group","_location","_newPlyr","_playerGroup","_playerUID","_token","_type","_vars","_wMags","_wMagsArray","_weapon","_wh","_kIndex","_reviver","_reviverCStats","_reviverKarma","_reviverKarmaAdj"];
//[[[end]]] //[[[end]]]
params ["_player","_reviver",["_token","",[""]] ]; params ["_player","_reviver",["_token","",[""]] ];
@ -49,12 +49,9 @@ if (!local _player) then {
// Load Inventory // Load Inventory
_loadout = getUnitLoadout _player; _loadout = getUnitLoadout _player;
_primaryWeapon = "";
_secondaryWeapon = "";
_wh = nearestObjects[_player, ["WeaponHolderSimulated"], 12]; _wh = nearestObjects[_player, ["WeaponHolderSimulated"], 12];
_droppedPrimary = []; _droppedPrimary = [];
_droppedSecondary = []; _droppedSecondary = [];
_droppedWeapons = [];
_deleteprimary = []; _deleteprimary = [];
_deletesecondary = []; _deletesecondary = [];
reverse _wh; reverse _wh;
@ -63,18 +60,23 @@ if (!local _player) then {
{ {
_type = getNumber(configfile >> "cfgweapons" >> (_x select 0) >> "type"); _type = getNumber(configfile >> "cfgweapons" >> (_x select 0) >> "type");
switch _type do { switch _type do {
case 1: {_droppedPrimary = _x; _primaryWeapon = _x select 0; _deleteprimary = [_currwh]}; case 1: {_droppedPrimary = _x; _deleteprimary = [_currwh]};
case 4: {_droppedSecondary = _x; _secondaryWeapon = _x select 0;_deletesecondary = [_currwh]}; case 4: {_droppedSecondary = _x; _deletesecondary = [_currwh]};
}; };
} forEach (weaponsItemsCargo _x); } forEach (weaponsItemsCargo _x);
} foreach _wh; } foreach _wh;
{ {
if (!isnull _x) then {deletevehicle _x}; if (!isnull _x) then {deletevehicle _x};
} foreach (_deleteprimary+_deletesecondary); } foreach (_deleteprimary+_deletesecondary);
if (count _droppedPrimary == 6) then {
_droppedPrimary set [6,_droppedPrimary select 5];
_droppedPrimary set [5,[]];
if !(_droppedPrimary isequalto []) then {_droppedWeapons pushback _droppedPrimary}; };
if !(_droppedSecondary isequalto []) then {_droppedWeapons pushback _droppedSecondary}; if (count _droppedSecondary == 6) then {
// diag_log ["DEBUG: _droppedWeapons %1", _droppedWeapons]; _droppedSecondary set [6,_droppedSecondary select 5];
_droppedSecondary set [5,[]];
};
hideObjectGlobal _player; hideObjectGlobal _player;
@ -125,65 +127,12 @@ if (!local _player) then {
_newPlyr setDamage 0.25; _newPlyr setDamage 0.25;
// Add inventory // Add inventory
_newPlyr setUnitLoadout [_loadout, false]; _loadout set [0,_droppedPrimary];
_loadout set [1,_droppedSecondary];
// _newPlyr setUnitLoadout [_loadout, false];
// Dropped Weapons // Workaround for Client / Server synchronizing issue in SetUnitLoadout
if !(_droppedWeapons isequalto []) then { [_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
_equipped = [_primaryWeapon,_secondaryWeapon];
{
_weapon = _x deleteAt 0;
_type = getNumber(configfile >> "cfgweapons" >> _weapon >> "type");
_attachments = [];
_wMags = false;
_wMagsArray = [];
// suppressor, laser, optics
{
// magazines
if (_x isEqualType []) then{
_wMags = true;
_wMagsArray pushback _x;
} else {
// attachments
if (_x != "") then{
_attachments pushBack _x;
};
};
} forEach _x;
if (_wMags) then {
{
_newPlyr addMagazine _x;
} foreach _wMagsArray;
};
// add weapon if equiped
if (_weapon in _equipped) then {
_equipped = _equipped - [_weapon];
if (_weapon != "") then {
_newPlyr addWeapon _weapon;
};
switch _type do {
case 1: { // primary
removeAllPrimaryWeaponItems _newPlyr;
{ _newPlyr addPrimaryWeaponItem _x }forEach _attachments;
};
case 2: { // handgun
removeAllHandgunItems _newPlyr;
{ _newPlyr addHandgunItem _x }forEach _attachments;
};
case 4: { // secondary
// removeAllSecondaryWeaponItems player; does not exist ?
{
_newPlyr removeSecondaryWeaponItem _x;
} forEach(secondaryWeaponItems _newPlyr);
{ _newPlyr addSecondaryWeaponItem _x }forEach _attachments;
};
};
}else{
{
_newPlyr addItem _x;
}forEach _attachments;
};
} forEach _droppedWeapons;
};
// Final Push // Final Push
_token = _newPlyr call EPOCH_server_setPToken; _token = _newPlyr call EPOCH_server_setPToken;

View File

@ -65,6 +65,7 @@ class CfgServerFunctions
class server_onPlayerDisconnect {}; class server_onPlayerDisconnect {};
class server_deadPlayer {}; class server_deadPlayer {};
class server_revivePlayer {}; class server_revivePlayer {};
class server_SetUnitLoadout {};
class server_storeCrypto {}; class server_storeCrypto {};
class server_equippedItem {}; class server_equippedItem {};
class server_unpackBackpack {}; class server_unpackBackpack {};