Jump to content

Kubas94CZ

Undefined number of variable names

Recommended Posts

Hello,

I'm making rally point script (based of many diferent scripts), but I have problem with number of squad leaders (number of variable names).

 

  Reveal hidden contents

 

I have problem with variables SQA ... SQB ... SQC, these variables are variable names of each squad leader. But I never know how many squad leaders I will need (it depends on number of players and so on) so let's say that I have 3 squad leaders (SQA, SQB, SQC) but when they use this script via addAction it will show error message:

"undefined variable sqd in line if ((_unit == SQD) && (r2Cooldown == 1)) exitWith {"

 

So unless I have all squad leader this error will show up on each use. Script works, but these error messages are annoying. Is there way to solve this? I know there is way by dividing script for each squad leader, but I don't think it is THE WAY. Or is it possible to use variable name in each line such as:

  Reveal hidden contents

 

Thanks for any answers,

Kuba

Share this post


Link to post
Share on other sites

Before proceeding into its code, you should do some verification on _unit to ensure 1) it's not null, like when AI are disabled or get deleted in a cleanup, and 2) it's still alive, not dead.

if (!isNull SQA && {Alive SQA}) then {
	if ((_unit == SQA) && (r1Cooldown == 0)) then {

 

Share this post


Link to post
Share on other sites
  On 4/11/2020 at 4:54 PM, opusfmspol said:

you should do some verification on _unit to ensure 1) it's not null,

make sure it is not nil first

if ( !isNil "SQA" && { _unit == SQA && r1Cooldown == 0 } ) then {

 

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

×