Jump to content
Sign in to follow this  
Hornet_it

Problem 'type array expected object'

Recommended Posts

Hi, i've a problem making a gearing script called in my init.sqf

nul0 = [] execVM "scripts\init\initGearing.sqf";

This is the script called by the above comand

EDITED with Tajin help

// Variables
_squadLeaders = [asl00, bsl00, csl00, plhq00, asl00_1];
_squadMeds = [smedic00, smedic01, smedic02, smedic03];
_teamLeaders = [alpha1, alpha2, alpha3, bravo1, bravo2, bravo3, charlie1, charlie2, charlie3];
_automaticRiflemen = [ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10];
_antiTank = [at1, at2, at3];
_riflemen = [r1, r2, r3, r4, r5, r6];
_aARs = [aar1, aar2, aar3, aar4, aar5, aar6, aar7, aar8, aar9, aar10];
_pilots = [p1, p2, p3, p4];
_crewmen = [cr1, cr2, cr3, cr4, cr5, cr6, cr7, cr8, cr9, cr10, cr11, cr12, cr13, cr14, cr15, cr16];

// Gearing
{ _x execVM "scripts\gearing\squad_leader.sqf"; } forEach _squadLeaders;
{ _x execVM "scripts\gearing\squad_medic.sqf"; } forEach _squadMeds;
{ _x execVM "scripts\gearing\team_leader.sqf"; } forEach _teamLeaders;
{ _x execVM "scripts\gearing\automatic_rifleman.sqf"; } forEach _automaticRiflemen;
{ _x execVM "scripts\gearing\anti_tank.sqf"; } forEach _antiTank;
{ _x execVM "scripts\gearing\rifleman.sqf"; } forEach _riflemen;
{ _x execVM "scripts\gearing\assistant_automatic_rifleman.sqf"; } forEach _aARs;
{ _x execVM "scripts\gearing\pilot.sqf"; } forEach _pilots;
{ _x execVM "scripts\gearing\crewman.sqf"; } forEach _crewmen;

Everything works fine, the only exception is for the squad medic gearing

// Debug problem array
hint format ["%1",[_this]];
// Remove weapons and magazines
removeAllWeapons _this;
//Main weapon
_this addWeapon "ACE_M4A1_C"; 
//Main weapon magazines
for "_i" from 0 to 6-1 do {_this addMagazine "30Rnd_556x45_Stanag"};
//Night vision googles
//_this addWeapon "NVGoggles"; 
//Grenade
for "_i" from 0 to 2-1 do {_this addMagazine "HandGrenade_West"}; 
//Smokes 
for "_i" from 0 to 4-1 do {_this addMagazine "SmokeShell"};
//Rangefinder and batteries  
_this addWeapon "Binocular_Vector"; 
_this addmagazine "ACE_Battery_Rangefinder";
_this addmagazine "ACE_Battery_Rangefinder";
//IFAK  
for "_i" from 0 to 2-1 do {_this addMagazine "ACE_Epinephrine"};  
for "_i" from 0 to 2-1 do {_this addMagazine "ACE_Morphine"};
//Medic gear
for "_i" from 0 to 2-1 do {_this addMagazine "ACE_Epinephrine"};  
for "_i" from 0 to 2-1 do {_this addMagazine "ACE_Morphine"};
for "_i" from 0 to 4-1 do {_this addMagazine "ACE_Bandage"}; 
//Rucksack
_this addWeapon "ACE_Rucksack_MOLLE_DMARPAT_Medic"; 
//Equip
_this addWeapon "ACE_Earplugs";
_this addWeapon "ACE_GlassesLHD_glasses";
_this addWeapon "ACE_GlassesTactical";
_this addWeapon "ACE_KeyCuffs";

Now, in line 4 arma finds an error '#removeAllWeapons _this; type array, expected object'

I don't understand why everything is fine with other scripts but not for this one. My debug (line 2) shows that the name called is not an array but is actually the name of the unit.

