Forum Jump :

Author Message

Wambo  



Posts: 3
Rank:


Level: Member

Country: at
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-07-17 23:50        
     
Hello,

I just started to learn SQF scripting.
To get more familiar with the syntax I wanted to make a script which repairs a car to the state where it´s able to drive.

I get this Errormessage when I run the script via console [_nul = [] execVM "scripts\start_repair.sqf";] and then try to repair a vehicle:
Link

Here´s my code:
Link
Link

I hope someone can help me.

Greetings
Wambo


Author Message


Posts: 1525
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2014-07-18 00:59        
     
It fails because _vehicle exists in one script but not the other, using _ in front of a variable makes it only work in the current script/scope.

You will need to pass the information about the vehicle to the other script.
Change addaction to the following in file 1

_action = player addAction ["Repair Provisionally","scripts\repair.sqf",_vehicle];


and then in file 2

add this
at the top of the code
_vehicle = _this select 3;

it should now be defined.

Also it would be better to copy and paste your script otherwise anyone who tries to help may have to retype every line of code to test it if it's not an obvious fix.


Advertisement


Author Message

Wambo  



Posts: 3
Rank:


Level: Member

Country: at
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2014-07-18 01:08        
     
Thanks a lot for your fast answer (:. I had no clue what was wrong.
Yeah. I´ll copy the text next time.

Greetings
Wambo


Author Message


Posts: 176
Rank:


Level: Member

Country: pl
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2014-07-18 02:26        
     
For the future:
_var //is local variable
var //is global variable (but not public!)

u can also private variables for scope:
private ["_var"];
if u want use local variables in other script/functions u must pass them as F2kSel show (in that case)


Author Message

Wambo  



Posts: 3
Rank:


Level: Member

Country: at
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2014-07-18 11:14        
     
Okay, thanks.