mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
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:
parent
28adb8942d
commit
cc04eac4fb
@ -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
|
@ -212,28 +212,8 @@ if (!isNull _player) then {
|
||||
_currentWeapon = _apperance param [4,""];
|
||||
// _newPlyr setUnitLoadout [_loadout, false];
|
||||
|
||||
// Workaround for Client / Server synchronizing issue in unitloadout
|
||||
_Primary = _loadout select 0;
|
||||
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;
|
||||
};
|
||||
// Workaround for Client / Server synchronizing issue in SetUnitLoadout
|
||||
[_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
|
||||
|
||||
diag_log format["DEBUG: loaded player %1 with new schema Version %2", _newPlyr, _schemaVersion];
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf
|
||||
*/
|
||||
//[[[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]]]
|
||||
params ["_player","_reviver",["_token","",[""]] ];
|
||||
|
||||
@ -49,12 +49,9 @@ if (!local _player) then {
|
||||
// Load Inventory
|
||||
_loadout = getUnitLoadout _player;
|
||||
|
||||
_primaryWeapon = "";
|
||||
_secondaryWeapon = "";
|
||||
_wh = nearestObjects[_player, ["WeaponHolderSimulated"], 12];
|
||||
_droppedPrimary = [];
|
||||
_droppedSecondary = [];
|
||||
_droppedWeapons = [];
|
||||
_deleteprimary = [];
|
||||
_deletesecondary = [];
|
||||
reverse _wh;
|
||||
@ -63,18 +60,23 @@ if (!local _player) then {
|
||||
{
|
||||
_type = getNumber(configfile >> "cfgweapons" >> (_x select 0) >> "type");
|
||||
switch _type do {
|
||||
case 1: {_droppedPrimary = _x; _primaryWeapon = _x select 0; _deleteprimary = [_currwh]};
|
||||
case 4: {_droppedSecondary = _x; _secondaryWeapon = _x select 0;_deletesecondary = [_currwh]};
|
||||
case 1: {_droppedPrimary = _x; _deleteprimary = [_currwh]};
|
||||
case 4: {_droppedSecondary = _x; _deletesecondary = [_currwh]};
|
||||
};
|
||||
} forEach (weaponsItemsCargo _x);
|
||||
} foreach _wh;
|
||||
{
|
||||
if (!isnull _x) then {deletevehicle _x};
|
||||
} 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};
|
||||
// diag_log ["DEBUG: _droppedWeapons %1", _droppedWeapons];
|
||||
};
|
||||
if (count _droppedSecondary == 6) then {
|
||||
_droppedSecondary set [6,_droppedSecondary select 5];
|
||||
_droppedSecondary set [5,[]];
|
||||
};
|
||||
|
||||
hideObjectGlobal _player;
|
||||
|
||||
@ -125,65 +127,12 @@ if (!local _player) then {
|
||||
_newPlyr setDamage 0.25;
|
||||
|
||||
// Add inventory
|
||||
_newPlyr setUnitLoadout [_loadout, false];
|
||||
_loadout set [0,_droppedPrimary];
|
||||
_loadout set [1,_droppedSecondary];
|
||||
// _newPlyr setUnitLoadout [_loadout, false];
|
||||
|
||||
// Dropped Weapons
|
||||
if !(_droppedWeapons isequalto []) then {
|
||||
_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;
|
||||
};
|
||||
// Workaround for Client / Server synchronizing issue in SetUnitLoadout
|
||||
[_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
|
||||
|
||||
// Final Push
|
||||
_token = _newPlyr call EPOCH_server_setPToken;
|
||||
|
@ -65,6 +65,7 @@ class CfgServerFunctions
|
||||
class server_onPlayerDisconnect {};
|
||||
class server_deadPlayer {};
|
||||
class server_revivePlayer {};
|
||||
class server_SetUnitLoadout {};
|
||||
class server_storeCrypto {};
|
||||
class server_equippedItem {};
|
||||
class server_unpackBackpack {};
|
||||
|
Loading…
Reference in New Issue
Block a user