Jump to content
aeroson

GET/SET Loadout (saves and loads pretty much everything)

Recommended Posts

Great inspiration on how to use the new commands, very creative with the placeholders. :D

Good job - thanks.

Regarding spawning in underwear:

(Only in MP?) this happens sometimes.

I recommend spawning the load function, and adding micro sleep (0.001) between remove and add of clothes. Seems to fix it.

Share this post


Link to post
Share on other sites

this is great - much more elegant than my version

couple of questions:

1. would it be better to rename the functions to:

get --> save

set --> load

as get can be thought to mean get from array (ie load) or get from player (ie save)

2. if you want the save loadout function to work on spawned ammo crates in MP you need to run the addaction in local player init or respawn script etc

3. do you also have the grenade muzzle bug? if you take nades, save loadout then respawn, do your nades disappear from top right ammo HUD and you can't throw them with G until you drop and pick one up again?

i've added your scripts and still have the issue. it's a select muzzle issue as far as i can see

cheers and awesome work bud

Egg

Share this post


Link to post
Share on other sites

Updated/Fixed

@eggbeast Thank you for assistance and showing me how to reproduce the bug D:

1. Iam sorry, it's just a matter of opinion, you can always rename it ^.^

@others

2. You can either re-addAction every respawn or sleep a bit before addingActions.

3. Was quite a weird bug, if it happens to you, add some sleep before spawning setLoadout.

player addEventHandler ["Respawn", {
   [] spawn {
     sleep 1; // If it still doest not work add more sleep D:
     [player,loadout] spawn setLoadout;
   };
 }
];  

Edited by aeroson

Share this post


Link to post
Share on other sites

yeah totally awesome dude - that's a weight off my mind now - i can focus on the main mission

top effort!

Share this post


Link to post
Share on other sites

Hey! Just trying out your script here. Very nice, but it seems there is a problem with the respawn eventhandler that causes the "respawn with same weapons" thing not to work. Seems that checking the corpse for the last loadout doesn't return the correct results. This makes everyone respawn in their underwear. Anyone else having the same issue?

Share this post


Link to post
Share on other sites

Thank you for nice bug find. Looks like corpse doesn't have any gear at all :/

Here is an inelegant work around...

waitUntil { !isNull player }; // Wait for player to initialize

// Compile scripts
getLoadout = compile preprocessFileLineNumbers 'fnc_get_loadout.sqf';
setLoadout = compile preprocessFileLineNumbers 'fnc_set_loadout.sqf';

// Save loadout every 2 seconds
[] spawn {
 while{true} do {
   if(alive player) then {
     loadout = [player] call getLoadout;
   };
   sleep 2;  
 };
};

// Load saved loadout on respawn
player addEventHandler ["Respawn", {
   [player,loadout] spawn setLoadout;
 }
];

Share this post


Link to post
Share on other sites

Aeroson, you're a life saver. Ingame, that's quite literally, as now people spawn with their gear rather than the diving uniform/weapon they start out with ;)

Just wondering if nedley's post meant anything as i'll be using this in a coop mission;

I have tried in MP and it works, however I changed:

init:

// Load saved loadout on respawn
player addMPEventHandler ["MPRespawn", {
[player,loadout] call setLoadout;
}
];

Will I be required to use the addMPEventHandler and MPRespawn variable for my coop mission?

I apologise if this is a stupid question, my coding experience is limited allthough I am a quick learner. All I need is the documentation and I'll catch up! :)

info I found on mprespawn and mpeventhandler on the wiki:

http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#MPRespawn

As of 1.62, this command does not work as one would expect. It is only triggered on the machine where the unit it was assigned to is local. The only difference between Respawn and MPRespawn is that MPRespawn can be assigned from anywhere while Respawn requires the unit to be local.

This command must be used in conjunction with the new command addMPEventHandler rather than the old command used for non MP commands.

Edited by LeYuno

Share this post


Link to post
Share on other sites

Right on, that seems to fix it for now. I wonder if this should be reported as a bug to the tracker?

