Jump to content
  • 0

[HELP] Players able to bypass part requirements when deploying vehicles..


DangerRuss

Question

Sorry for the confusing title but I need a little bit of help. Im using an old scroll wheel option deploy script that I've modified to suit my purposes however I've recently discovered a rather serious problem. When you deploy the vehicle it is initially attached to the player and you are required to press space bar to deploy the vehicle. However, in the time before you press space bar you can simply move the required parts to your backpack and then deploy the vehicle without actually losing the required parts. This allows players to make an infinite amount of deployable vehicles.

 

How can I stop this?  Here are my scripts

 

Deploy.sqf

if !(isNil "isDangerDeploying")exitWith{
    titleText["Already deploying something ...","PLAIN DOWN"];
};
isDangerDeploying = true;

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 {
		cutText ["\n\nPRESS SPACEBAR TO DEPLOY", "PLAIN DOWN"];
		_Offset = [0,5,0]; //change how far from player vehicle spawns
		_worldPos = player modelToWorld _Offset; // spawn in front of player
		_object = "350z_ruben" createVehicle (_worldPos);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object attachTo [player,[-0.2, 5, 1]];		

		waitUntil {deploybike};
		_object setVariable ["Deployed", "1", true];
		
		player playActionNow "Medic";
		cutText ["\n\nDeploying vehicle. 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";
		player removeMagazine "PartEngine";
		player removeMagazine "PartGeneric";
			_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 350z you lazy bum!"], "PLAIN DOWN"];
		 r_interrupt = false;
		 player switchMove "";
		 player playActionNow "stop";
	 
		sleep 10;
		
		_object addEventHandler ["GetIn",{
				_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned 350z DO NOT SAVE after server restart! ","PLAIN DOWN",5] call RE;
			}];

		
		} else {
		r_interrupt = false;
		player switchMove "";
		player playActionNow "stop";
        deleteVehicle _object;
		cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
		};
};

isDangerDeploying = nil;

fn_selfActions.sqf

// -------------------------------------- 350z DEPLOY -------------------------------------- 
_weapons = [currentWeapon player] + (weapons player) + (magazines player);
_isNissan350z = typeOf cursorTarget in ["350z_ruben"];
 

if ("ItemToolbox" in _weapons && "PartEngine" in _mags && "PartGeneric" in _mags ) then {
        hasNissanItem = true;
    } else { hasNissanItem = false;};
    if((speed player <= 1) && hasNissanItem && _canDo) then {
        if (s_player_350z < 0) then {
            s_player_350z = player addaction[("<t color=""#D16666"">" + ("Deploy 350z") +"</t>"),"deploys\350z\deploy.sqf","",5,false,true,"", ""];
        };
    } else {
        player removeAction s_player_350z;
        s_player_350z = -1;
};
// -------------------------------------- 350z DEPLOY -------------------------------------- 
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

the problem is, that there is no check if the player actually has an engine and a scrap in the main script. you would need to add that check. best would at the same spot, where the check for toolbox is.

_hasengine = "PartEngine" in magazines player;

same for partgeneric.

then

if (toolbox) && (_hasenigne) && ...

you get the idea.

even better would be using bis_fnc_invremove in my opinion.

Link to comment
Share on other sites

  • 0

This will fix it, by removing the parts earlier in the script

 

if !(isNil "isDangerDeploying")exitWith{
    titleText["Already deploying something ...","PLAIN DOWN"];
};
isDangerDeploying = true;
 
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 {
cutText ["\n\nPRESS SPACEBAR TO DEPLOY", "PLAIN DOWN"];
_Offset = [0,5,0]; //change how far from player vehicle spawns
_worldPos = player modelToWorld _Offset; // spawn in front of player
_object = "350z_ruben" createVehicle (_worldPos);
_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];
_object attachTo [player,[-0.2, 5, 1]];
 
waitUntil {deploybike};
_object setVariable ["Deployed", "1", true];
 
//moved removal of required parts here to prevent abuse
player removeWeapon "ItemToolbox";
player removeMagazine "PartEngine";
player removeMagazine "PartGeneric";
 
player playActionNow "Medic";
cutText ["\n\nDeploying vehicle. 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;
};
uiSleep 0.1;
};
r_doLoop = false;
 
