Jump to content
Sign in to follow this  
BadHabitz

Config code for executing a script

Recommended Posts

I'm trying to determine where certain items are going in specific units. I figured a script would be the best way of filling vests, since backpacks are easy, but adding items and magazines by default fills your uniform before it starts putting items into the vest.

Seeing the code from a loadout exported from the Virtual Arsenal, I had the idea of accomplishing my goal by using a script. My problem is I don't understand the whole Eventhandler setup, and I'm unsure how the unit should call the script so it can do what I want. I've also thought about handling the entire loadout using a script for each soldier, but they have to be soldiers in a faction that can be added through the mission editor... not adding code to the Init box of a soldier.

If anyone knows a better way to specifically load a vest, please share. Ultimately, I think I just need to know the proper code for the 'init=' in Eventhandlers to get it to work.

Note: I do have a proper unit filled out, but removed unneeded code for the example below to keep it clean.

config.cpp

class CfgVehicles {
   class B_Soldier_base_F;
   class B_Soldier_F: B_Soldier_base_F {
       class Eventhandlers;
   };
class Base_Soldier: B_Soldier_F {
	_generalMacro = "B_Soldier_f";
	scope = 2;
	side = 1;
	author = "BadHabitz";
	displayName = "Base Soldier";

	class EventHandlers: EventHandlers {
		init = "(_this select 0) execVM ""\Mod\soldiers\base_vest_items.sqf""";
	};
};

'base_vest_items.sqf'

this addItemToVest "random_magazine";

Edited by BadHabitz

Share this post


Link to post
Share on other sites

this addItemToVest "random_magazine";

Before "addItemToVest" you need "_this", not "this".

In .sqf files you pretty much always use "_this", the only place "this" is used (in general) is in 2D editor fields (like the "init" field for players) and .sqm files.

By the way, love PG Services, thanks for all the work you've put into it!

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
Sign in to follow this  

×