wozzsta 16 Posted March 2, 2016 Hey guys, sorry for all the help posts i am trying everything i can think of before posting one i promise :) Anyhow, i have this custom loadout.sqf and im calling it from the init box on my units with this. null = [this] execVM "loadout.sqf"; this addeventhandler ["respawn","_this execVM 'loadout.sqf'"]; and it only half works, in that only half the items in the loadout are actually loaded. here is the loadout.sqf maybe i have done something wrong because when i start the mission in the editor it gives me the "error undefined variable in expression, this". But haven't i defined it with the second line? waitUntil {!isNull player}; _unit = _this select 0; removeallassigneditems this; removeallcontainers this; removeuniform this; removevest this; removebackpack this; removeGoggles this; removeHeadgear this; removeAllWeapons this; _unit addVest "V_PlateCarrier3_rgr"; _unit addUniform "U_B_GhillieSuit"; _unit addBackPack "B_Carryall_ocamo"; _unit addHeadgear "H_ShemagOpen_tan" _unit additem 'ItemWatch'; _unit additem 'ItemMap'; _unit additem 'ItemCompass'; _unit additem 'ItemRadio'; _unit assignitem 'ItemMap'; _unit assignitem 'ItemWatch'; _unit assignitem 'ItemCompass'; _unit assignitem 'ItemRadio'; _unit addWeapon "MMG_02_sand_F"; _unit addPrimaryWeaponItem "muzzle_snds_338_sand"; _unit addPrimaryWeaponItem "optic_AMS_snd"; _unit addPrimaryWeaponItem "bipod_01_F_snd"; _unit addMagazines ["130Rnd_338_Mag", 2]; _unit addWeapon "launch_RPG32_F"; _unit addMagazines ["RPG32_F", 2]; _unit additem 'FirstAidKit'; _unit addmagazine 'HandGrenade'; _unit addmagazine 'HandGrenade'; if(true) exitWith{}; Share this post Link to post Share on other sites
Alex150201 894 Posted March 2, 2016 The part where you remove stuff, you need to change the "this" part to _unit. Share this post Link to post Share on other sites
wozzsta 16 Posted March 2, 2016 Thanks dude, also i didnt add a ; to the end of the 19th line which is why it was only half working lol ! Share this post Link to post Share on other sites
Alex150201 894 Posted March 3, 2016 Thanks dude, also i didnt add a ; to the end of the 19th line which is why it was only half working lol ! There you go! I didn't see that neither. I just had a bare look at the code didn't really check for semicolons. Share this post Link to post Share on other sites
TMZulu 3 Posted March 22, 2016 (edited) I seem to have a similar problem where I have a script that allows a player to create their own loadout but it seems that none of the primary magazines are spawning. Here is a snippet: removeAllWeapons player; removeAllItems player; removeAllAssignedItems player; if (isNil "primary") then{ }else{ if (primary == "mx")then{ player addWeapon "arifle_MX_F"; for "_i" from 1 to 5 do {player addItemToVest "30Rnd_66x39_caseless_mag";}; player addItemToVest "30Rnd_66x39_caseless_mag"; }else{ }; }; It was working initially but it seems to have stopped working when I integrated it into a dialog and added an infinite loop for telling if someone logs into admin. Again, It spawns the rifle, the handgun, the ammo for the handgun, and some extra items later on in the script but no rifle magazines. **Keep in mind this isn't just for the mx but for other rifles in the same script too** Anyone have any idea what is the problem? Edited March 22, 2016 by TMZulu Share this post Link to post Share on other sites
zeddy360 0 Posted March 22, 2016 for some reason i can't open a topic in this forum section and can't reply to all threads but i want to share something that took me some days to archieve and it's more or less related to this thread.please don't hit me :)i was looking for a simple save/load equipment script but only found either broken or not fully working scripts. i also tried to use the functionality of VAS but it turned out that VAS doesn't work correctly with some mods that i've got installed (it didn't load the waeapon attachments, weapon was from the bundeswehrmod, attachment was vanilla). finally i found BIS_fnc_exportInventory and decided to do it myself.i'm still new to SQF so this might be a bit ugly in some parts but it gets the job done and works in MP as well.i've put this into my init.sqf: saveEquipment = { _loadout = [player,'script',true] call BIS_fnc_exportInventory; profileNamespace setVariable ['respawnLoadout',_loadout]; saveProfileNamespace; }; loadEquipment = { _loadout = profileNamespace getVariable "respawnLoadout"; _codeArray = []; { _push = _x; if (_x select [4,24] == "// Remove existing items") then { _push = _x select [4+24]; }; if (_x select [4,17] == "// Add containers") then { _push = _x select [4+17]; }; if (_x select [4,14] == "// Add weapons") then { _push = _x select [4+14]; }; if (_x select [4,12] == "// Add items") then { _push = _x select [4+12]; }; if (_x select [4,15] == "// Set identity") then { _push = _x select [4+15]; }; _codeArray pushBack _push; } foreach (_loadout splitString ";"); _code = _codeArray joinString ";"; call compile _code; }; then i made a box and added actions to it: this addaction ["<t color='#EECC00'>Change Equipment</t>",{ ["Open",true] call BIS_fnc_arsenal; }]; this addaction ["<t color='#BEEEEF'>Save Gear for Respawn</t>",{ [] call saveEquipment; }]; finally i added a respawn event handler to the player (also in init.sqf): player addEventHandler ["Respawn", { [] call loadEquipment; }]; what it does: it generates a script that is similar to what is exported by the arsenal. this is then saved to a variable in the players profile. when he respawns it loads that script up and executes it which equips him again. the problems with this are: - "compile" doesn't preprocess the code and therefore i had to manually get rid of the comments in the script that gets returned by "BIS_fnc_exportInventory". if that functions gets changed some day so that more comments are in the returned script, it will break the loadEquipment function. - this executes code that comes from a profile that the player potentially can change manually afaik. so the player would be able to execute his own code on your server. for me this is no problem since i will play it with some friends only but one has to be aware of that risk if he want's to use this. maybe the equipment could be saved to a different namespace that can't be manually manipulated by editing files. but i'm still new to all this so i dunno how. Share this post Link to post Share on other sites