if (_finished) then {
 
_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 350z you lazy bum!"], "PLAIN DOWN"];
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
 
uiSleep 10;
 
_object addEventHandler ["GetIn",{
_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned 350z DO NOT SAVE after server restart! ","PLAIN DOWN",5] call RE;
}];
 
} else {
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
        deleteVehicle _object;
cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
};
};
 
isDangerDeploying = nil; 

Link to comment
Share on other sites

  • 0

the problem is, that there is no check if the player actually has an engine and a scrap in the main script. you would need to add that check. best would at the same spot, where the check for toolbox is.

_hasengine = "PartEngine" in magazines player;

same for partgeneric.

then

if (toolbox) && (_hasenigne) && ...

you get the idea.

even better would be using bis_fnc_invremove in my opinion.

It doesnt matter because you can move the toolbox to your backpack and still build the vehicle, so that check doesn't even work. it simply makes sure you have it at the time you select it on your scroll wheel but nothing stops you from deploying it once it's attached to your player.

Link to comment
Share on other sites

  • 0

It doesnt matter because you can move the toolbox to your backpack and still build the vehicle, so that check doesn't even work. it simply makes sure you have it at the time you select it on your scroll wheel but nothing stops you from deploying it once it's attached to your player.

 

 

This will fix it, by removing the parts earlier in the script

 

if !(isNil "isDangerDeploying")exitWith{
    titleText["Already deploying something ...","PLAIN DOWN"];
};
isDangerDeploying = true;
 
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 {
cutText ["\n\nPRESS SPACEBAR TO DEPLOY", "PLAIN DOWN"];
_Offset = [0,5,0]; //change how far from player vehicle spawns
_worldPos = player modelToWorld _Offset; // spawn in front of player
_object = "350z_ruben" createVehicle (_worldPos);
_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];
_object attachTo [player,[-0.2, 5, 1]];
 
waitUntil {deploybike};
_object setVariable ["Deployed", "1", true];
 
//moved removal of required parts here to prevent abuse
player removeWeapon "ItemToolbox";
player removeMagazine "PartEngine";
player removeMagazine "PartGeneric";
 
player playActionNow "Medic";
cutText ["\n\nDeploying vehicle. 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;
};
uiSleep 0.1;
};
r_doLoop = false;
 
if (_finished) then {
 
_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 350z you lazy bum!"], "PLAIN DOWN"];
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
 
uiSleep 10;
 
_object addEventHandler ["GetIn",{
_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned 350z DO NOT SAVE after server restart! ","PLAIN DOWN",5] call RE;
}];
 
} else {
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
        deleteVehicle _object;
cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
};
};
 
isDangerDeploying = nil; 

Link to comment
Share on other sites

  • 0

Ive been thinking something like this would work but I can't seem to find where to place it without breaking the scripts

 

if (!(player hasweapon "ItemToolbox") || !("PartEngine" in (magazines player)) || !("PartGeneric" in (magazines player))) exitWith{titleText ["NO","PLAIN"];};
Link to comment
Share on other sites

  • 0

This will fix it, by removing the parts earlier in the script

 

if !(isNil "isDangerDeploying")exitWith{
    titleText["Already deploying something ...","PLAIN DOWN"];
};
isDangerDeploying = true;
 
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 {
cutText ["\n\nPRESS SPACEBAR TO DEPLOY", "PLAIN DOWN"];
_Offset = [0,5,0]; //change how far from player vehicle spawns
_worldPos = player modelToWorld _Offset; // spawn in front of player
_object = "350z_ruben" createVehicle (_worldPos);
_object setVariable ["ObjectID", "1", true];
_object setVariable ["ObjectUID", "1", true];
_object attachTo [player,[-0.2, 5, 1]];
 
waitUntil {deploybike};
_object setVariable ["Deployed", "1", true];
 
//moved removal of required parts here to prevent abuse
player removeWeapon "ItemToolbox";
player removeMagazine "PartEngine";
player removeMagazine "PartGeneric";
 
player playActionNow "Medic";
cutText ["\n\nDeploying vehicle. 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;
};
uiSleep 0.1;
};
r_doLoop = false;
 
if (_finished) then {
 
_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 350z you lazy bum!"], "PLAIN DOWN"];
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
 
uiSleep 10;
 
_object addEventHandler ["GetIn",{
_nil = [nil,(_this select 2),"loc",rTITLETEXT,"Warning: Spawned 350z DO NOT SAVE after server restart! ","PLAIN DOWN",5] call RE;
}];
 
} else {
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
        deleteVehicle _object;
cutText ["\n\nCanceled deploying vehicle", "PLAIN DOWN"];
};
};
 
