Jump to content
Sign in to follow this  
christian2526

How to use the vehicleChat command?

Recommended Posts

Hello guys,

I have a problem, since ArmA 3 something in the script i`m using, which worked fine in ArmA 2 OA, is broken. Simply its a vehicle Service Point Script which should display the Status of the Repair in the vehicleChat. As far as i know thats the only thing which is broken, but i can`t figure out how to use the command correct?

The Script i`m using:

_veh = (_this select 3) select 0;	

_drv = driver _veh;

if (_veh == _drv) then {
_drv groupChat "Das kannst du nur in einem Fahrzeug machen - This can only be done inside a vehicle.";

} else { if (_veh getVariable ["vehServiceActive", false]) then {
// already being serviced	
_veh vehicleChat "Dieses Fahrzeug wird bereits gewartet - This Vehicle is already being serviced.";	

} else {	

_veh setVariable ["vehServiceActive", true, true];
_veh vehicleChat "Das Fahrzeug wird repariert - This Vehicle is being repaired...";

_fuel = fuel _veh;
_veh setFuel 0;
waitUntil {sleep 1; (fuel _veh) == 0};

_dmg = getDammage _veh;	
_dmgPart = _dmg / 10;
_repairTime = 30 * _dmg;

if(!isMultiplayer) then {
	_repairTime = _repairTime / 10;
};

// Initiate Repairs

{
	sleep _repairTime;			
	_dmg = _dmg - _dmgPart;
	_veh setVehicleInit format["this setDamage %1;", _dmg];
	processInitCommands;		
	_veh vehicleChat format["Das Fahrzeug wird repariert - This Vehicle is being repaired... (%1%2)", _x, "%"];
} forEach [10,20,30,40,50,60,70,80,90];

sleep _repairTime;	
_veh vehicleChat format["Das Fahrzeug wird repariert - This Vehicle is being repaired... (%1%2)", 100, "%"];	
_veh setDamage 0;		
_veh setFuel _fuel;

_veh vehicleChat "Reparatur vollstaendig abgeschlossen! - All Repairs done!";
_veh setVariable ["vehServiceActive", false, true];

}; };

I hope someone is able to help me soon. Thanks.

Share this post


Link to post
Share on other sites

Are you sure the player is in the vehicle?

The vehicle chat shows only for unts in the vehicle.

Share this post


Link to post
Share on other sites

You are having a locality issue.

In MP, vehicleChat should be run locally on player.

It works in editor-placed Triggers because those are in a global environment, meaning they run on both server AND player.

Running it on the server-only will produce no visible text for player local, unless it's distributed through a publicVariable.

Something like this:

textToBroadcast = {
if (vehicle player = _veh) then {
_veh vehicleChat "Dieses Fahrzeug wird bereits gewartet - This Vehicle is already being serviced.";
};
}; publicVariable "textToBroadcast";

Though I am in no position to test at the moment, that will broadcast the contained code

textToBroadcast = { /* contained code */};

to all connected players. Then you have to filter the players to get the ones who should receive the message.

amended code:

_veh = (_this select 3) select 0;    

_drv = driver _veh;

if (_veh == _drv) then {
   _drv groupChat "Das kannst du nur in einem Fahrzeug machen - This can only be done inside a vehicle.";

} else { if (_veh getVariable ["vehServiceActive", false]) then {
   // already being serviced    
  textToBroadcast = {
if (vehicle player = _veh) then {
_veh vehicleChat "Dieses Fahrzeug wird bereits gewartet - This Vehicle is already being serviced.";
};
}; publicVariable "textToBroadcast"; 

} else {    

   _veh setVariable ["vehServiceActive", true, true];
   _veh vehicleChat "Das Fahrzeug wird repariert - This Vehicle is being repaired...";

   _fuel = fuel _veh;
   _veh setFuel 0;
   waitUntil {sleep 1; (fuel _veh) == 0};

   _dmg = getDammage _veh;    
   _dmgPart = _dmg / 10;
   _repairTime = 30 * _dmg;

   if(!isMultiplayer) then {
       _repairTime = _repairTime / 10;
   };

   // Initiate Repairs

   {
       sleep _repairTime;            
       _dmg = _dmg - _dmgPart;
       _veh setVehicleInit format["this setDamage %1;", _dmg];
       processInitCommands;        
       _veh vehicleChat format["Das Fahrzeug wird repariert - This Vehicle is being repaired... (%1%2)", _x, "%"];
   } forEach [10,20,30,40,50,60,70,80,90];

   sleep _repairTime;    
   _veh vehicleChat format["Das Fahrzeug wird repariert - This Vehicle is being repaired... (%1%2)", 100, "%"];    
   _veh setDamage 0;        
   _veh setFuel _fuel;

   _veh vehicleChat "Reparatur vollstaendig abgeschlossen! - All Repairs done!";
   _veh setVariable ["vehServiceActive", false, true];

}; };  

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites

Ok, got it. For the first 2 i can insert this and use it, but for the third:

   {
       sleep _repairTime;            
       _dmg = _dmg - _dmgPart;
       _veh setVehicleInit format["this setDamage %1;", _dmg];
       processInitCommands;        
       _veh vehicleChat format["Das Fahrzeug wird repariert - This Vehicle is being repaired... (%1%2)", _x, "%"];
   } forEach [10,20,30,40,50,60,70,80,90];

I dont know if it is just the same or not?

Share this post


Link to post
Share on other sites

You need to replace setVehicleInit and processInitCommands - they were removed for security.

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
Sign in to follow this  

×