Jump to content
clock_x

Problem with dog patrol script - undefined variable

Recommended Posts

Hey there,

 

I'm using the dog patrol script 'Patrulla Perruna' from Monovdd | Carlos Alberto Arango Schutz (+  Team Condor | CLA). It's pretty awesome, perfect for my stealth mission.

 

But I got one problem, I'm in the process of clearing all script errors. Mainly undefined variable ones.

 

The rpt file gives me one error at the start of the script:

Error in expression <

if (Isserver) then {

_unidad = _this select 0;

_RazaDeseada = _this se>
  Error position: <_this select 0;

_RazaDeseada = _this se>
  Error Undefined variable in expression: _this
File D:\x\x\ArmA 2\missions\OP%20GECKOHUNT%20v2%2e2%2e5%20Final.Takistan\scripts\patrullaperruna.sqf, line 22

Here is what the script looks like in that part:

if (Isserver) then {

    _unidad = _this select 0; //unit
    
    _RazaDeseada = _this select 1; //dog race
    
    _cantidad = _this select 2; //count
    
    _bando = side _unidad;
    
    _grupo = creategroup _bando;

And here is how I call it from my units init:

_nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";

I don't really understant how _this is undefined since it is _unidad, the unit in this case. It's placed in the editor, so why is it doing this?

Anyone got an idea how to fix this?


Help is much appreciated! Thanks in advance.

 

Cheers

Share this post


Link to post
Share on other sites

The error says line 22. The script snippet you posted would have the error in line 3. So there is something missing in that script, which might be the cause of the problem.

Is it a player controlled unit? Error might happen when the slot stays empty.

Share this post


Link to post
Share on other sites

Thanks for the quick answer!
There are notes and description before that:

Spoiler

//----------------------------------------------------------------------------------------------------------
//  Patrulla Perruna | Dog Patrol
//  Version: 0.0.3
//  Autor: Monovdd | Carlos Alberto Arango Schutz (monovdd@hotmail.com)
//    Creditos: Team Condor | CLA
//----------------------------------------------------------------------------------------------------------
//  Notes: This Script is inspired by two other existing scripts, in fact part of the work is taken
// of the authors of these scripts. Script blitzy (Limitations for multiplayer) and EODD Dog li-
// mitations in terms of playability.
//
// Description: Script that allows you to add a dog to a unit to form a patrol with a dog that
// Detect and attack nearby enemy soldiers and play sounds of a real dog.
//----------------------------------------------------------------------------------------------------------
// Use: Place the following in the init of the soldier dog master:
//            _nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";
//----------------------------------------------------------------------------------------------------------
//PROCESS OF INITIALIZATION OF THE SCRIPT. VARIABLES ARE DEFINED
//----------------------------------------------------------------------------------------------------------

if (Isserver) then {

    _unidad = _this select 0; //unit
    
    _RazaDeseada = _this select 1; // dogs race
    
    _cantidad = _this select 2; //count
    
    _bando = side _unidad;
    
    _grupo = creategroup _bando;


It's a non playable AI OPFOR unit. My map is a singleplayer map with 2 switchable BLUFOR player units. I really have no clue why this is happening, then again I'm no expert. 😀
I'm always trying to figure stuff out like this:

player globalChat format ["unit:%1 dog:%2 number:%3", _unidad, _RazaDeseada, _cantidad];

I got ANY ANY ANY from it.

Share this post


Link to post
Share on other sites

Oh wait I slightly missunderstood.

So _this is nil. I thought the "this" in the array might be nil.
Maybe you are calling it with "execVM.." without the arguments somewhere?

Executing this:

_nul = execVM "scripts\patrullaperruna.sqf";

Would cause the error you're getting.

Share this post


Link to post
Share on other sites

Searching through my mission.sqm  I only got it in two units:

_nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";
_nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";

(I removed the extra questionmarks from the sqm.)


And I got this in my init.sqf:

call compile preprocessFileLineNumbers "scripts\patrullaperruna.sqf";

Maybe that's the problem?
I dont actually know why I have this line there, normally it says so in the description from the script author, but it doesn't.

Share this post


Link to post
Share on other sites
1 minute ago, clock_x said:

Maybe that's the problem?

Yes it is. You are calling it without arguments.

Why are you doing that?

Share this post


Link to post
Share on other sites

I don't know, put this there a year ago for some unknown reason, thanks for helping me out there. 😀

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

×