I know i could "move" everything to unit's init, I've also got problem by calling the script directly in unit's init. So, just to "study" a bit of scripting and arrays again, I tried this solution but now i've a problem I can't understan...

Can someone help me?

Edited by Hornet_it

Share this post


Link to post
Share on other sites

1. Your initGearing.sqf can be simplified massively. Try this:

// Variables
_squadLeaders = [asl00, bsl00, csl00, plhq00, asl00_1];
_squadMeds = [smedic00, smedic01, smedic02, smedic03];
_teamLeaders = [alpha1, alpha2, alpha3, bravo1, bravo2, bravo3, charlie1, charlie2, charlie3];
_automaticRiflemen = [ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10];
_antiTank = [at1, at2, at3];
_riflemen = [r1, r2, r3, r4, r5, r6];
_aARs = [aar1, aar2, aar3, aar4, aar5, aar6, aar7, aar8, aar9, aar10];
_pilots = [p1, p2, p3, p4];
_crewmen = [cr1, cr2, cr3, cr4, cr5, cr6, cr7, cr8, cr9, cr10, cr11, cr12, cr13, cr14, cr15, cr16];

// Gearing
{	_x execVM "scripts\gearing\squad_leader.sqf"; } forEach _squadLeaders;
{ _x execVM "scripts\gearing\squad_medic.sqf"; } forEach _squadMeds;
{ _x execVM "scripts\gearing\team_leader.sqf"; } forEach _teamLeaders;
{ _x execVM "scripts\gearing\automatic_rifleman.sqf"; } forEach _automaticRiflemen;
{ _x execVM "scripts\gearing\anti_tank.sqf"; } forEach _antiTank;
{ _x execVM "scripts\gearing\rifleman.sqf"; } forEach _riflemen;
{ _x execVM "scripts\gearing\assistant_automatic_rifleman.sqf"; } forEach _aARs;
{ _x execVM "scripts\gearing\pilot.sqf"; } forEach _pilots;
{ _x execVM "scripts\gearing\crewman.sqf"; } forEach _crewmen;

2. Try to remove everything but that line to make sure the error isnt elsewhere.

The command itself looks ok. I assume one of the varnames is mistyped or not set correctly.

ps.: You could also use LEA for this.

Share this post


Link to post
Share on other sites

Thanks for the tip, just trying right now.

I know LEA and everything ;) but, as you can understand, I want to try make it by myself :D

EDIT: just tried, same problem as above ('typed array expected object')... every variable seems to be ok as i've double checked them... Can't actually understand why it reads an array instead of a single variable as it actually do (debug hint in my script shows the correct variable).

EDIT2: Found the error, the code is ok, I forgot to erase some lines in my medics init :D

Edited by Hornet_it

Share this post


Link to post
Share on other sites

Ahahah that's one of my "bad script typing habit", I do that to remember that 0 is actually the first step, so when i call "2-1" i know i'm actually calling for "two" of them [0 and 1] but i read "2". A bit complex but it help me quick read every numerical call, expecially gear calls...

About the script, it's initialized in my init.sqf as i said. I can't call every unit script in unit's init beause i saw it's sometimes broken by the server on dedi or mission restart.

Share this post


Link to post
Share on other sites

You know that you're gonna have some problems on MP game in this way right? :)

By the way try to modify this one:

{ _nul = [_x] execVM "scripts\gearing\squad_medic.sqf"; } forEach _squadMeds;

and this:

// Debug problem array
_unit = _this select 0;
hint format ["%1",[_unit]];
// Remove weapons and magazines
removeAllWeapons _unit;

Share this post


Link to post
Share on other sites
You know that you're gonna have some problems on MP game in this way right? :)

What part are you talking about? If you mean calling the script in init.sqf is actually a "bad idea" I will completely remove the script because I will roll-back to unit's init manual gear change or, if you mean calling the script without naming it (null= [] execVM "") i've already change that part. At least I'm gonna find out if something's wrong with some tests later.

I've already solved the other problem 'typed array, expected object', there was no typing errors, only some codes forgotten in some unit's init.

Thanks for your help.

Edited by Hornet_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  

×