Jump to content
Sign in to follow this  
slendermang

Error 0 elements provided, 3 expected

Recommended Posts

Hi guys, I'm trying to delete all objects within the radius of another object (or marker, how would I do this?) but everytime the trigger is activated it returns 

14:53:31 Error in expression <{deleteVehicle _x} forEach nearestObjects ["clean", [], 800]>
14:53:31 Error position: <nearestObjects ["clean", [], 800]>
14:53:31 Error 0 elements provided, 3 expected

 

Now when it says 3 expected its not doubt referencing the array, what exactly is wrong with it? It's setup as nearestObjects describes on the wiki.

Share this post


Link to post
Share on other sites

Hi, sorry about that. I checked out what you said, I was referring to the position of the object I spawned with quotation marks rather than simply its variable name and that seems to have fixed the problem that it was outputting. After trying to fix it for 2 hours it always seems I discover the stupid things when I go to ask  :lol:

Share this post


Link to post
Share on other sites

It's always the way man. I used to find all sorts of shit wrong with my scripts and mods 5 minutes after I uploaded them to Armaholic for everyone to try back in the day.

 

Re: your issue about markers, you could have a few lines of code before the object check to check whether it's an object or marker.  So you could do something like this:

 

_name = "clean";
_myPos = [];


// Let's pretend that _name is a marker to begin with

if (_name in allMapMarkers) then {
    _myPos = markerPos _name
} else {
    // assume it is instead an object

    _myPos = getPos (missionNamespace getVariable [_name,[]]);
};


if (_myPos isEqualTo []) then {
    // exception code here
} else {
    {deleteVehicle _x} forEach nearestObjects [_myPos, [], 800]
};

I haven't tested this but it should/might work.  There's probably other ways to check (using typeName or it's replacement isEqualType... family for example but that's all I can muster up at the moment).

  • Like 1

Share this post


Link to post
Share on other sites

Sorry, that was crap.  This should accept string or objects as valid inputs.  Other data types shouldn't break it though:

 

fnc_thing = {
    params ["_name"];
    _myPos = [];

    // check to see if input is an object

    if (_name isEqualType objNull) then {
        _myPos = getPos _name
    } else {
        if (_name isEqualType "") then {
            // Let's pretend that _name is a marker to begin with
            if (_name in allMapMarkers) then {
                _myPos = markerPos _name
            } else {
                // assume it is now object name saved as string
                _myPos = getPos (missionNamespace getVariable [_name,[]]);
            };
        };
    };


    if (_myPos isEqualTo []) then {
        // exception code here
    } else {
        // jackpot
        {deleteVehicle _x} forEach nearestObjects [_myPos, [], 800]
    };
};

And you would do:

 

[_variable] call fnc_thing

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  

×