Share this post


Link to post
Share on other sites

Yup good idea (will do it), wasn't able to find anything related to it out there.

Share this post


Link to post
Share on other sites

binoculars (they are a weapon not an item) don't reload to body at the moment in evo. not sure if this is because of their weird status

Share this post


Link to post
Share on other sites

Updated/Fixed

Thank you D:

Hopefully it will now work with all Binocular-like weapons....

Edited by aeroson

Share this post


Link to post
Share on other sites

Thank you, removed micro sleeps and added waitUntils for magazines, to make sure that weapon's are added loaded under any circumstances.

Also released it on github (just for the sake of doing it D:)

Edited by aeroson

Share this post


Link to post
Share on other sites
_m = (getArray(configFile>>"CfgWeapons">>_w>>"magazines") select 0);

_t addMagazine _m;

this is the biggest genius move in your awesome script aero

we should definitely let BIS know about the magazine bug associated with removeweapon/removeallweapons.

it seems that the loaded magazine is almost allocated to the assigneditems, as it appears on the right with the silencers etc.

the bug arises because using standard means:

when you count magazines player it doesn't list it.

when you count assignedweaponitems it doesn't list it

the implication is that we need to either:

a) fix magazines player to count loaded magazines (preferred) or

b) fix assignedweaponitems to count loaded mags

I've gone through my mission and every instance of removeweapon has been modified with your load extra magazine fix! (R3F logistics/ spy class code i wrote)

the grenade muzzle bug remains a mystery - will run your new script today and over the weekend and feed back

does anyone know if this has been ticketed at BIS as a bug? I don't like to try because the admins at the bug-logging place are a bit too feisty for us (they must be inundated!).

cheers

egg

Share this post


Link to post
Share on other sites

Great solutions, thanks!

I would add a private statement on top of your scripts since you are using very general variable names and you are encouraging people to preproccess+call your script. So this can lead to inconsistencies later on...

Share this post


Link to post
Share on other sites

@eggbeast About the currently loaded magazine, i was unable to find out anything about it :( But i think it might be somehow possible.

@zapat Thank you, updated it.

Share this post


Link to post
Share on other sites

Work completely flawless up until I went to put in Revive, now only objectives and revive work....possibly chance of bit of help?

This is what i have in Ini.sqf currently:

// Compile scripts

Objectives_ini = compile preprocessFileLineNumbers "Objectives\Init.sqf";

call compile preprocessFile "=BTC=_revive\=BTC=_revive_init.sqf";

["obj_", 35, 2] call Objectives_ini;

};

waitUntil { !isNull player }; // Wait for player to initialize

getLoadout = compile preprocessFileLineNumbers 'fnc_get_loadout.sqf';

setLoadout = compile preprocessFileLineNumbers 'fnc_set_loadout.sqf';

// Lets wait 10 seconds, hopefully all crates will spawn by then

sleep 10;

// Save default loadout

loadout = [player] call getLoadout;

// Add save/load loadout actions to all ammo boxes

{

_x addAction ["Save loadout", "fnc_get_loadout.sqf"];

_x addAction ["Load loadout", "fnc_set_loadout.sqf"];

} forEach nearestObjects [getpos player,["ReammoBox","ReammoBox_F"],15000];

// Load saved loadout on respawn

player addEventHandler ["Respawn", {

[player,loadout] call setLoadout;

}

];

Share this post


Link to post
Share on other sites

which revive are you using? how does it affect the respawning of units? that's the code you need to examine

you may need to add stuff into the revive code

Share this post


Link to post
Share on other sites

Using the =BTC= Alpha release, been working well since started using it, as far as the respawning of units, had no issues.

---------- Post added at 07:44 ---------- Previous post was at 07:42 ----------

Seeing a conflict here...looks like the BTC Revive Respawns you with your gear, well at least what you had when you die.

---------- Post added at 07:55 ---------- Previous post was at 07:44 ----------

Sorry to no be more specific trying to get into the whole mission creation, still learning. :bounce3:

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×