Jump to content

Sign in to follow this  
eymerich

[] exec "script.sqs"

Recommended Posts

To be honest I am very embarassed by this post.

But It's over 1 hour and I am get tired of this problem.

The question is: Does'nt Arma2 recognize anymore the following command line:

[parameter1, parameter2 and so on] exec "script.sqs" (or "/scripts/nameofscript.sqs")?

I did a mission.

A c130, sincronized with a trigger, fly toward the Trigger.

On trigger activation there is this line:

[player, c130] exec "/scripts/eject.sqs"

where:

c130 is the name of the airplane in the editor.

The script is not executed, although the trigger is properly activated :confused:

-- --

This is the code:

***

player sideChat "script activated"

_pl = _this select 0

_airplane = _this select 1

_t = 3

#cd

(name driver _airplane) sidechat format ["%1 TO %2: %3", name driver _airplane, name player, _t]

~1

? _t != 0 : _t = _t - 1; goto "cd"

_units = units group _pl; _i = count _units

#Lp

~.5

(_units select _i) action [ "eject", _airplane];

(_units select _i) setspeedmode [0,0,0];

[_units select _i] exec "ca\air2\halo\data\Scripts\HALO_getout.sqs"

? _i != 0 : _i = _i - 1; goto "Lp"

Exit

****

please note: neither the first line is displayed in the game (player sideChat "script activated") which bring me to the question of this post. :butbut:

Share this post


Link to post
Share on other sites

You should stop using .sqs and use .sqf instead.

Execute with: _nil = [groupnamehere] execVM "scripts\halo.sqf"

if (isServer) then 
{

_grp = _this select 0;

{
   		unassignVehicle (_x);
  		 (_x) action [ "eject", vehicle _x];
   		_x setvelocity [0,0,0];
   		[_x] exec "ca\air2\halo\data\Scripts\HALO_getout.sqs";
  		 sleep 0.4;

} foreach units _grp;

};

Edited by cobra4v320

Share this post


Link to post
Share on other sites

the problem is this:

[player, c130] exec "/scripts/eject.sqs"

in any editor item, (unit, object, trigger etc) you need to have a handle on all exec, execVM, spawn, call lines.

placing this in your trigger should fix alot.

[b]_null = [/b][player, c130] exec "/scripts/eject.sqs";

Edit: and your / is wrong, should be \

Not sure if it matters though.

Edited by Demonized

Share this post


Link to post
Share on other sites

Here you go try this one.

if (isServer) then 
{

_grp = _this select 0;

_t = 5;

   while {_t != 0} do {
       hint format ["HALO JUMP in:\n%1", _t];	
_t = _t - 1;
sleep 1;
   };

hint "";

{
unassignVehicle (_x);
  	(_x) action [ "eject", vehicle _x];
   	_x setvelocity [0,0,0];
   	[_x] exec "ca\air2\halo\data\Scripts\HALO_getout.sqs";
  	sleep 0.1;

   } foreach units _grp;

};

Share this post


Link to post
Share on other sites
  Demonized said:
the problem is this:

[player, c130] exec "/scripts/eject.sqs"

in any editor item, (unit, object, trigger etc) you need to have a handle on all exec, execVM, spawn, call lines.

placing this in your trigger should fix alot.

[b]_null = [/b][player, c130] exec "/scripts/eject.sqs";

Edit: and your / is wrong, should be \

Not sure if it matters though.

Thanks you all for your kind answers.

Two shorts considerations:

1) isn't "_null = code line" a local var in a global space? At least that was in opf and arma1.

2) why sqs is so obsolete? I have read a .sqs guide by cheeta on opfec and he also was saying that sqs and sqf differes by the goal aimed by the scripter.

In short, if i am not mistaken, Sqs should be preferred in easy script (like this) while sqf is preferable in complex script.

Share this post


Link to post
Share on other sites

1: _null works just fine without local variable in global space error, why i cant tell you since i dont really know why.

i always use _null and it always works.

2: sqs is slower, sqf is faster.

http://community.bistudio.com/wiki?title=6thSense.eu:EG#SQF_vs_SQS

look through that exxelent page, it explains alot of different stuff.

I myself started out with sqs and learned from Mr Murrays exxelent guide, once i wanted more i had to learn sqf, and now i never really use sqs anymore, its like the lada VS the Batmobile, both can drive on the road, but Batmobile can do so much more.

