OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: erebus1 on 23 Jul 2008, 17:12:10

Title: IED sqf syntax error
Post by: erebus1 on 23 Jul 2008, 17:12:10
Hey all, Im trying to learn sqf coming from sqs.. I have an IED script that worked with sqs but when I ported it over it's telling me I'm missing a closing }.

Am I missing something here?

Code: [Select]
// ied.sqf
// syntax as follows
// [this,distance from player before expload,damage needed to expload] exec "ied.sqf"
// [this,15,0.2] exec "ied.sqf"

_veh = _this select 0;
_distance = _this select 1;
_damage = _this select 2;

if ((getdammage _veh >= _damage) || (side player == west)&&(player distance _veh < _distance)) then
{
_ied = "Sh_120_SABOT" createvehicle getpos _veh;
};
Title: Re: IED sqf syntax error
Post by: Spooner on 23 Jul 2008, 18:17:53
Yes, you are missing something. That file compiles and runs with no errors for me ;P

The problem is how you are running it. ArmA doesn't care about file extensions; it is the command you use to run it that determines whether the SQS or SQF interpreter is used.

Code: (compile and run SQF in new script instance) [Select]
[this,15,0.2] execVM "ied.sqf"

Code: (precompile SQF and run, waiting for the script to finish, returning a value) [Select]
ied = compile preprocessFileLineNumbers "ied.sqf";
_result = [this,15,0.2] call ied;

Code: (precompile SQF and run in new script instance) [Select]
ied = compile preprocessFileLineNumbers "ied.sqf";
[this,15,0.2] spawn ied;
Title: Re: IED sqf syntax error
Post by: erebus1 on 23 Jul 2008, 20:56:31
with [this,15,0.2] execVM "ied.sqf"

i get error, Type Script, Expected Nothing.
Title: Re: IED sqf syntax error
Post by: Mandoble on 23 Jul 2008, 20:58:13
Try with
Code: [Select]
res = [this,15,0.2] execVM "ied.sqf"
Title: Re: IED sqf syntax error
Post by: erebus1 on 23 Jul 2008, 21:04:47
thanks fellas, that got rid of the error mandoble, only problem is its not looping, so I have to put it inside a while do?

in my other one I used loop, but that doesnt work in sqf
Title: Re: IED sqf syntax error
Post by: MachoMan on 23 Jul 2008, 22:14:02
Why loop? :no: Just use a trigger!
Title: Re: IED sqf syntax error
Post by: Cheetah on 23 Jul 2008, 22:23:35
Alternatively, use the waitUntil (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=w#812) command.
Title: Re: IED sqf syntax error
Post by: Mandoble on 23 Jul 2008, 22:51:14
You are using ""this"" as argument, so I did assume you were already executing that from the init field of a unit, from a trigger or from a waypoint.