Home   Help Search Login Register  

Author Topic: Help needed with BBoat script (Helicast), arma reports missing a ";"  (Read 3328 times)

0 Members and 1 Guest are viewing this topic.

Offline Landdon

  • Members
  • *
I'm have trouble trying to fix a problem that I'm encountering when I am using this helicast script below.  Armed Assualt states that I am missing a ";" somewhere near Line 70 of the code listed below.  But everything around it and near it has a ";" after each line.  This error occurs once I have use the Action menu command "Deploy Boat."   Any help would be greatly appreciated, Thanks in advance!

Code: [Select]
// Script can be run on several helicopters at the same time, as well as dealing with actions internally.
// Put: nil=[this,0,0,"Init"] execVM "bboat.sqf"; in each chopper line, or from other script by changing
// "this" to the chopper name. Remember to modify the following line to fit the helicopter array:
if (isNil "HULK_BoatCarriers") then {HULK_BoatCarriers = [bird,bird2,bird3];};
_bird = _this select 0;
_user = _this select 1;
_id = _this select 2;
_mode = _this select 3;
scopeName "Root";
// Public code section:
call compile format
['
HULK_BoatCarrier_%1 = [];
"HULK_BoatCarrier_%1" addPublicVariableEventHandler
{
_arr = _this select 1;
_c = _arr select 0;
switch (_c) do
{
case 0 :
{
_p = _arr select 1;
_p sideChat "Deploying the zodiac now!";
};
default {hint "Error in Boat script: Unexpected value in EH";};
};
};
', _bird];
// End public section
switch (_mode) do
{
case "Init" :
{
// running on all clients
scopeName "Init";
_act = 0;
_set = 0;
_r = 10; //variable sleep depending on if there is a pilot and whether the action is available - independant on all choppers
while {alive _bird} do
{
scopeName "loop01";
_posh = getPos _bird select 2;
if (isNull (driver _bird)) then {_r = 15;} else {_r = 2;};
if ( (_posh > 2 && _posh < 20) && (damage _bird < 0.5) && (_bird in HULK_BoatCarriers) && (local (driver _bird)) ) then
{
if (_set == 0) then
{
_act = _bird addAction ["Deploy boat", "bboat.sqf","Drop", 100, false, false, ""];
_set = 1;
};
_r = 0.2;
} else
{
if (_set == 1) then
{
_bird removeAction _act;
_set = 0;
_act = 0;
};
};
sleep _r;
};
};
case "Drop" :
{
// running on client using action added in Init section
scopeName "Drop";
call compile format
['
%1_CRRC = createVehicle ["Zodiac",%1 modelToWorld [0,0,-.2],[],0,""];
%2 sideChat "Deploying the zodiac now!";
HULK_BoatCarriers = HULK_BoatCarriers - [%1];
publicVariable "HULK_BoatCarriers";
//trigger public EH:
HULK_BoatCarrier_%1 = [0,%2];
publicVariable "HULK_BoatCarrier_%1";
', _bird, _user];
};
case "Add" :
{
// placeholder for way of adding boat back to heli
};
default {hint "Error in boat script: wrong parameter given";};
};

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Wild guess: assign a name to the helicopter(s).

Reason: "%1_CRRC" will turn into something like "WEST 1-1-B:1_CRRC" otherwise. And this is no valid variable name.
try { return true; } finally { return false; }

Offline Rommel92

  • Members
  • *
Code: (fix) [Select]
call compile format ["%1_CRRC = createVehicle ['Zodiac',%1 modelToWorld [0,0,-.2],[],0,''];%2 sideChat 'Deploying the zodiac now!';HULK_BoatCarriers = HULK_BoatCarriers - [%1];publicVariable 'HULK_BoatCarriers'; HULK_BoatCarrier_%1 = [0,%2];publicVariable 'HULK_BoatCarrier_%1'", _bird, _user];
You were missing various "", and also format doesn't accept line breaks, it just cracks the sh*ts.

Another way could be to do  (THEORY, NO IDEA IF WORKS):

Code: (defines) [Select]
case "Drop" :
{
// running on client using action added in Init section
scopeName "Drop";

#define __BIRD__ _bird
#define __USER__ _user

__BIRD___CRRC = createVehicle ["Zodiac",__BIRD__ modelToWorld [0,0,-.2],[],0,""];

__USER__ sideChat "Deploying the zodiac now!";

HULK_BoatCarriers = HULK_BoatCarriers - [__BIRD__];

publicVariable "HULK_BoatCarriers";

HULK_BoatCarrier___BIRD__ = [0,__USER__];
publicVariable "HULK_BoatCarrier___BIRD__";
};
« Last Edit: 17 Feb 2009, 01:35:47 by Rommel92 »

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
@Rommel92
I don't think Landdon missed anything since he seems not be the author of the code (take a look at the tag). There are also no missing quotes in the call compile format block (you can check with hint format[...]).

And #define does not work this way. Think of it as the Search/Replace function of your text editor. This Search/Replace is only done once (usually before the script is compiled). So there are no more #defines in the code that actually gets executed.
« Last Edit: 17 Feb 2009, 02:53:27 by Worldeater »
try { return true; } finally { return false; }

Offline Landdon

  • Members
  • *
You are correct I am not the author of the code, I think it was Hulking Unicorn.  The Helicopter name is "bird", and I have a game logic placed on the map called "rhib1."  I hope that helps.

Offline Rommel92

  • Members
  • *
Well technically 'he' was still missing the commas, but in regards to the actual scripting, I was unawares that " and ' could be swapped around like that.

And yes I did not think it did, it had to be constant predefined, not as something you can define later off a local variable.  :good:

Either way I think I may have figured out myself as to why that statement was not working for me in the past. I lacked a ; on the end of each statement (in hints for example), but they must be necessary.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Landdon, did you..
Quote
// ... Remember to modify the following line to fit the helicopter array:
if (isNil "HULK_BoatCarriers") then {HULK_BoatCarriers = [bird,bird2,bird3];};
... at the top of the script?
try { return true; } finally { return false; }

Offline Landdon

  • Members
  • *
I'm going to say I believe so, as I deleted "Bird2" and "Bird3" from the array and name my helicopter "bird".  I took the code out of Sharkattack's "=RTY=US-Navy-Seals-[1].Sara" PBO file. 

In the INI Line I have:

Code: [Select]
nil=[this,0,0,"Init"] execVM "bboat.sqf";
And I have a game logic placed on the map called "rhib1."


Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
What a pain. Anyway, some notes:

- The script seems not be used in sharkattack's mission
- The script dos not require a game logic.
- The pilot who drops the boat has to have a name, too!
try { return true; } finally { return false; }

Offline Landdon

  • Members
  • *
Sir,

I'm sorry you find me to be a "pain", that was not my intention at all.  But I did grab the wrong mission, title the mission is =RTY=counter-intel[1a].Sara. The mission I downloaded and just re-downloaded came from armaholic.com, and can be found at:

http://www.armaholic.com/page.php?id=3323

I place the de-pboed mission within my MPMISSION folder and look at through the editor there was a game logic.  What I will do now is, I will just start removing pieces from the mission until I get it down to just what I need.  In regards to "The pilot who drops the boat has to have a name, too!"  If I am the pilot, then I shouldn't have to go in and place may name in it, as this is not for a AI but for a human player.  So excuse me for trying to learn something.  Thank you for your time and effort.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Be assured that I don't think you're a pain. I was referring to the debugging of the script. Its style is rather obscure and it took me quite some while to get behind its secret.

About the name: the player's unit has to have a name set in the editor in order to make this script work [1]. To be more precisely, all units the player might control at the time of dropping require a name (think of team switches).


[1] The names assigned in the editor are in fact the names of global variables. The script relies on these names.
try { return true; } finally { return false; }

Had totally forgotten about this script :)

Anyway, it seems to me that you're on the right track regarding the issue Worldeater.
Probably either the helicopter or the playable unit names are unnamed.

Landdon, if you find that the units and the chopper do indeed have editor-given names, please attach your mission in your reply, and I'll take a little look.
Btw, you don't need that rhib gamelogic for my script, that's probably used by shark attack for the mission.