Jump to content
Twiznak

[Help] cfgVehicles eventhandler, error Identifying variable.

Recommended Posts

Hello everyone! I am here asking for help with an error I am getting from an eventhandler contained within a custom soldier class config.cpp file. This custom class is the project to make giant and miniature soldiers using setObjectScale. The error comes from a misidentification of a variable. Here is my config.cpp file. I used Drungo's config generator.

config.cpp

Spoiler

class cfgPatches
{
  class TWZ_Pym_Warriors
  {
    units[]={"TWZ_Twz_Pym_Little_F","TWZ_Twz_Pym_Big_F"};
    weapons[]={"TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr","TWZ_hgun_P07_snds_F_muzzle_snds_L"};
    requiredVersion=0.1;
    requiredAddons[]={"A3_Weapons_F_Items","A3_Weapons_F","A3_Weapons_F_Rifles_MX","A3_Weapons_F_Pistols_P07","A3_Characters_F","CuratorOnly_Characters_F_BLUFOR"};
  };
};

class cfgFactionClasses
{
  class TWZ_Pym_Warriors
  {
    icon="";
    displayName="Pym Warriors";
    side=1;
	scope=2;
    priority=1;
  };
};


class cfgWeapons
{
  class arifle_MX_RCO_pointer_snds_F;
  class hgun_P07_snds_F;

  class TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr: arifle_MX_RCO_pointer_snds_F
  {
    displayName="MX 6.5 mm";
    scope=1;
    class LinkedItems
    {
      class LinkedItemsMuzzle
      {
        slot="MuzzleSlot";
        item="muzzle_snds_H";
      };
      class LinkedItemsOptic
      {
        slot="CowsSlot";
        item="optic_Hamr";
      };
      class LinkedItemsAcc
      {
        slot="PointerSlot";
        item="acc_pointer_IR";
      };
    };
  };

  class TWZ_hgun_P07_snds_F_muzzle_snds_L: hgun_P07_snds_F
  {
    displayName="P07 9 mm";
    scope=1;
    class LinkedItems
    {
      class LinkedItemsMuzzle
      {
        slot="MuzzleSlot";
        item="muzzle_snds_L";
      };
    };
  };

};

class cfgVehicles
{
  class B_recon_TL_F;

  class TWZ_Twz_Pym_Little_F: B_recon_TL_F
  {
    faction="TWZ_Pym_Warriors";
    side=1;
	scope=2;
    displayName="Twz Pym Little F";
    uniformClass="U_B_CombatUniform_mcam_vest";
    weapons[]={"Rangefinder","TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr","TWZ_hgun_P07_snds_F_muzzle_snds_L","Put","Throw"};
    respawnWeapons[]={"Rangefinder","TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr","TWZ_hgun_P07_snds_F_muzzle_snds_L","Put","Throw"};
    items[]={"FirstAidKit"};
    respawnItems[]={"FirstAidKit"};
    magazines[]={"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","Chemlight_green","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag_Tracer","30Rnd_65x39_caseless_mag_Tracer","16Rnd_9x21_Mag","MiniGrenade","MiniGrenade","SmokeShell","SmokeShellGreen","SmokeShellBlue","SmokeShellOrange","Chemlight_green"};
    respawnMagazines[]={"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","Chemlight_green","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag_Tracer","30Rnd_65x39_caseless_mag_Tracer","16Rnd_9x21_Mag","MiniGrenade","MiniGrenade","SmokeShell","SmokeShellGreen","SmokeShellBlue","SmokeShellOrange","Chemlight_green"};
    linkedItems[]={"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","NVGoggles","Rangefinder","H_MilCap_mcamo","V_Chestrig_rgr","G_Shades_Black","NVGoggles"};
    respawnLinkedItems[]={"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","NVGoggles","Rangefinder","H_MilCap_mcamo","V_Chestrig_rgr","G_Shades_Black","NVGoggles"};
    backpack="";
	class EventHandlers
	{
	class TWZ_Pym_Warriors
		{
			init="_this spawn { while {true} do { [(_this select 0 select 0)] setObjectScale .35; }; };";
		};
	};
  };

