-
Second Lieutenant
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=&# 34;500Rnd_TwinVickers"
?secondary==2:gun="TwinM134";mag=" 4000Rnd_762x51_M134"
?secondary==3:gun="M197";mag="750R nd_M197_AH1"
?secondary==4:gun="GAU12";mag="300 Rnd_25mm_GAU12"
?secondary==5:gun="2A42";mag="230R nd_30mmHE_2A42"
?secondary==6:gun="FFARLauncher";mag=& #34;14Rnd_FFAR"
?secondary==7:gun="FFARLauncher";mag=& #34;38Rnd_FFAR"
?secondary==8:gun="57mmLauncher";mag=& #34;96Rnd_57mm"
?secondary==9:gun="80mmLauncher";mag=& #34;40Rnd_80mm"
?secondary==10:gun="HellfireLauncher"; mag="8Rnd_Hellfire"
?secondary==11:gun="VikhrLauncher";mag ="12Rnd_Vikhr_KA50"[/QUOTE]
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?
-
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
[/QUOTE]
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"
};
[/QUOTE]
My 2 cents,
VictorFarbau
-
Staff Sergeant
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_T winVickers";};
case 2:{gun="TwinM134";mag="4000Rnd_762 x51_M134"};
case 3:{gun="M197";mag="750Rnd_M197_AH1 "};
case 4:{gun="GAU12";mag="300Rnd_25mm_GA U12"};
case 5:{gun="2A42";mag="230Rnd_30mmHE_2 A42"};
case 6:{gun="FFARLauncher";mag="14Rnd_F FAR"};
case 7:{gun="FFARLauncher";mag="38Rnd_F FAR"};
case 8:{gun="57mmLauncher";mag="96Rnd_5 7mm"};
case 9:{gun="80mmLauncher";mag="40Rnd_8 0mm"};
case 10:{gun="HellfireLauncher";mag="8R nd_Hellfire"};
case 11:{gun="VikhrLauncher";mag="12Rnd _Vikhr_KA50"};
//default{...}
};
[/QUOTE]
regards,
6*9=42
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules