Jump to content

MetaliX

Member
  • Content Count

    3
  • Joined

  • Last visited

  • Medals

Community Reputation

1 Neutral

About MetaliX

  • Rank
    Rookie
  1. Firstly, apologies for my double post. I was having some issues with the forums at the time. In the remaining post I mentioned that if you add an eventhandler with "killed" and execute the script, it will save the gear you die with. For example, this in the player init line: this addEventHandler ["killed", {_this execVM "weaponrespawn.sqf";}]; Ive not personally tried it yet but it should work. *EDIT* I have tested with the code above. It partially works. I respawn with the weapons i died with but nothing else. I also get the error "Bad vehicletype". Anyone got any ideas why? *EDIT 2* FIXED SEE BELOW ---------- Post added at 17:54 ---------- Previous post was at 17:53 ---------- Well I have come up with a solution to not having to save every time you die. That is, if you want to spawn with the same gear every time and NOT what you had when you died. Ie. if during your mission you picked up a weapon you didnt have when you saved your gear, you will not have it when you respawn. Firstly add this into the init line of each player: this addEventHandler ["killed", {_this execVM "weaponrespawn.sqf";}]; then add this into the init of an object eg. a crate: this addAction["Save Loadout","weaponsave.sqf"]; then make a file called weaponsave.sqf and paste this in: weaponsvar = weapons player; magazinesvar = magazines player; vestvar = vest player; uniformvar = uniform player; headgearvar = headgear player; backpackvar = backpack player; primaccvar = primaryWeaponItems player; //Primary Weapon Accessories secaccvar = secondaryWeaponItems player;//Secondary Weapon Accessories sideaccvar = handgunItems player; // Sidearm Accessories itemsvar = items player; // Medkits, ToolKits etc. assitemsvar = assignedItems player; // NVG's, GPS etc. hint "Loadout Saved"; then make another file and call it weaponrespawn.sqf and paste this in: waitUntil {!alive player}; waitUntil {alive player}; _p = player; removeAllWeapons _p; _p addBackpack backpackvar; _p addVest vestvar; _p addUniform uniformvar; _p addHeadgear headgearvar; {_p addItem _x} forEach itemsvar; {_p addMagazine _x} forEach magazinesvar; {_p addWeapon _x} forEach weaponsvar; {_p addPrimaryWeaponItem _x} forEach primaccvar; {_p addSecondaryWeaponItem _x} forEach secaccvar; {_p addHandgunItem _x} forEach sideaccvar; {_p addItem _x} forEach assitemsvar; {_p assignItem _x} forEach assitemsvar; _primw = primaryWeapon _p; hint "Loadout Restored"; if (_primw != "") then { _p selectWeapon _primw; // Fix for weapons with grenade launcher _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles"); _p selectWeapon (_muzzles select 0); }; The difference here from my original script besides the obvious fact there there is now two scripts, is that the weaponsave.sqf script uses global variables as opposed to local variables. Hope this helps guys. :)
  2. Hey guys, Ive been tackling this today. Ive used this save gear script from Armaholic as a baseline: http://www.armaholic.com/page.php?id=10785&highlight=WEAPONRESPAWN The script works almost perfectly; the only issue is that every time you respawn, you lose 1 magazine for your primary, secondary and sidearm. This includes GL rounds. You keep everything else however; uniform, vest, attachments... even mines, hand grenades and med/tool kits. If someone could come up with a way to fix the losing mags issue, it would be very much appreciated. Just one thing to bare in mind, every time you respawn, you have to save your gear. If you don't you'll lose it on repsawn. A way around this would be to run the script using an eventhandler also on "respawn" or "killed" in case you forget to save. This is my first real attempt at scripting so, be gentle :D Apologies if the script is a bit messy. I put this in the init line of a crate. this addAction["Save Loadout","weaponrespawn.sqf"]; SQF file. I feel the section in red may be redundant, but it works with it in however. _weapons = weapons player; _magazines = magazines player; _vest = vest player; _uniform = uniform player; _headgear = headgear player; _backpack = backpack player; _primacc = primaryWeaponItems player; //Primary Weapon Accessories _secacc = secondaryWeaponItems player;//Secondary Weapon Accessories _sideacc = handgunItems player; // Sidearm Accessories _items = items player; // Medkits, ToolKits etc. _assitems = assignedItems player; // NVG's, GPS etc. hint "Loadout Saved"; waitUntil {!alive player}; waitUntil {alive player}; _p = player; removeAllWeapons _p; _p addVest _vest; _p addUniform _uniform; _p addHeadgear _headgear; _p addBackpack _backpack; {_p addItem _x} forEach _items; {_p addMagazine _x} forEach _magazines; {_p addWeapon _x} forEach _weapons; {_p addPrimaryWeaponItem _x} forEach _primacc; {_p addSecondaryWeaponItem _x} forEach _secacc; {_p addHandgunItem _x} forEach _sideacc; {_p addItem _x} forEach _assitems; {_p assignItem _x} forEach _assitems; [color="#FF0000"]_primw = primaryWeapon _p; hint "Loadout Restored"; if (_primw != "") then { _p selectWeapon _primw; // Fix for weapons with grenade launcher _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles"); _p selectWeapon (_muzzles select 0); };[/color]
  3. *Edit* Removed double post
×