Jump to content
Cigs4

Artillery problems in MP dedicated

Recommended Posts

Hello!

I'm stuck for a few days on this. The idea would be that, as soon as a trigger is activated, a mortar will start shooting at the players.
 

0 = []spawn {  
  
while {alive gun_1G} do {  
sleep 15;  
_ammo = getArtilleryAmmo [gun_1] select 0;    
_tgt = player getRelPos [50,30];   
[gun_1,[_tgt,_ammo,1]] remoteExecCall ["doArtilleryFire"];};  
  
};

The code is in a trigger with Activation BLUEFOR, DETECTED BY OPFOR. It's a dedicated MP environment.

The trigger works, but gives this error: "Error Undefined variable in expression: _ammo".

I don't know how to fix this, I searched and didn't find a solution.

Would anyone know how to help me, please??

Thanks in advance.

Share this post


Link to post
Share on other sites
3 hours ago, Cigs4 said:

"Error Undefined variable in expression: _ammo".

Most likely getArtilleryAmmo is returning [] so select 0 is nil( undefined ).

Try getArtilleryAmmo from the debug console and see what return you are getting.

There is also no need for the remoteExec(unless the trigger is server only and gun_1 is not local to the server). Make sure that gun_1 is local or remoteExec where gun_1 is local rather than everywhere.

 

Share this post


Link to post
Share on other sites

This worked for me in a hosted MP.

 

_ammo = getArtilleryAmmo [mortar1] select 0;
_tgt = getPos player;
mortar1 doArtilleryFire[_tgt,_ammo,3];  //3 is amt. shots fired

 

Share this post


Link to post
Share on other sites

Many thanks to both of you for your help.

Larrow, actually after doing what you suggested, I saw that the mortar returned nil for ammo.
I never suspected it might be out of ammo, in fact I believed it had infinite ammo.

One more thing learned.

Thanks again, gentlemen.

Share this post


Link to post
Share on other sites

On dedicated, there is no player, so you could have some extra issues because player is undefined.
You can use something like:

- selectRandom allPlayers;

- selectRandom (allPlayers select {side _x == WEST});

- or referring to the trigger (in activation code):


 

thisTrigger spawn {
  params ["_trig","_plyrs","_ammo"];
  while {alive gun_1G} do {
    sleep 15;
    _plyrs = allPlayers select {_x inArea _trig && side _x == WEST};
    _ammo = getArtilleryAmmo [gun_1];
    if (_plyrs isEqualTo [] or _ammo isEqualTo []) exitWith {};
    _tgt = (selectRandom _plyrs) getPos [30 + random 20,random 360];
    gun_1 doArtilleryFire[_tgt,_ammo #0,1];
  };
};

 

  • Like 3

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

×