Highly recomend you start learning some sqf, its not that different from sqs really, just if instead of ? and then instead of : and sleep instead of ~ etc, ofc there is much more but it all makes sense after a short while.

Look up other peoples sqf scripts, start small and youll get a hang of it.

Also do a few searches and im sure there is several sqf guides out there.

Share this post


Link to post
Share on other sites

sqs is just fine. If your script does what you need it to do, you don't have to think about it. It does seem to be a pet peeve with many of the members here though, they see red when someone uses sqs and then try to convert him to use sqf.

  Demonized said:
the problem is this:

[player, c130] exec "/scripts/eject.sqs"

in any editor item, (unit, object, trigger etc) you need to have a handle on all exec, execVM, spawn, call lines.

placing this in your trigger should fix alot.

[b]_null = [/b][player, c130] exec "/scripts/eject.sqs";

Edit: and your / is wrong, should be \

Not sure if it matters though.

You don't need a script handle with exec.

Share this post


Link to post
Share on other sites
  Quote
You don't need a script handle with exec.

my bad, Celery is right indeed, was the error then \ / or do you still have error?

On the sqs VS sqf matter, most scripts ever released in newer times is in sqf, when you only know sqs youll end up short somewhere, unless you ofc only plan on using sqs scripts and/or create your own sqs scripts.

So learning and using sqf is a big advantage, no matter if sqs works for its purposes or not.

Share this post


Link to post
Share on other sites

Besides, when you do something stupid and come to the forums to ask for help, it is much easier for more people to help you if you use sqf.

Share this post


Link to post
Share on other sites

The main reason its easier is because you dont get hassled by the experts who rip on sqs even though most things could be done in either.

Not everyone is a programmer. Programmers arent necessarily the best script designers.

Share this post


Link to post
Share on other sites

Maybe, maybe not.

But the fact is if you ask me what is wrong with your sqs script, I will most likely not know, while with sqf I might be of help. And I'm sure I'm not the only one. sqf is much easier to read and much more similar in syntax to stuff like c and java.

Share this post


Link to post
Share on other sites
  TJ72 said:
The main reason its easier is because you dont get hassled by the experts who rip on sqs even though most things could be done in either.

Not everyone is a programmer. Programmers arent necessarily the best script designers.

The fact is SQS is depreciated. It works sure, but it's day is done. Some things are easier in it, but the future is SQF. The longer someone spends learning depreciated and obsolete coding while NOT learning SQF is only going to hurt them.

Recent weeks has had a bunch of people horribly using both SQS and SQF in the same script and having no idea why what was wrong. It was because people kept giving them SQS examples "because it works" so that's what the newbie scripter learned.

Since basically everything is being written in SQF (and now FSMs - a whole new concept to learn) that is what someone new should be learning. Things are only going to get more complicated and the leap from basic SQF to complex SQF is a lot less than SQS to complex SQF.

SQS is depreciated. Stop using it. :) Won't you think of the children.

Share this post


Link to post
Share on other sites
  kylania said:
The fact is SQS is depreciated. It works sure, but it's day is done. Some things are easier in it, but the future is SQF. The longer someone spends learning depreciated and obsolete coding while NOT learning SQF is only going to hurt them.

SQS is depreciated. Stop using it. :) Won't you think of the children.

The words 'deprecated' and 'obsolete' mean absolutely nothing because SQS works perfectly in every part of the game series, and for simpler scripts it's a time saver. People say it's deprecated because people say it's deprecated.

Share this post


Link to post
Share on other sites

Oh, come on now. Everyone knows that sqs sucks moose balls. And especially newcomers shouldn't bother to even look at sqs. You're not even allowed to write a single command over multiple lines and other bull**...

  Celery said:
... and for simpler scripts it's a time saver.

No. Sqs is never a time saver, not even for "simpler" scripts. You're just used to old habits and ugly goto's and loops which are a nightmare and should be legaly banned from any language there is. :D

  Celery said:
People say it's deprecated because people say it's deprecated.

Sqs is deprecated because it's dangerous (just take the example with unallowed linebreaks.. muahaha, poor beginners) and because it is a poor and fugly language and because we have sqf which is much better and nicer to use. ;)

Share this post


Link to post
Share on other sites
  ruebe said:
No. Sqs is never a time saver, not even for "simpler" scripts. You're just used to old habits and ugly goto's and loops which are a nightmare and should be legaly banned from any language there is. :D

