Jump to content
Sign in to follow this  
celery

Why doesn't a simple poll work?

Recommended Posts

I made a very simple vehicle and weapon selection script in the init file of my mission. It goes like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">primary=(floor Param2)

?primary==1:helitype="AH6"

?primary==2:helitype="UH60"

?primary==3:helitype="AH1W"

?primary==4:helitype="Mi17"

?primary==5:helitype="KA50"

secondary=(Param2-primary)*100

?secondary==0:gun="default"

?secondary==1:gun="TwinVickers";mag="500Rnd_TwinVickers"

?secondary==2:gun="TwinM134";mag="4000Rnd_762x51_M134"

?secondary==3:gun="M197";mag="750Rnd_M197_AH1"

?secondary==4:gun="GAU12";mag="300Rnd_25mm_GAU12"

?secondary==5:gun="2A42";mag="230Rnd_30mmHE_2A42"

?secondary==6:gun="FFARLauncher";mag="14Rnd_FFAR"

?secondary==7:gun="FFARLauncher";mag="38Rnd_FFAR"

?secondary==8:gun="57mmLauncher";mag="96Rnd_57mm"

?secondary==9:gun="80mmLauncher";mag="40Rnd_80mm"

?secondary==10:gun="HellfireLauncher";mag="8Rnd_Hellfire"

?secondary==11:gun="VikhrLauncher";mag="12Rnd_Vikhr_KA50"

The vehicle part is fine and the variable is changed, but the weapon part gives blank variables, even though a hint format box returns a completely viable secondary value. Can anyone tell me what the problem is?

Share this post


Link to post
Share on other sites

I had the same issues a long time ago in OFP already. That's why used a more complex script in OFP and now SQF in ArmA (calling the SQF from the init.sqs).

In my mind this is related to the multiple statements per line that you use. The code parser failed on me each time I tried that construct and I think it has to do with the line breaks used by different text editors. Anyway, this is speculation; but what I know worked is either this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?secondary==0:goto "default"

?secondary==1: goto "vickers"

#default

exit

#vickers

gun="TwinVickers"

mag="500Rnd_TwinVickers"

exit

But SQF constructs with their clear delimiters work a lot more reliable in general:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

IF (secondary==1) THEN

{

       gun="TwinVickers";

       mag="500Rnd_TwinVickers"

};

My 2 cents,

VictorFarbau

Share this post


Link to post
Share on other sites

hi celery,

why you guys all use the deprecated sqs scripting?

did you try out init.sqf, and just switch your values?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

primary=floor(Param2);

helitype=switch (primary) do {

case 0:{"AH6"};

case 1:{"UH60"};

case 2:{"AH1W"};

case 3:{"Mi17"};

case 4:{"KA50"};

//default{...}

};

secondary=(Param2-primary)*100;

switch (secondary) do {

case 0:{gun="default";};

case 1:{gun="TwinVickers";mag="500Rnd_TwinVickers";};

case 2:{gun="TwinM134";mag="4000Rnd_762x51_M134"};

case 3:{gun="M197";mag="750Rnd_M197_AH1"};

case 4:{gun="GAU12";mag="300Rnd_25mm_GAU12"};

case 5:{gun="2A42";mag="230Rnd_30mmHE_2A42"};

case 6:{gun="FFARLauncher";mag="14Rnd_FFAR"};

case 7:{gun="FFARLauncher";mag="38Rnd_FFAR"};

case 8:{gun="57mmLauncher";mag="96Rnd_57mm"};

case 9:{gun="80mmLauncher";mag="40Rnd_80mm"};

case 10:{gun="HellfireLauncher";mag="8Rnd_Hellfire"};

case 11:{gun="VikhrLauncher";mag="12Rnd_Vikhr_KA50"};

//default{...}

};

regards,

6*9=42

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  

×