Jump to content
Sign in to follow this  
PELHAM

Script error:No matching signature for <array> operator <code>

Recommended Posts

Need help with this random smoke generator / detector script:

I get the error:

No matching signature for <array> operator <code> from Squint

Which means I am passing it the wrong argument? I have tried several but can't find the right one?

It works up until the if (blah blah) then sequence.

// nul = [] execVM "scripts\randsmoke.sqf";

private ["_smokes","_type","_dest"];
_smokes = ["SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];
_type = _smokes select floor(random count _smokes);
_dest = _type createVehicle getMarkerPos "p1";

if (_type = SmokeShellYellow) then {hint "yellow";};
else {
if (_type = SmokeShellRed) then {hint "red";};
else {
if (_type = SmokeShellGreen) then {hint "green";};
else {
if (_type = SmokeShellPurple) then {hint "purple";};
else {
if (_type = SmokeShellBlue) then {hint "blue";};
else {
if (_type = SmokeShellOrange) then {hint "orange";};

sleep 1;
trgSmoke setPos (getMarkerPos "p1hold");

Edited by PELHAM

Share this post


Link to post
Share on other sites

private ["_smokes","_type","_dest"];
_smokes = ["SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];
_type = _smokes select floor(random count _smokes);
_dest = _type createVehicle getMarkerPos "p1";

if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellYellow[color="Green"]"[/color]) then {hint "yellow";};
[color="Red"]else {[/color]
if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellRed[color="Green"]"[/color]) then {hint "red";};
[color="Red"]else {[/color]
if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellGreen[color="Green"]"[/color]) then {hint "green";};
[color="Red"]else {[/color]
if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellPurple[color="Green"]"[/color]) then {hint "purple";};
[color="Red"]else {[/color]
if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellBlue[color="Green"]"[/color]) then {hint "blue";};
[color="Red"]else {[/color]
if (_type =[color="Green"]=[/color] [color="Green"]"[/color]SmokeShellOrange[color="Green"]"[/color]) then {hint "orange";};

sleep 1;
trgSmoke setPos (getMarkerPos "p1hold");

Remove red; add green.

Share this post


Link to post
Share on other sites

Agree with pvpscene that it would be better to use switch here. Muzzleflash is also correct that you could just turn it into a sequence of independent tests. The original error was that you had semicolons before the 'else' operators. If you remove these, things will work better but you'll then need a bunch of closing brackets at the end of the script.

Share this post


Link to post
Share on other sites

Thank you all.

I am going to have fun converting it to a switch.

P.S. Squint is a real help sbsmac - I use it all the time!

---------- Post added at 23:14 ---------- Previous post was at 21:40 ----------

Here is the full script if anyone wants to use it:

-random smoke generator

-radio calls with colour of random smoke

-returns player vehicle as well

You need:

-a trigger to start the script at the LZ

-a marker for the LZ

-a marker to move the trigger so it does not fire twice (last 2 lines).

These can be setPos around to have the effect repeat at different LZs.

// nul = [] execVM "scripts\randsmoke.sqf";

private ["_smokes","_type","_dest"];

player commandChat format ["LZ, pop smoke, over."];

_smokes = ["SmokeShellYellow","SmokeShellRed","SmokeShellGreen","SmokeShellPurple","SmokeShellBlue","SmokeShellOrange"];

_type = _smokes select floor(random count _smokes);

_dest = _type createVehicle getMarkerPos "p1";

switch (_type) do

{

case "SmokeShellYellow": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, yellow smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, yellow smoke, LZ in sight, over."];

};

case "SmokeShellRed": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, red smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, red smoke, LZ in sight, over."];

};

case "SmokeShellGreen": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, green smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, green smoke, LZ in sight, over."];

};

case "SmokeShellPurple": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, purple smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, purple smoke, LZ in sight, over."];

};

case "SmokeShellBlue": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, blue smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, blue smoke, LZ in sight, over."];

};

case "SmokeShellOrange": {

sleep 2;

Utes_Control globalChat format ["%1 Roger, orange smoke, cleared to land, over.", typeof vehicle player];

sleep 2;

player commandChat format ["Roger, orange smoke, LZ in sight, over."];

};

};

sleep 1;

trgSmoke setPos (getMarkerPos "p1hold");

Edited by PELHAM
code error

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  

×