Jump to content

Recommended Posts

I want a unit to move in a vehicle after respawn but it shows that error code:

17:52:36 Error in expression <_wp = _unit addWaypoint [_pos1, 0];>
17:52:36   Error position: <_unit addWaypoint [_pos1, 0];>
17:52:36   Error Undefined variable in expression: _unit
17:52:36 Error in expression <_unit  setWaypointType "MOVE";>
17:52:36   Error position: <_unit  setWaypointType "MOVE";>
17:52:36   Error Undefined variable in expression: _unit
17:52:36 Error in expression <_unit setWaypointSpeed "Full";>
17:52:36   Error position: <_unit setWaypointSpeed "Full";>
17:52:36   Error Undefined variable in expression: _unit
17:52:36 Error in expression <_unit setWaypointBehaviour "Combat";>
17:52:36   Error position: <_unit setWaypointBehaviour "Combat";>
17:52:36   Error Undefined variable in expression: _unit
17:52:36 Error in expression <_unit setWaypointType "GETIN NEAREST";>
17:52:36   Error position: <_unit setWaypointType "GETIN NEAREST";>
17:52:36   Error Undefined variable in expression: _unit

 

 

 

the script is activated with this in the unit's init:this addMPEventHandler ["MPRespawn", {[_unit] exec "respawnvehiclescript.sqf"}];

 

the script:    _unit = _this select 0;
    _pos1 = getMarkerPos "Marker1";
    _wp = _unit addWaypoint _pos1
    _unit  setWaypointType "MOVE";
    _unit setWaypointSpeed "Full";
  _unit setWaypointBehaviour "Combat";
  _unit setWaypointType "GETIN NEAREST";
      hint "%1 respawned!!!"

Share this post


Link to post
Share on other sites
this addMPEventHandler[ "MPRespawn", {
	params[ "_unit", "_corpse" ];
	
	[ _unit ] execVM "respawnvehiclescript.sqf"
}];

 

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, Larrow said:

this addMPEventHandler[ "MPRespawn", {
	params[ "_unit", "_corpse" ];
	
	[ _unit ] execVM "respawnvehiclescript.sqf"
}];

 

it seems to be working but now i get this error:

18:31:37 Error in expression <Marker1";
_wp = _unit addWaypoint _pos1
_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:37   Error position: <_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:37   Error Missing ;

    

script:private ["_unit"];
    _unit = _this select 0;
    IF(!local _unit) exitwith {};

    _pos1 = getMarkerPos "Marker1";
    _wp = _unit addWaypoint _pos1
    _wp  setWaypointType "MOVE";
    _wp setWaypointSpeed "Full";
  _wp setWaypointBehaviour "Combat";
  _wp setWaypointType "GETIN NEAREST";
  hint "%1 respawned!!!"
 

Share this post


Link to post
Share on other sites
Just now, Spriterfight said:

it seems to be working but now i get this error:

18:31:37 Error in expression <Marker1";
_wp = _unit addWaypoint _pos1
_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:37   Error position: <_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:37   Error Missing ;

    

script:private ["_unit"];
    _unit = _this select 0;
    IF(!local _unit) exitwith {};

    _pos1 = getMarkerPos "Marker1";
    _wp = _unit addWaypoint _pos1
    _wp  setWaypointType "MOVE";
    _wp setWaypointSpeed "Full";
  _wp setWaypointBehaviour "Combat";
  _wp setWaypointType "GETIN NEAREST";
  hint "%1 respawned!!!"
 

nevermind i got it

 

Share this post


Link to post
Share on other sites
5 minutes ago, Spriterfight said:

_wp = _unit addWaypoint _pos1

No ending ;

  • Thanks 1

Share this post


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

No ending ;

now shows this

 18:38:05 Error in expression <1 = getMarkerPos "Marker1";
_wp = _unit addWaypoint _pos1;
_wp  setWaypointType >
18:38:05   Error position: <addWaypoint _pos1;
_wp  setWaypointType >
18:38:05   Error addwaypoint: Type Object, expected Group

  

script:

    _pos1 = getMarkerPos "Marker1";
    _wp = _unit addWaypoint _pos1;
    _wp  setWaypointType "MOVE";
    _wp setWaypointSpeed "Full";
  _wp setWaypointBehaviour "Combat";
  _wp setWaypointType "MOV";
  hint "%1 respawned!!!"

Share this post


Link to post
Share on other sites

You are adding your waypoint to a unit, not a group.

_wp = (group _unit) addWaypoint _pos1;

or similar, the parentheses may not be necessary.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

You should bookmark this page - https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 - and have a look at the commands you are using. Use of them is explained pretty well, and in this case it's addWaypoint that is wrong next (you need to give it a group, not a unit), but there's a few other mistakes in there that you'll find the answers to in the script wiki

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Oh, addWaypoint takes at least two arguments (center and radius)

_unit = unit1;
_pos1 = getMarkerPos "Marker1";
_wp = (group _unit) addWaypoint [_pos1, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "Full"; 
_wp setWaypointBehaviour "Combat";

 

  • Thanks 1

Share this post


Link to post
Share on other sites
9 minutes ago, beno_83au said:

you'll find the answers

Sorry @beno_83au, just saw you were leading him to water 🙂

 

Or teaching him to fish? I dunno. I'm tired.

  • Thanks 1
  • Haha 2

Share this post


Link to post
Share on other sites

now it says 

18:31:51 File C:\Users\tibcs_000\Documents\Arma 3\missions\ww2mp.Tanoa\respawnvehiclescript.sqf, line 7
18:31:51 Error in expression <Marker1";
_wp = _unit addWaypoint _pos1
_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:51   Error position: <_wp  setWaypointType "MOVE";
_wp setWayp>
18:31:51   Error Missing ;

 

 

script:

    private ["_unit"];
    _unit = _this select 0;
    IF(!local _unit) exitwith {};

    _unit = unit1;
    _pos1 = getMarkerPos "Marker1";
    _wp = (group _unit) addWaypoint [_pos1,0];
    _wp setWaypointType "MOVE";
    _wp setWaypointSpeed "Full";
    _wp setWaypointBehaviour "Combat";
  hint "%1 respawned!!!"

do respawned ai units change variable name?

Share this post


Link to post
Share on other sites

No, I pasted my test code, I forgot to remove that declaration. Just delete the line 

_unit = unit1;

Told you I was tired.

  • Thanks 1

Share this post


Link to post
Share on other sites

what to do if the ai dosent follow waypoints and runs everywhere on the server but if i switch to sp they follow the waypoints properly

Share this post


Link to post
Share on other sites

You are doing a locality check, so if the AI aren't local to your machine, they won't receive the waypoint.

Share this post


Link to post
Share on other sites

So i tested some things the ai wont move on the mp map even if i switch to singleplayer but if i make a new scenario the ai moves

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

×