ker8er0s 10 Posted December 16, 2010 Kudos Bon, Very handy script. using it at the moment with a few minor modifications to suit our purposes. Thanks again. Share this post Link to post Share on other sites
Crimson_Raptor 0 Posted December 17, 2010 A possibility is to put in init.sqf: That's the answer I was looking for! Thanks Galzohar! Share this post Link to post Share on other sites
r.flagg 11 Posted January 17, 2011 Does anyone have a mission with this script used properly they can link to, please? Hate to be a bother, but this thread has me confused. I tried ... copying/pasting the first block of code that Bon has posted, and made it saveloadout.sqf. Then I put execVM "saveloadout.sqf"; in my init.sqf I also added WaitUntil{isDedicated || not isNull player}; to the top of my saveloadout.sqf. But we're still having issues with it when playing on a listen server. I have a large backpack (12 slots) with a sniper rifle and 2 magazines in it, but the weapon isn't showing up for me, my bag is empty. And a few times my friend says he's respawning with a different weapon altogether. Not one he had to start with, and not hte one in his bag. We use norrin's respawn/revive. Share this post Link to post Share on other sites
sgtice 10 Posted February 10, 2011 As far as adding items that you spawn with, say you removed GPS and Map from some people, etc. What would you need to add into that script? Share this post Link to post Share on other sites
Bon 12 Posted February 11, 2011 (edited) As far as adding items that you spawn with, say you removed GPS and Map from some people, etc. What would you need to add into that script? Sorry I don't understand. Just try to do what you want to do using this script. Here's no distinction made between adding and removing stuff, l so it will probably work without modifications. But, as I said, I didn't really understand what you were trying to say. :o @All: Made the instructions in the first post a little bit more explicit, hope that helps. hf. Edited February 11, 2011 by Bon Share this post Link to post Share on other sites
sgtice 10 Posted February 11, 2011 (edited) As far as the script it respawns with the weapons, mags, backpack and contents you had when you spawned. I was wondering how to do the same with the items, like your watch, map, etc. I tried tinkering with it last night and couldn't get it to work And to clarify the 1st page script is now respawn with what you had when you died rather then started the mission with right? Edited February 11, 2011 by SGTIce Share this post Link to post Share on other sites
Bon 12 Posted February 12, 2011 As far as the script it respawns with the weapons, mags, backpack and contents you had when you spawned. I was wondering how to do the same with the items, like your watch, map, etc. I tried tinkering with it last night and couldn't get it to workAnd to clarify the 1st page script is now respawn with what you had when you died rather then started the mission with right? Here, "weapons" include all items like watch, map, compass etc.... The script lets you spawn either with what you had when you died OR with what you saved before (if you saved your loadout before) using the saveloadout.sqf script. That was always the intention of the script, nothing else. Let's say, you use code in a script or a units init line to customarily equip the unit at the beginning of a mission. Then simply add to the very end of this code the following: _nul = ["",<unit>] execVM "saveloadout.sqf"; where <unit> is the reference to the unit (in a script probably a local variable like _unit, in the init line it would be this). Share this post Link to post Share on other sites
sgtice 10 Posted February 12, 2011 (edited) Is there a way I could modify it to a 3rd approach of respawning with a custom loadout minus the save loadout? And during my tests I get all the items back. Edited February 12, 2011 by SGTIce Share this post Link to post Share on other sites
r.flagg 11 Posted February 16, 2011 (edited) Let's say, you use code in a script or a units init line to customarily equip the unit at the beginning of a mission. Then simply add to the very end of this code the following: _nul = ["",<unit>] execVM "saveloadout.sqf"; where <unit> is the reference to the unit (in a script probably a local variable like _unit, in the init line it would be this). Would / should that be any different for a listen server? I think I have this working on our listen server, except when I connect to the host, I don't have my weapon in my backpack at start of mission (but he did). Here's my init: removeAllWeapons this; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addMagazine "30Rnd_556x45_Stanag"; this addWeapon "M16A2"; this addMagazine "15Rnd_9x19_M9SD"; this addMagazine "15Rnd_9x19_M9SD"; this addMagazine "15Rnd_9x19_M9SD"; this addMagazine "15Rnd_9x19_M9SD"; this addWeapon "M9SD"; this addmagazine "HandGrenade_West"; this addmagazine "HandGrenade_West"; this addmagazine "HandGrenade_West"; this addWeapon "Binocular"; removeBackpack this; this addBackpack "US_Backpack_EP1"; (unitBackpack this) addWeaponCargo ["M110_TWS_EP1",1]; (unitBackpack this) addMagazineCargo ["20Rnd_762x51_B_SCAR",2]; _nul = ["",this] execVM "saveloadout.sqf"; Edit: Think I got it working. I have started to use a custom script to give that custom loadout, instead of putting it in the init line of the player. Thanks for this handy script Bon. Edited February 17, 2011 by R.Flagg Share this post Link to post Share on other sites
kiptanoi 10 Posted August 25, 2011 I am not so god at this so please help. Is this right? I got this so far: init.sqf // To get proper gear on our team gear=compile preprocessfile "myGear.sqf"; [] call gear; // Save current loadout. _nul = ["",player] execVM "saveloadout.sqf"; // To get players to spawn with proper gear. execVM "player_respawn.sqf"; myGear.sqf private["_u"]; _DumpAmmo={ waituntil{!isNull _this}; _u= _this; removeallweapons _u }; _Add_Team_Spec_Leader={ waituntil{!isNull _this}; _u= _this; _u addweapon "ACE_VTAC_RUSH72"; _u addweapon "ACE_HuntIR_monitor"; _u addweapon "ItemGPS"; _u addweapon "NVGoggles"; _u addweapon "ACE_Earplugs"; _u addweapon "ACE_MX2A"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addMagazine "ACE_HuntIR_M203"; _u addMagazine "ACE_HuntIR_M203"; _u addmagazine "SmokeShell"; _u addmagazine "SmokeShell"; _u addMagazine "ACE_M34"; _u addMagazine "ACE_M34"; _u addMagazine "ACE_M34"; _u addMagazine "ACE_M34"; _u addMagazine "1Rnd_HE_M203"; _u addMagazine "1Rnd_HE_M203"; _u addMagazine "1Rnd_HE_M203"; _u addMagazine "1Rnd_HE_M203"; _u addweapon "SCAR_L_STD_EGLM_TWS"; _u selectWeapon "SCAR_L_STD_EGLM_TWS"; //[_u, "Laserbatteries", 1] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "30Rnd_556x45_Stanag", 5] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "ACE_HuntIR_M203", 2] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "SmokeShell", 2] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "MAAWS_HEDP", 1] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "MAAWS_HEAT", 1] call ACE_Sys_Ruck_fnc_AddMagToRuck; }; _Add_Team_Spec_AT={ waituntil{!isNull _this}; _u= _this; _u addweapon "ACE_VTAC_RUSH72"; _u addweapon "ItemGPS"; _u addweapon "NVGoggles"; _u addweapon "ACE_Earplugs"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "30Rnd_556x45_Stanag"; _u addmagazine "MAAWS_HEDP"; _u addmagazine "MAAWS_HEAT"; _u addmagazine "ACE_M34"; _u addmagazine "SmokeShell"; _u addweapon "SCAR_L_STD_EGLM_TWS"; _u setVariable ["ACE_weapononback", "MAAWS"]; _u selectWeapon "SCAR_L_STD_EGLM_TWS"; [_u, "30Rnd_556x45_Stanag", 10] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "SmokeShell", 5] call ACE_Sys_Ruck_fnc_AddMagToRuck; [_u, "ACE_M34", 5] call ACE_Sys_Ruck_fnc_AddMagToRuck; }; if(!isNil "m1")then{ _u=m1; _u call _DumpAmmo; _u call _Add_Team_Spec_Leader; }; if(!isNil "m2")then{ _u=m2; _u call _DumpAmmo; _u call _Add_Team_Spec_AT; }; saveloadout.sqf WaitUntil{isDedicated || not isNull player}; _unit = _this select 1; _weapons = weapons _unit; _magazines = magazines _unit; _backpack = unitBackpack _unit; _backpackmagazines = getMagazineCargo _backpack; _backpackweapons = getWeaponCargo _backpack; savedloadout = [_weapons,_magazines,typeOf _backpack,_backpackmagazines,_backpackweapons]; hint "current loadout saved"; player_respawn.sqf WaitUntil{not isNull player || isDedicated}; player addEventHandler ["Killed",{ player spawn { _unit = _this; private ['_magazines','_weapons','_backpack','_backpackweap','_backpackmags']; if(isNil "savedloadout") then { _weapons = weapons _unit; _magazines = magazines _unit; _backpack = typeOf unitBackpack _unit; _backpackmags = getMagazineCargo unitBackpack _unit; _backpackweap = getWeaponCargo unitBackpack _unit; } else { _weapons = savedloadout select 0; _magazines = savedloadout select 1; _backpack = savedloadout select 2; _backpackmags = savedloadout select 3; _backpackweap = savedloadout select 4; }; WaitUntil{alive player}; removeAllWeapons player; removeAllItems player; removeBackpack player; {player addMagazine _x} foreach _magazines; {player addWeapon _x} foreach _weapons; if (primaryWeapon player != "") then { player selectWeapon (primaryWeapon player); _muzzles = getArray(configFile>>"cfgWeapons" >> primaryWeapon player >> "muzzles"); // Fix for weapons with grenade launcher player selectWeapon (_muzzles select 0); }; if(_backpack != "") then { player addBackpack _backpack; clearWeaponCargo (unitBackpack player); clearMagazineCargo (unitBackpack player); for "_i" from 0 to (count (_backpackmags select 0) - 1) do { (unitBackpack player) addMagazineCargo [(_backpackmags select 0) select _i,(_backpackmags select 1) select _i]; }; for "_i" from 0 to (count (_backpackweap select 0) - 1) do { (unitBackpack player) addWeaponCargo [(_backpackweap select 0) select _i,(_backpackweap select 1) select _i]; }; }; }; }]; And here is what I want with it: 1) The players got diffrent loadout. 2) The loadout are automatic saved. 3) I have a save loadout action and can use it. (this in initline at a crate: player addaction ["Save Loadout","saveloadout.sqf"];) 3) All players got there diffrent saved loadout when respawned. Is my current code ok and multiplayer compatible? Share this post Link to post Share on other sites
galzohar 31 Posted August 25, 2011 Add a waitUntil {!isNil "ace_sys_ruck"}; before you use ruck functions, afaik it is possible (although rare) that ACE ruck system will not be initialized by the time your gear script runs. I also doubt the backpack commands work with ACE rucks since they are completely different than how the BIS rucks work. Also, it might be a bit more clean to just set the variables (weapons, magazines, etc) and then run the load loadout script, instead of having 2 separate scripts that do the same thing (equip the player). Also, I'm not sure how you choose which player gets what, but yours might not do what you want... If you want to check which unit the player has taken just check if player==unit1 and run the script client-side only (if (!isDedicated) then {...};) Share this post Link to post Share on other sites