Jump to content
Sign in to follow this  
Rkillah-Rye

Emulated Minefield script

Recommended Posts

Hi my problem is with the following script, the script itself works wonders but breaks if the script is triggered when in a wheeled/tracked vehicle.

The script execution is in a repeating detect blufor trigger that covers a specific area

when trigger is activated it runs the following script..

//hit_minefield.sqf    ----   delayed trigger every specific increment set in reactivating trigger emulates a minefield
player setVariable ["in_Minefield", TRUE];
_in_minefield = player getVariable "in_Minefield";
while {_in_minefield} do {
	if(alive player)then {
					_in_minefield = player getVariable "in_Minefield";
					_Who = player;
					_velx = velocity (vehicle player) select 0;
					_vely = velocity (vehicle player) select 1;
					_spd = (_velx + _vely);
					_air = vehicle player isKindOf "Air";
					_veh = vehicle player;
					[WEST,"base"] sideChat format["%1 stepped in a minefield traveling at speed %2 as a %3 / air vehicle = %4",_Who,_spd,_veh,_air];// debugging
					if (vehicle player isKindOf "Air")then
					{
					[WEST,"base"] sideChat format["%1 is in an air vehicle and is above the minefield",_Who];// debuggingdd
					}else{
							[WEST,"base"] sideChat format["%1 checking are you moving in the minefield?",_Who];// debugging
						if (_spd != 0 or _spd != -0)then	{
							[WEST,"base"] sideChat format["%1 is moving have you hit a mine?",_Who];// debugging
							_hitmine = floor(random(3));
							[WEST,"base"] sideChat format["%1 is moving have you hit a mine? give me 0 for yes = %2",_Who,_hitmine];// debugging
									if( _hitmine != 0)then{
									[WEST,"base"] sideChat format["%1 is a lucky bastard just missed a mine",_Who];// debugging
									}else{
									_pos = position player ;
									[WEST,"base"] sideChat format["%1 has hit a mine!",_Who];// debugging
									 //bomb="Bo_GBU12_lgb" createVehicle (_pos);
									};
							}else{
							[WEST,"base"] sideChat format["%1 is standing still in a minefield",_Who];// debugging
						};
					};
	}else{
	[WEST,"base"] sideChat "you are dead";// debugging
	player setVariable ["in_Minefield", FALSE];
	};
	sleep floor(random(5));
};

When the trigger is deactivated it runs this script.

player setVariable ["in_Minefield", FALSE];

The problem is as follows

if the player enters the "minefield"(trigger area) in a vehicle and then gets out of the vehicle and then walks out of the "minefield"(trigger area)

the script continues to run on the player? this tells me it is still running on the vehicle entity but doing the speed checks and vehicle checks on the player entity but its ignoring the player variable "in_Minefield" as if it has attached this variable to the vehicle, but it works seemlessly if you go in and out on foot.

ps the side chat is just for debugging purposes.

Share this post


Link to post
Share on other sites

Im back and I have found where the problem is, it is not the script itself it is the trigger, when the vehicle activates the trigger and the vehicle stays in the trigger area it is not deactivating, so my question is now how can i group the trigger via script to all of the players, so it is only activated deactivated by each player seperately.

RK

---------- Post added at 07:26 PM ---------- Previous post was at 07:24 PM ----------

Im back and I have found where the problem is, it is not the script itself it is the trigger, when the vehicle activates the trigger and the vehicle stays in the trigger area it is not deactivating, so my question is now how can i group the trigger via script to all of the players, so it is only activated deactivated by each player seperately.

RK

The Trigger itself is only created once on the server, but the script runs on the player so is this possible to have 2 different players activate the trigger at the same time?

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  

×