  class TWZ_Twz_Pym_Big_F: B_recon_TL_F
  {
    faction="TWZ_Pym_Warriors";
    side=1;
	scope=2;
    displayName="Twz Pym Big F";
    uniformClass="U_B_CombatUniform_mcam_vest";
    weapons[]={"Rangefinder","TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr","TWZ_hgun_P07_snds_F_muzzle_snds_L","Put","Throw"};
    respawnWeapons[]={"Rangefinder","TWZ_arifle_MX_RCO_pointer_snds_F_muzzle_snds_Hacc_pointer_IRoptic_Hamr","TWZ_hgun_P07_snds_F_muzzle_snds_L","Put","Throw"};
    items[]={"FirstAidKit"};
    respawnItems[]={"FirstAidKit"};
    magazines[]={"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","Chemlight_green","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag_Tracer","30Rnd_65x39_caseless_mag_Tracer","16Rnd_9x21_Mag","MiniGrenade","MiniGrenade","SmokeShell","SmokeShellGreen","SmokeShellBlue","SmokeShellOrange","Chemlight_green"};
    respawnMagazines[]={"30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag","Chemlight_green","30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_mag_Tracer","30Rnd_65x39_caseless_mag_Tracer","16Rnd_9x21_Mag","MiniGrenade","MiniGrenade","SmokeShell","SmokeShellGreen","SmokeShellBlue","SmokeShellOrange","Chemlight_green"};
    linkedItems[]={"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","NVGoggles","Rangefinder","H_MilCap_mcamo","V_Chestrig_rgr","G_Shades_Black","NVGoggles"};
    respawnLinkedItems[]={"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","NVGoggles","Rangefinder","H_MilCap_mcamo","V_Chestrig_rgr","G_Shades_Black","NVGoggles"};
    backpack="";
	class EventHandlers
	{
		class TWZ_Pym_Warriors
		{
			init="_this spawn { while {true} do { [(_this select 0 select 0)] setObjectScale .35; }; };";
		};
	};
  };

};

I have scripted myself into a corner here. in the following code


class TWZ_Pym_Warriors
		{
			init="_this spawn { while {true} do { [(_this select 0 select 0)] setObjectScale .35; }; };";
		};

 

 [(_this select 0)] returns an error: type array, expected object... .Please correct me here. I figured that the first variable in the TWZ_Pym_Warriors would be "units[]={"TWZ_Twz_Pym_Little_F","TWZ_Twz_Pym_Big_F"};"

and when I flex the little knowledge I have of passing variable from scope to scope I add another "select 0" to identify the first variable, of the first variable in units. However, this returns the error: type object, expected array..... *facePalm*.

 

I am obviously way off here. Would you please explain/show me how to Identify the variable of the body of the unit which I am attempting to execute the code upon.

Share this post


Link to post
Share on other sites

mmmm I'm seeing that you're calling _this select 0. You're calling the first parameter of the class I guess, but I don't understand why the select 0 again. Is it because you want to call the array index of unit [] ?

Share this post


Link to post
Share on other sites
32 minutes ago, Kenziy sam said:

mmmm I'm seeing that you're calling _this select 0. You're calling the first parameter of the class I guess, but I don't understand why the select 0 again. Is it because you want to call the array index of unit [] ?

Hi. Yes, that is correct and that's the problem. either way it returns an error. _this select 0 returns error: type array expected object & _this select 0 select 0 returns error: type object expected array! I'm not doing this right.

Share this post


Link to post
Share on other sites

Try using the find command.
https://community.bistudio.com/wiki/find

PD:

The truth is I don't know about the manipulation of the Config but I did something and I do not know if I have logic to obtain the object of the index 0 since from what I read about the CfgPatches in the array of units[], what is designated are the objects that have already been created in the CfgVehicles.


(configFile >> "cfgvehicles" >> "TWZ_Twz_Pym_Little_F" ) select 0 
 

Share this post


Link to post
Share on other sites

It's an array because you're writing an array.😋

You can't setObjectScale a string (class) but, as the command indicates, ... an object!

Did you try:

init="_this spawn { while {true} do {uiSleep 0.3; _this setObjectScale .35}};";

  • Thanks 1

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

×