Jump to content
Sign in to follow this  
eagledude4

0 elements provided in addAction

Recommended Posts

action_tankstelle = player addaction [format["<t color=""#FFFF00"">" +"Refuel Vehicle (%1)", _value],"petrolrefuel.sqf","",1,false,true,"",'_Pump = nearestobjects [getpos player, ["Land_A_Fuelstation_Feed", "cl_police_fuel_point"], 5]; _Car = nearestObject [player, "LandVehicle"]; (Fuel _Car <= .9) and (vehicle player == player) and (player distance _Car <= 3) and (_Car distance _Pump <= 10)'];

Throws error "0 elements provided, 3 expected", and flags the spot between _Car and distance (the [#])

What am I missing exactly?

Share this post


Link to post
Share on other sites

It means _Car is possibly returning as "NULL" (or is it out of scope there? not sure) so it's looking for a position as in [1,2,3] - it's not getting that so it's saying it's missing the 3 elements in the array as expected.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

I use the same variable for other actions without getting the error, so I'm suspecting the issue lies with how _Car is interacting with _Pump. Any ideas on how to solve the issue?

Edited by eagledude4

Share this post


Link to post
Share on other sites

Have you tried hinting the array?

Also try: <= 0.9

Might not be the problem but it's ugly either way.

Share this post


Link to post
Share on other sites

Looked again - it's not _car - you are giving it _pump as an array of objects (or empty array if there are none) not an object - that is why it's confused?

_Pump = nearestobjects [getpos player, ["Land_A_Fuelstation_Feed", "cl_police_fuel_point"], 5];

that returns an array - you need to select an object from the array as the distance command can only use positions, locations or objects.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

I had a feeling that was probably the problem.

Is there any way to use nearestObjects in this situation?

Edited by eagledude4

Share this post


Link to post
Share on other sites

Thanks for the link, but I already know how to select from the array. I was just looking for a way to compare distances to multiple classnames.

action58 = player addaction [format["<t color=""#FFFF00"">" +"Refuel Vehicle (%1)", PetrolCost],"petrolrefuel.sqf","",1,true,true,"",'_Pumps = nearestobjects [getpos player, ["Land_A_Fuelstation_Feed", "cl_police_fuel_point"], 5]; _Pump1 = _Pumps select 0; _Pump2 = _Pumps select 1; _Car = nearestObject [player, "LandVehicle"]; (vehicle player == player) and (player distance _Car <= 3) and (_Car distance _Pump1 <= 5 or _Car distance _Pump2 <= 5)'];

is the working code.

Edited by eagledude4

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  

×