Jump to content
Sign in to follow this  
Kakel_anders@hotmail.com

Problems with my first small script..

Recommended Posts

Hey guys,

For learning purposes i started making a fireextinguisher-script.

It does pretty much what i want it to do today using addAction but i can't for the life of me understand why i cannot remove the action at the end of the script...

If anyone would care to have a look at it and inform me what im doing wrong here ?

Fireextinguisher.sqf

// Simple Fireextinguisher by Tactical Anders (Using a crapload of other scripts and wikis for inspiration)

// Check if landvehicle is within 5 meters
_vehicle = player nearObjects ["LandVehicle", 5]; 

// Select closest landvehicle and put it in the _veh variable
_veh = _vehicle select 0; 

// Check damage on nearest hunter and add to _vehdamage
_vehDamage = getDammage _veh;

// If there is atleast 1 land vehicle nearby - >  Allow Extinguisher
IF (count _vehicle >= 1)

// Then set the damage to 1 -> 0 -> 1 to create non burning wreck, play sound handle temporary invul and display message
THEN {_vehDamage = _veh setDamage 1;
  _vehDamage = _veh setDamage 0;
  _vehDamage = _veh setDamage 1;
  player allowDammage false;
     player say3D ["Sound1", 100];
  hint "You temporarily put the fire out, hurry up!";
  sleep 10;
  player allowDammage true;
  hint "The vehicle is boiling hot, get out of there!";

[color="#FF0000"]// Remove action
  player removeAction _extAction;


};
ELSE {
   hint "You are too far away from the fire";
};[/color]

(The red lines indicate what i cant get to run)

And im adding the action from init.sqf like this

_extAction = player addAction ["Fire extinguisher","extinguisher\extinguisher.sqf"];

Be aware this is my first script, and im sure there are better ways to do this, but this is what i as a complete noob could make out of a little googling and Biki :)

Cheers!

Share this post


Link to post
Share on other sites

The _extAction is defined outside of the addAction script, that cannot work, as the _extAction is only locally bound.

Checking the biki we see that the action id is also found inside the addAction script via _this select 2 (https://community.bistudio.com/wiki/addAction)

So if you replace 'player removeAction _extAction;' with 'player removeAction (_this select 2);' it should work.

Share this post


Link to post
Share on other sites

Hey TeTeT, and thanks for the answer!

Yes, ive tried a few variations there already.

The script do run though, maybe i should use a globalvariable instead ?

Anyway, thing is that the script doesnt even run as far down as to the removeAction and i have been battleing it out with the .rpt for quite a while.

This is what it gives me -

ELSE {
hint "You are too far away from the fi>
13:12:04   Error position: <{
hint "You are too far away from the fi>
13:12:04   Error Missing ;
13:12:04 File C:\Users\Game\Documents\Arma 3 - Other Profiles\kakel_anders\missions\Altisfire.Altis\extinguisher\extinguisher.sqf, line 35
13:12:04 Error in expression <ayer removeAction _extAction;

// Anders

Share this post


Link to post
Share on other sites

The part with

};

ELSE {

most likely doesn't work, as the ; closes the if. You need to remove it.

Good luck with fixing the script,

TeTeT

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  

×