Jump to content
Sign in to follow this  
zorilya

got a 0elemnts 3 expected error and i dunno why.

Recommended Posts

This is my line used in the on acc line of a trigger. it's a supply truck deplyment script

Detect = (Detect + 1); \\ counter for the number of times trigger is activated

Busted = thislist select 0; \\ gets name of detected unit

BustedLoc = getpos Busted; hint (str(Busted)); \\ returns [x,y,z] of detected unit and displays it (for my debugging)

NVillage1 = nearestlocation [bustedLoc,"nameVillage"]; \\ gets closest village name to detected unit

NVillage = getpos NVillage1; \\ gets that villages position

NBuilding = nearestBuilding BustedLoc ; \\ gets closest building to detected unit

DepLoc = (NBuilding distance NVillage); \\ gets ditance between the building and the village

if (DepLoc > 150) then {Deployment = NBuilding} else {Deployment = NVillage1} ;

\\ checks if distance is over 150 meters and sets the Deployment to either the building or village repectively.

I get the error in the "NVillage1 = #nearestlocation [bustedLoc,"nameVillage"];" with a 0 element 3 expected.

this script worked fine when i defined the BustedLoc variable as the position of player or any other named unit and i don't see how taking a unit from the trigger list as any different to that. it's still an object /unit that i then get the position from to feed the nearest location check.

please if someone could shed some light on this i would be grateful as it just seems after many hours of trying different ways to define variables and circumvent this issue, nothing come close to this method, for which i see no problem.

thanks

zorilya

Share this post


Link to post
Share on other sites

I think the problem is thislist, I don't think it will be passed on it's own it may need passing in the [] brackets

null=[thislist select 0] execvm "whatever.sqf";

and in the script use

Busted = _this select 0;

Share this post


Link to post
Share on other sites

Thanks for the reply but i'm trying not to use any needless scripts could you explain how i could do this in my, on acc ,a seperate trigger or init box. I'm also a little confuzed by the modification to the Busted variable... could you explain what this would do please?

Edited by zorilya

Share this post


Link to post
Share on other sites

I missed the on act part of your post.

In that case there's nothing wrong, I tried it and get no errors after removing all the // text

Are you spawning the script by any chance as that would also give the error you describe and again you would have to pass thislist within the [] brackets.

nul=[thislsit select 0] spawn {Busted = _this select 0; rest of code };

Other than that I don't really know why your getting the error.

Share this post


Link to post
Share on other sites

I'm not spawning the code, just out of interest what map are you trying this code on? i'm on lingor and i suspect that the details pertaining to locations are perhaps a little more vague than the stock maps (due to the lack of light markers and such). my code seems to work once in a blue moon and with no changes on the subjects of it's execution. I have read in places that the 0 elements 3 expected is somewhat sporadic but i refuse to believe something systematic in nature, programmed by humans, is too complex for someone to get an understand as to why this happens.

in the mean time if you could try this on lingor and see if you get a similar problem i'd be grateful.

thanks again

zorilya

Edited by zorilya

Share this post


Link to post
Share on other sites

I tested on Utes, I did download lingor as it looks impressive.

I tested again and it still seems to work ok. I tried several locations and still can't replicate the problem. Here's the exact script copied from a trigger.

Detect = (Detect + 1); 
Busted = thislist select 0; 
BustedLoc = getpos Busted; hint (str(Busted)); 
NVillage1 = nearestlocation [bustedLoc,"nameVillage"]; 
NVillage = getpos NVillage1; 
NBuilding = nearestBuilding BustedLoc ; 
DepLoc = (NBuilding distance NVillage); 

if (DepLoc > 150) then {Deployment = NBuilding} else {Deployment = NVillage1} ; 

If I add player setpos getpos nvillage1 it just moves me to a building in the nearest town so it does work.

As far as I know thislist just contains an array of units names nothing more so select 0,select 1 ect is all that's needed.

Update.

How are you using the trigger, if it's set to true or none present that will cause the error as thislist is empty.

Maybe rather than using thislist try naming the trigger ie Trig1 and in the code use

Busted = Trig1;

This way it will always have a location.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thankyou so much man... i actually notice halfway though my last hour of testing that i've had the condition set to true so i changed it to this and it seems consistant with your description. one last little question.

I've been trying to get it so that when it is repeatedly triggered it sets the Detect counter +1 each time, allowing me to set different event's into action upon these triggers. however it doesn't seem to want to trigger repeatedly. one Blufor group engages, is deteced and upon Detect == 1 the first truck is dispatched. the next truck is set to dispatch upon Detect == 2 but i can't get the trigger to trigger more than once even with the repeatedly funtion selected. any ideas?

Share this post


Link to post
Share on other sites

Could you post the script that dispatches the trucks? Might be an issue in the way you do that?

Share this post


Link to post
Share on other sites

The script uses the previous variables from the trigger to determine where to go and the trucks move where their corresponding troops have a waypoint.... so it's the troops that i have on a "get in nearest" waypoint and that waypoint condition is set to "Detect == 1" or "Detect == 2" depending on if it is Truck1 or Truck2.

troops get in and are set to "domove Deployment" as per the previous script.

there will be a few more details to add later but i just wanna make sure they can deploy to different areas, as and when they take contacts.

Share this post


Link to post
Share on other sites

The thing have to remember with triggers is that repeated dose not mean they'll always repeat.

It will only repeat if the condition has changed, if one BLUFOR enters the trigger it fires and it will not fire again even if a second unit enters.

It will fire again once the first unit leaves the trigger and another enters. The condition was true became false and is now true again.

If the trigger isn't firing a second time then you have units in the trigger preventing it from firing.

You will need to force the condition to change this and round (time %1) == 1 this will fire every second even if the condition doesn't change.

There are other ways to force the change that may be more suitable but not knowing the full story it's hard to say.

Share this post


Link to post
Share on other sites

could you explain a suiable way to reset my trigger after a certain amount of time?

Share this post


Link to post
Share on other sites

You could can add a variable to the condition but it will need defining first in an init file or game logic.

time_var = true

Cond

this and time_var

On act

time_var = false

Now when you want to check the trigger again you need to set time_var to true.

You could do this by placing it in a waypoint and when some object gets there it sets var_time = true or

iyou add the following to the triggers on act it will force it after xx amount of time

time_var = false; {null=[] spawn {sleep 10;time_var = true};

Share this post


Link to post
Share on other sites

i copy and pasted this code exactly and got an error. a generic error :(

Share this post


Link to post
Share on other sites

typo try time_var = false; null=[] spawn {sleep 10;time_var = true};

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  

×