Jump to content
davidoss

setVehicleammodef

Recommended Posts

Hi.

I write a simple vehicle service  code:

 

if (isServer) then { 
 
 null = [thislist select 0] spawn { 
 
  params ["_veh"]; 
   
   private _turrets = count (allTurrets _veh); 
   private _gethit = getAllHitPointsDamage _veh; 
   private _fuel = ((fuel _veh) < 1); 
   private _damage = _gethit select 2; 
   private _damaged = ((count (_damage select {_x > 0})) > 0);  
   private _proceded = false; 
   sleep 2; 
   if (_damaged) then { 
    
    (vehicle _veh) setDamage 0; 
    _proceded = true; 
   }; 
   if (_fuel) then { 
    
    null = [_veh, 1] remoteExecCall ["setFuel", _veh, false]; 
    _proceded = true; 
   }; 
    
   if !(_turrets isEqualTo 0) then { 
    
    null = [_veh, 1] remoteExecCall ["setVehicleAmmoDef", _veh, false]; // not working
    _proceded = true; 
   }; 
    
   if (_proceded) then { 
    
    [getPos _veh, "vehrepaired", "Vehicle",crew _veh] call fnc_sendNotif; 
     
   }; 
 }; 
 
};

I do not knew really why,  i think that there is going about turret locality.

How to write this properly?

Share this post


Link to post
Share on other sites

Using

veh setFuel 1;
veh setDamage 0;
veh setVehicleAmmo 1;

would work just as well. Setting damage to 0 if it's already 0 isn't a problem.

This looks like a university approach to problems, aka why make it simple when it can be made complicated. :)

Share this post


Link to post
Share on other sites

Not so easy, the trigger contain this code exist only server side

Share this post


Link to post
Share on other sites

Maybe something like..

{
	if !( turretLocal _x ) then {
		_null = [_veh, 1] remoteExecCall ["setVehicleAmmoDef", turretOwner _x, false];
	}else{
		_veh setVehicleAmmoDef 1;
	};
}forEach allTurrets _veh;

Most likely dont even need the IF statement as remoteExec should be smart enough to only apply it locally without any network traffic seeing as this is on the server.

Share this post


Link to post
Share on other sites
On 12/18/2016 at 1:45 AM, davidoss said:

Thanks works great

 

Hi, this looks just like something I could use. Can you please post the final form and an example of how to use it?

Share this post


Link to post
Share on other sites

Can you tell me how to run this though?

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

×