Jump to content
  • 0

[HELP] Need help tweaking my deploy script a little bit.


DangerRuss

Question

Im using a version of right click deploy bike script, making use of maca's right click system. Anyways I'm trying to do 2 things.

1. Im trying to allow an interrupt which will cancel the build when the player moves. For example if the player is deploying the bike and gets shot at and needs to cancel the build.

2. Currently my deploy script nicely places the bike in front of you. But I have seen servers which attach the buildable to the player, and allows the player to move the buildable into position before placing it.

Obviously the 2 would have to work together, so that moving to place the buildable doesn't cancel the build until you've actually started to build it.

Here is my current deploy script.

_weapons = [currentWeapon player] + (weapons player) + (magazines player);
closeDialog 0;

_toolbox = "ItemToolbox" in _weapons;

if (!_toolbox) then {
    cutText [format["Missing Toolbox"], "PLAIN DOWN"];
} else {
    player removeAction s_player_deploybike;
    player playActionNow "Medic";
    r_interrupt = false;
	player removeWeapon "ItemToolbox";
    	_dis=10;
    	_sfx = "repair";
    	[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
    	[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
 
   	 sleep 6;
	_Offset = [0,5,0]; //change how far from player vehicle spawns
	_worldPos = player modelToWorld _Offset; // spawn in front of player
    _object = "MMT_USMC" createVehicle (_worldPos);
   	_object setVariable ["ObjectID", "1", true];
   	_object setVariable ["ObjectUID", "1", true];
	_object setVariable ["Deployed", "1", true];
 	_degrees = getDir player;
	_object setDir _degrees;
   	 player reveal _object;
 
    	cutText [format["Here's your bike you lazy bum!"], "PLAIN DOWN"];
   	 r_interrupt = false;
   	 player switchMove "";
   	 player playActionNow "stop";
 
    	sleep 10;
 
   	 cutText [format["Warning: Spawned bikes DO NOT SAVE after server restart! If you wish to keep it - deconstruct it!"], "PLAIN DOWN"];
 
	
};

Here is an example of what Im talking about. Although I dont want to use the EVD script which he is using and has modified.

https://www.youtube.com/watch?v=oASs2_RUX88&feature=youtu.be

 

Thanks for any help!

Link to comment
Share on other sites

Recommended Posts

  • 0

Ok ive got it deleting vehicles, but how do I get it to stop the building loop?  It cancels the build but your player is still stuck in the position going through the animation. This is what Ive got working so far!

deploybike = false; //or whatever you would like to call this variable ;)

_weapons = [currentWeapon player] + (weapons player) + (magazines player);

closeDialog 0;


_toolbox = "ItemToolbox" in _weapons;

if (!_toolbox) then {
		cutText [format["Missing Toolbox"], "PLAIN DOWN"];
	} else {
		_Offset = [0,5,0]; //change how far from player vehicle spawns
		_worldPos = player modelToWorld _Offset; // spawn in front of player
		_object = "Old_bike_TK_INS_EP1" createVehicle (_worldPos);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object setVariable ["Deployed", "1", true];
		_object attachTo [player,[-0.2, 5, 1]];		

		waitUntil {deploybike};
		
		player playActionNow "Medic";
		cutText ["\n\nDeploying vehicle started... Move from current position to cancel", "PLAIN DOWN"];


			[1,1] call dayz_HungerThirst;
			player playActionNow "Medic";

			[player,"repair",0,false] call dayz_zombieSpeak;
			[player,50,true,(getPosATL player)] spawn player_alertZombies;

			r_interrupt = false;
			_animState = animationState player;
			r_doLoop = true;
			_started = false;
			_finished = false;

			while {r_doLoop} do {
				_animState = animationState player;
				_isMedic = ["medic",_animState] call fnc_inString;
				if (_isMedic) then {
					_started = true;
				};
				if (_started and !_isMedic) then {
					r_doLoop = false;
					_finished = true;
				};
				if (r_interrupt) then {
					r_doLoop = false;
				};
				sleep 0.1;
			};
			r_doLoop = false;
			
		if (_finished) then {
		
		player removeWeapon "ItemToolbox";
			_dis=10;
			_sfx = "repair";
			[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
			[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
	 
			detach _object;
		 
	 
			cutText [format["Here's your bike you lazy bum!"], "PLAIN DOWN"];
		 r_interrupt = false;
		 player switchMove "";
		 player playActionNow "stop";
	 
		sleep 10;
		//this way every player will get the message from a deployed bike
		_object addEventHandler ["GetIn",{
				_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned bikes DO NOT SAVE after server restart! If you wish to keep it - deconstruct it!","PLAIN DOWN",5] call RE;
			}];
		
	 
		
		}
		else {
        deleteVehicle _object;
		cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
		};
};

 

gonna keep comparing it to my old script to see what I can do!

 

Ok I have it working, I havent checked for any RPT errors but it works

deploybike = false; //or whatever you would like to call this variable ;)

_weapons = [currentWeapon player] + (weapons player) + (magazines player);

closeDialog 0;


_toolbox = "ItemToolbox" in _weapons;

if (!_toolbox) then {
		cutText [format["Missing Toolbox"], "PLAIN DOWN"];
	} else {
		_Offset = [0,5,0]; //change how far from player vehicle spawns
		_worldPos = player modelToWorld _Offset; // spawn in front of player
		_object = "Old_bike_TK_INS_EP1" createVehicle (_worldPos);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object setVariable ["Deployed", "1", true];
		_object attachTo [player,[-0.2, 5, 1]];		

		waitUntil {deploybike};
		
		player playActionNow "Medic";
		cutText ["\n\nDeploying vehicle started... Move from current position to cancel", "PLAIN DOWN"];


			[1,1] call dayz_HungerThirst;
			player playActionNow "Medic";

			[player,"repair",0,false] call dayz_zombieSpeak;
			[player,50,true,(getPosATL player)] spawn player_alertZombies;

			r_interrupt = false;
			_animState = animationState player;
			r_doLoop = true;
			_started = false;
			_finished = false;

			while {r_doLoop} do {
				_animState = animationState player;
				_isMedic = ["medic",_animState] call fnc_inString;
				if (_isMedic) then {
					_started = true;
				};
				if (_started and !_isMedic) then {
					r_doLoop = false;
					_finished = true;
				};
				if (r_interrupt) then {
					r_doLoop = false;
				};
				sleep 0.1;
			};
			r_doLoop = false;
			
		if (_finished) then {
		
		player removeWeapon "ItemToolbox";
			_dis=10;
			_sfx = "repair";
			[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
			[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
	 
			detach _object;
		 
	 
			cutText [format["Here's your bike you lazy bum!"], "PLAIN DOWN"];
		 r_interrupt = false;
		 player switchMove "";
		 player playActionNow "stop";
	 
		sleep 10;
		//this way every player will get the message from a deployed bike
		_object addEventHandler ["GetIn",{
				_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned bikes DO NOT SAVE after server restart! If you wish to keep it - deconstruct it!","PLAIN DOWN",5] call RE;
			}];
		
	 
		
		
		} else {
		r_interrupt = false;
		player switchMove "";
		player playActionNow "stop";
        deleteVehicle _object;
		cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
		};
};

Link to comment
Share on other sites

  • 0

i just got it with right click, thats why these options are missing.

 

for the animation:

[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";

deleteVehicle _object; cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"]; }; 

 

Link to comment
Share on other sites

  • 0

 

i just got it with right click, thats why these options are missing.

 

for the animation:

[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";

deleteVehicle _object; cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"]; }; 

 

 

Alright yea I figured that out.. mine looks a bit different though haha we'll see if I get RPT errors.

 

How would I add

cutText ["\n\nPRESS SPACE BAR TO DEPLOY.", "PLAIN DOWN"]

after you click "deploy bike".. so players know they have to press space to deploy it.

I tried adding it right before

waitUntil {deploybike};

but that just breaks the script :P

Link to comment
Share on other sites

  • 0

Next order of business... when deploying this I see both the deploy and repack action on the scroll wheel, which allows the possibility of infinite toolboxes. I tried to get the "deployed" variable to set after the bikes been built but I Can't get that to work. Gonna try remove the action variables in the deploy script.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...