isDangerDeploying = nil; 

Someone gave me an idea to just readd them back to the inventory if you move and cancel the script, however even using your fix it isn't removing the items from the inventory soon enough, once the car is attached to the player if you open your inventory they are still in the inventory. I guess I'll try and play around with where that remove items actually belongs.

Link to comment
Share on other sites

  • 0

Someone gave me an idea to just readd them back to the inventory if you move and cancel the script, however even using your fix it isn't removing the items from the inventory soon enough, once the car is attached to the player if you open your inventory they are still in the inventory. I guess I'll try and play around with where that remove items actually belongs.

 

I would suggest then that you should re-write the spawn script as it is getting to the point of being overly complicated and any fixes added will compound other issues.

Link to comment
Share on other sites

  • 0

:huh:

waitUntil {deploybike};
		
if (!("ItemToolbox" in items player) || !("PartEngine" in magazines player) || !("PartGeneric" in magazines player)) exitWith {
	cutText ["\n\nNo parts found!", "PLAIN DOWN"];
	deleteVehicle _object;
	isDangerDeploying = nil;
};
Link to comment
Share on other sites

  • 0

I actually resolved this. You remove the parts before the option to press space bar to deploy appears. Then when you hit space bar it begins deploying however if you move it exits the script and gives you your parts back.

if !(isNil "isDangerDeploying")exitWith{
    titleText["Already deploying something ...","PLAIN DOWN"];
};
isDangerDeploying = true;

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 {
		player removeWeapon "ItemToolbox";
		player removeMagazine "PartEngine";
		player removeMagazine "PartGeneric";
		cutText ["\n\nPRESS SPACEBAR TO DEPLOY", "PLAIN DOWN"];
		_Offset = [0,5,0]; //change how far from player vehicle spawns
		_worldPos = player modelToWorld _Offset; // spawn in front of player
		_object = "350z_ruben" createVehicle (_worldPos);
		_object setVariable ["ObjectID", "1", true];
		_object setVariable ["ObjectUID", "1", true];
		_object attachTo [player,[-0.2, 5, 1]];		

		waitUntil {deploybike};
		_object setVariable ["Deployed", "1", true];
		

		player playActionNow "Medic";
		cutText ["\n\nDeploying 350z. 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 {
		
			_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 350z!"], "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 350z DO NOT SAVE after server restart! ","PLAIN DOWN",5] call RE;
			}];

		
		} else {
		r_interrupt = false;
		player switchMove "";
		player playActionNow "stop";
        deleteVehicle _object;
		cutText ["\n\nCanceled deploying 350z", "PLAIN DOWN"];
	    player addWeapon "ItemToolbox";
		player addMagazine "PartEngine";
		player addMagazine "PartGeneric";
		};
};

isDangerDeploying = nil;

Link to comment
Share on other sites

  • 0

Now you're removing parts that might not exist and still adding those to inventory if it's cancelled. It will work fine if you use what I posted. Although I can see couple other flaws in that. You should lock the vehicle while it's in "preview" or someone can get in it and glitch into bases. Also you can use it for swiping people to death or use it as a shield in combat, so remove the "preview" if player moves.

Link to comment
Share on other sites

  • 0

Now you're removing parts that might not exist and still adding those to inventory if it's cancelled. It will work fine if you use what I posted. Although I can see couple other flaws in that. You should lock the vehicle while it's in "preview" or someone can get in it and glitch into bases. Also you can use it for swiping people to death or use it as a shield in combat, so remove the "preview" if player moves.

 The check for the parts is in the fn_selfactions.sqf. If you dont have the required parts the scroll wheel option will never appear so this is not an issue. Once you press deploy on your scroll wheel it removes the parts. You must press the space bar for the script to go any further, and if you allow it to build your parts are already removed, but if you move and cancel you get the parts back. Works pretty well. I think you might have assumed Im using a button? In which case you are absolutely correct and it would be an issue.

Im not concerned with the preview function since I run a pvp overwatch server,there are no bases, and if you're dumb/bad enough to allow a player to smack you to death with a vehicle, well I hope someone recorded it and posts it online for everyone to have a good laugh at.

 

Thanks for your input though, I'll keep that in mind if I decide to change the script up at some point for whatever reason.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...