Jump to content
IGD Big Steve

Timer within trigger activation

Recommended Posts

Hi all, I am working on a script for a dedicated server that will add an action to a player, while inside a trigger area, to repair their vehicle/reload vehicle ammo. I am looking for help with the "cars" portion of the script. The player will enter the trigger area on a vehicle, the vehicle will be forced to freeze/stop, an addaction will appear or the player will be forced to exit before the addaction appears. I have tried numerous different methods of trying to call a remote function or running a script but have yet to find the perfect fit for the code.

I've been posting a lot recently but I am trying hard to learn what I can by myself and give an indication of effort before asking for help.

As of now, I am trying to do everything within the trigger as a last resort, fortunately it helps show what I am trying to accomplish.

//trigger options
name: serviceTrigger_1

Activation: no type, anybody present, repeatable //anyone inside the trigger

Expression:
	Condition: (vehicle player) in thisList; //vehicle/player is inside trigger is still true

	On Act: { 
				if (_x in thisList) then { 
				missionNamespace setvariable ["servicePlayer", _x]; 
										} 
			}forEach allplayers; //if the player is inside area, make it a variable
 
 		moveOut servicePlayer; //get out of the car
 
		missionameSpace setvariable ["serviceVehicle", (nearestObject [thisTrigger, "car"])]; //set a variable = the closest vehicle to the trigger
 
		serviceVehicle setvelocity [0,0,0];  //stop car
		serviceVehicle setpos (getpos thisTrigger); //make sure it doesn't roll away from lag
 
		servicePlayer addaction ["Refresh Vehicle Ammo", serviceVehicle setvehicleAmmo 1]; 
		servicePlayer addAction ["Repair Vehicle", serviceVehicle setDamage 0]; 
		hint format["You are inside the service station, please select from the scroll-wheel options"];

	On De-act: 
				removeAllActions player; 
				hint format["You left the service station"]

 

Share this post


Link to post
Share on other sites

Found this some where on the internet some time ago and Activated via SQF inside a trigger. Worked in MP.

if (isServer) then {

_timeForRepair = 5;

_vehicle = vehicle player;

hint format ["Please wait %1 seconds for repair",_timeForRepair];

sleep _timeForRepair;

if (_vehicle == player) then

{_vehicle = cursorTarget;};

_vehicle setfuel 1;

_vehicle setdamage 0;

_vehicle = nil;

};

Can't help with ammo part. Not exactly what you want but might help you further.

Share this post


Link to post
Share on other sites

preset condition of your trigger could be anyPlayer instead of anyBody

then let the simple condition : this

 

In on act field, something like

thisList spawn {
  _vehs = _this select {_x isKindOf "air" or _x isKindOf "landVehicle"};
  {
    _veh = _x;
    if (local _veh) then {
      hint "You are inside the service station, please select from the scroll-wheel options";
      _plyrs = allPlayers select {_x in _veh};
      {moveOut _x} forEach crew _veh;
      _veh setFuel 0;
      _veh setvelocity [0,0,0];
     };
    _veh addaction ["Refresh Vehicle Ammo",
      {
        params ["_tgt","_plyr","_id"];
         _tgt setvehicleAmmo 1;
         _tgt removeAction _id;
    }];
     _veh addaction ["Repair Vehicle",
      {
        params ["_tgt","_plyr","_id"];
         _tgt setDamage 0;
         _tgt removeAction _id;
    }];
    _veh addaction ["Refuel vehicle",
      {
        params ["_tgt","_plyr","_id"];
        _tgt setfuel 1:
        _tgt removeAction _id;
    }];   
    nil
  } count _vehs;
};

 

Just as example.

  • Like 2

Share this post


Link to post
Share on other sites

I got it working but I'm trying to make the activation pause briefly. This script functions and I believe should be working on MP as well. The trigger processes the script so fast that the player drives right through (simulation is set to false then true very quickly). I'm trying to pause the activation for a couple seconds so the vehicle can stop and the player can turn the vehicle around around. Basically I want to pause it so the player doesn't crash. 

 

//condition
allplayers in thisList || vehicle player in thisList;

//on activation

hint format["You entered the Service Staion"];  
 
{   
publicVariable "serviceVehicle"; 
serviceVehicle = nearestObject [thisTrigger, "car"];   
publicVariable "servicePlayer";     
servicePlayer = _x;   
}forEach thisList; 
 
if ( 
((serviceVehicle distance2D thisTrigger) < 15) && 
((servicePlayer distance2D thisTrigger) < 15) 
) 
then{ 
    
serviceVehicle enableSimulation false;   
servicePlayer enableSimulation false;   
disableUserInput true;  
 
serviceVehicle setVelocity [0,0,0]; 
serviceVehicle setvehicleAmmo 1;    
serviceVehicle setDamage 0;    
servicevehicle setfuel 1;   

// delay excecution here

hint format["Your vehicle has been repaired, refuled and rearmed"];  
 
serviceVehicle enableSimulation true;   
servicePlayer enableSimulation true; 
disableuserInput false; 
};

 

 

  • Confused 1

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

preset condition of your trigger could be anyPlayer instead of anyBody

then let the simple condition : this

 

In on act field, something like

 

Just as example.

 

The script will not run, the trigger doesn't like running a script and gives errors. 

Share this post


Link to post
Share on other sites
1 hour ago, IGD Big Steve said:

 

The script will not run, the trigger doesn't like running a script and gives errors. 

I tested it. But feel free to persist in your way.

PS: There are plenty of possible error in a trigger, like omit a handle (here 0 for spawn command), or any // /* comment line.

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

×