He-Man Posted June 2, 2016 Report Share Posted June 2, 2016 Hi, everybody of you know the problem with disappearing mags out of current weapon on login (only with 6,5mm weapons, especially GL-Weapons) and revive (every weapon). Now I took some time to search for the Problem and I found it. I also found some other things, that I was able to tune. Let's begin with EPOCH_server_loadplayer.sqf: Spoiler if (count _weaponsAndItems >= 2) then { _equipped = _weaponsAndItems select 2; If count _weaponsAndItems is >= 2, it can be 2. But then, _equipped can not be _weaponsaAndItems select 2! So it must be "if (count _weaponsAndItems >= 3)" Spoiler { ... if (_x isEqualType []) then{ _wMags = true; _wMagsArray = _x; } else { // attachments if (_x != "") then{ _attachments pushBack _x; }; }; ... } forEach(_weaponsAndItems select 1); _weaponsAndItems select 1 is defined in EPOCH_server_savePlayer.sqf as "weaponsItems _player". If the Player have a GL Weapon within a normal mag AND rnd Greande Shell, "weaponsItems _player" gives an array of: ['attach1','attach2','attach3',[magazine1],[magazine2],'bipod']. Because there can come 2 arrays of mags, it must be: "_wMagsarray PUSHBACK _x" Spoiler if (_weapon in _equipped) then { _equipped = _equipped - [_weapon]; if (_wMags) then { _newPlyr addMagazine _wMagsArray; }; 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 { // overflow need to add these items to storage { _newPlyr addItem _x; } forEach _attachments; if (_wMags) then { _newPlyr addMagazine _wMagsArray; }; In this Part, you can trim the code a bit. There is no need for running "if (_wMags) then ..." in IF and in ELSE. So just move it before the if/else. The second part is, because we made an array of more then one mag in _wMagsArray, we have to load it as follows: if (_wMags) then { { _newPlyr addMagazine _x; } foreach _wMagsArray; }; Now we come to EPOCH_server_revivePlayer.sqf: Because the load player script and the revive player script are very similar, a have assumed the _fnc_addItemToX from the load player script to the top of the revive player script Spoiler if (_player distance _reviver > 20) exitWith{}; _fnc_addItemToX = { private ["_itemSlot","_itemqtys","_newPlyr"]; _newPlyr = _this select 0; { _itemSlot = _forEachIndex; _itemqtys = _x select 1; { for "_i" from 1 to (_itemqtys select _forEachIndex) do { switch _itemSlot do { case 0: { _newPlyr addItemToUniform _x }; case 1: { _newPlyr addItemToVest _x }; case 2: { _newPlyr addItemToBackpack _x }; }; }; } forEach(_x select 0); } forEach (_this select 1); }; if (!local _player) then { Everybody knows, that often the revived Player have another weapon, as before he died. That is because the script is looking for all nearestObjects WeaponHolderSimulated from near to far and the last Weaponholder overwrite the first. The solution is reversing the array of weaponholders. In this part we also can fix the problem, that weapons can be duped by reviving. We delete the weponholders with our primary and secondary weapon instant. Here the "old" code: Spoiler _primaryWeapon = ""; _secondaryWeapon = ""; _droppedWeapons = []; { { _droppedWeapons pushBack _x; _type = getNumber(configfile >> "cfgweapons" >> (_x select 0) >> "type"); switch _type do { case 1: { _primaryWeapon = _x select 0 }; case 4: { _secondaryWeapon = _x select 0 }; }; } forEach (weaponsItemsCargo _x); } forEach nearestObjects[_player, ["WeaponHolderSimulated"], 12]; and here the new: Spoiler _wh = nearestObjects[_player, ["WeaponHolderSimulated"], 12]; _droppedPrimary = []; _droppedSecondary = []; _droppedWeapons = []; _deleteprimary = []; _deletesecondary = []; reverse _wh; { _currwh = _x; { _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]}; }; } forEach (weaponsItemsCargo _x); } foreach _wh; { if (!isnull _x) then {deletevehicle _x}; } foreach (_deleteprimary+_deletesecondary); if !(_droppedPrimary isequalto []) then {_droppedWeapons pushback _droppedPrimary}; if !(_droppedSecondary isequalto []) then {_droppedWeapons pushback _droppedSecondary}; Next the same as in load player: "if (count _weapons >= 3) then {..." And for loading the Inventory I have taken the same codes as in load player. It is already tested and working for us. Here the complete files: Epoch_server_loadPlayer.sqf: https://www.dropbox.com/s/yaepsos0b11x5m4/EPOCH_server_loadPlayer.sqf?dl=0 EPOCH_server_revivePlayer.sqf: https://www.dropbox.com/s/vb8ayuwlc2x0fb4/EPOCH_server_revivePlayer.sqf?dl=0 Tarabas, Grahame, vbawol and 1 other 4 Link to comment Share on other sites More sharing options...
Tarabas Posted June 2, 2016 Report Share Posted June 2, 2016 Oh yes, thank you He-Man. Good job. I will add this to the server. Epoch Team, if this is not part of the survival idea, pleas add this in 0.3.9 too. sorry saw the player revive feedback and its bug label @ github too late Link to comment Share on other sites More sharing options...
He-Man Posted June 3, 2016 Author Report Share Posted June 3, 2016 Then please give feedback, if this is working for you too. Link to comment Share on other sites More sharing options...
Tarabas Posted June 3, 2016 Report Share Posted June 3, 2016 I tested this now with a friend. Respawn/Relog with same ammo is working. Also after player revive we had the same Weapon with same ammo back as before we died. So that works :) Link to comment Share on other sites More sharing options...
obermaig Posted June 6, 2016 Report Share Posted June 6, 2016 Great Job, He-Man, many Thanks! That works perfectly! Link to comment Share on other sites More sharing options...
ReDBaroN Posted June 6, 2016 Report Share Posted June 6, 2016 Nice one He-Man. Works for me too :) Link to comment Share on other sites More sharing options...
vbawol Posted June 6, 2016 Report Share Posted June 6, 2016 Thanks He-Man! Got this added to 0.3.9 Grahame, arc7r7, axeman and 3 others 6 Link to comment Share on other sites More sharing options...
Grahame Posted June 6, 2016 Report Share Posted June 6, 2016 Works for me too Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now