Do me a favor and convert this to sqf:

?!isServer:exit
_unit=_this select 0
_number=_this select 1
goto format ["case%1",_number]

#case0
_unit setDamage 1

#case1
_unit setVelocity [0,0,50]
exit

#case2
_unit setDamage 0
~0.1
?alive _unit:goto "case2"
exit

#case3
{if (side _x==east) then {_x setDamage 1}} forEach allUnits
exit

Edited by Celery

Share this post


Link to post
Share on other sites

LOL this thread is getting out of hand, you guys should just fight it out. :yay:

Ill bring the beer and naked chicks.

if !(isServer) exitwith {};

_unit = _this select 0;
_number = _this select 1;

hint format ["case %1",_number];

switch (_number) do {

case 0:	{_unit setDamage 1};
case 1:	{_unit setVelocity [0,0,50]};
case 2:	{while {alive _unit} do {sleep 0.1; _unit setDamage 0}};
case 3:	{{if (side _x == east) then {_x setDamage 1}} forEach allUnits};
};

Edited by cobra4v320

Share this post


Link to post
Share on other sites

//////////////////     SQF RULEZ!!!     //////////////////
if (!isServer) exitWith {};
_unit = _this select 0;
_number = _this select 1;

if ((typeName _number) != "STRING") exitWith {
[_unit,str(_number)] execVM "SQFRULEZ,sqf";
};

switch (_number) do {
case "0": {_unit setDamage 1};
case "1": {_unit setVelocity [0,0,50]};
case "2": {_unit setDamage 0; sleep 0.1; if (!alive _unit) then {[_unit,"2"] execVM "SQFRULEZ,sqf"}};
case "3": {{if (side _x==east) then {_x setDamage 1}} forEach allUnits};
};

Edit, damn!! ninjaed :D

Edited by Demonized
fixed one case error.... :D

Share this post


Link to post
Share on other sites

SQS superiority for simple scripts proven, thank you gentlemen. :)

Share this post


Link to post
Share on other sites

I came up with almost the same thing as Demonized and Cobra.... might as well post!

if (not isServer) exitWith {};

_unit = _this select 0;
_number = _this select 1;

switch (_number) do {
case 0: {_unit setDammage 1};
case 1: {_unit setVelocity [0,0,50]};
case 2: {_unit setDammage 0};
case 3: {{if (side _x==east) then {_x setDamage 1}} forEach allUnits};
};

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

All I did was copy your script into a notepad and change a couple of words around. I dont disagree with you. However like everyone else is saying .sqf is what everyone to include new scripters should be heading towards.

Cant wait to see what ARMA 3 will bring...GOOD TIMES. :239:

Share this post


Link to post
Share on other sites
  Celery said:
Do me a favor and convert this to sqf:

Untested, but I'd go with something like:

if !(isServer) exitWith {};
_unit = _this select 0;
_number = _this select 1;
switch (_number) do {
case 0 : {_unit setdamage 1};
case 1 : {_unit setVelocity [0,0,50]};
case 2 : { //I'm not sure what the intended code is supposed to do, but here goes.
	_unit spawn {
		_unit = _this;
		while {alive _unit} do {
			_unit setDamage 0;
			sleep 0.1;
		};
	};
};
case 3 : {
	{
		if (side _x == east) then {_x setDamage 1};
	} forEach allUnits;
};
default {hint "Bad Parameters"};
};

I'm calling sqs decrecated because the wiki call it deprecated. I wouldn't be surprised to see sqs completely removed in Arma3. I'm sorry, but for me, sqs has "badly written script format" written all over it.

And what has already been said:

1) I don't help people anymore who post sqs, too unreadable for me to bother.

2) Confusing to have both, as especially new people, starts mixing things up.

Btw, reason I spawn the do while, is to free the memory occupied by the main script once it has decided what to do. If it's worth it, I guess can be subject to discussion.

  Celery said:
SQS superiority for simple scripts proven, thank you gentlemen. :)

I don't agree. Converting numbers to strings for the sake of making labels? Do yourself a favor and avoid spaghetti code and start using structured code instead. There is absolutely no sense in trying to teach bad coding style to aspiring new scripters.

Edited by CarlGustaffa
Syntax error, literally :p

Share this post


Link to post
Share on other sites
  CarlGustaffa said:

//I'm not sure what the intended code is supposed to do, but here goes.

I didn't quite get it either! Was no need for it.

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  

×