Jump to content
Sign in to follow this  
zooloo75

Does it exist? : Drivebys

Recommended Posts

I am wondering if there's a driveby script -- I searched but couldn't find any. I just created a driveby system where players can shoot out of vehicles.

If no such script has been made yet, I am willing to release mine for someone to possibly make a mod out of it (it could use some proper sitting animations that allow the player to shoot).

----

I built this for my Chernarus Life server.

Init.sqf

driveby = 0;
facingBack = 0;
facingFront = 0;
facingLeft = 0;
facingRight = 0;
driveByCar = objnull;
onKeyPress = compile preprocessFile "onKeyPress.sqf";
waituntil {!(IsNull (findDisplay 46))};
(findDisplay 46) displaySetEventHandler ["KeyDown", "_this call onKeyPress"];

onKeyPress.sqf

private["_handled", "_faceCP", "_faceVP"];

_key     = _this select 1;
_shift   = _this select 2;
_handled = false;

switch _key do

{
case 14:
{
	if(driveBy == 1) exitwith 
	{
	_nearCars = nearestobjects [player,["landvehicle"],10];
	detach player;
	driveBy = 0;
	player moveincargo (_nearCars select 0);
	facingBack = 0;
	facingFront = 0;
	facingLeft = 0;
	facingRight = 0;
	_handled = true;
	};
	if(driveBy == 0 && vehicle player != player) exitwith 
	{
	facingBack = 0;
	facingFront = 1;
	facingLeft = 0;
	facingRight = 0;
	execVM "driveby.sqf";
	_handled = true;
	};
};

case 19:
{
	if(driveBy == 0) exitwith {};
	reload player;
	_handled = true;
};

case 16:
{
	if(driveBy == 0 || facingBack == 1) exitwith {};
	facingBack = 1;
	facingFront = 0;
	facingLeft = 0;
	facingRight = 0;
	player setdir 180;
	_handled = true;
};

case 18:
{
	if(driveBy == 0 || facingFront == 1) exitwith {};
	facingBack = 0;
	facingFront = 1;
	facingLeft = 0;
	facingRight = 0;
	player setdir 0;
	_handled = true;
};

case 45:
{
	if(driveBy == 0 || facingLeft == 1) exitwith {};
	facingBack = 0;
	facingFront = 0;
	facingLeft = 1;
	facingRight = 0;
	player setdir -90;
	_handled = true;
};

case 46:
{
	if(driveBy == 0 || facingRight == 1) exitwith {};
	facingBack = 0;
	facingFront = 0;
	facingLeft = 0;
	facingRight = 1;
	player setdir 90;
	_handled = true;
};
};

_handled;

Driveby.sqf

//STEALTHSTICK==ZOOLOO75 - THE FIRST PERSON TO EVER CREATE A WORKING DRIVEBY SYSTEM IN ARMA.
_vcl = vehicle player;
driveByCar = _vcl;
if(driver vehicle player == player) exitwith {player allowdamage true;};
//People in the vehicle and calculations
_crewSlot = crew vehicle player;
_mySlot = _crewSlot find player; 
//player groupchat format ["%1",_mySlot];
if (_mySlot > 3) exitwith {hint "You cannot perform a driveby in this seat.";player allowdamage true;};
if (_mySlot == 0) exitwith {hint "You cannot perform a driveby without a driver.";player allowdamage true;};
////////////////////////////////
//Supported Vehicle check
_supported = [
"TT650_Base",
"SUV_Base_EP1",
"Lada_base",
"SkodaBase",
"VWGolf",
"UAZ_Base",
"M1030",
"ATV_Base_EP1",
"LandRover_Base",
"S1203_TK_CIV_EP1",
"UAZ_Unarmed_Base", 
"Volha_TK_CIV_Base_EP1",
"ATV_US_EP1",
"car_sedan"
];

//if !((typeof _vcl) in _supported) exitwith {hint "This vehicle is not supported for drivebys (yet!)";};

player allowdamage false;
_oldVel = velocity driveByCar;
format['%1 setvelocity [0,0,0];', driveByCar] call broadcast;
driveByCar setvelocity [0,0,0];

//Vehicle checks
if(_vcl iskindof "TT650_Base") then {moveout player; player attachto [_vcl,[-0.1,-0.3,-1]];};

if(_vcl iskindof "M1030") then {moveout player; player attachto [_vcl,[-0.1,-0.3,-1]];};

if(_vcl iskindof "SUV_Base_EP1") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.75,-0.25,-0.95]];}; if(_mySlot == 2) then { player attachto [_vcl,[0.75,-1,-0.95]];}; if(_mySlot == 3) then { player attachto [_vcl,[-0.85,-1,-0.95]];};};

if(_vcl iskindof "Lada_base") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.55,0.25,-1.3]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.5,-1.3]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.55,-0.5,-1.3]];};};

if(_vcl iskindof "SkodaBase") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.4,0,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.65,-0.8,-1.35]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.4,-0.8,-1.35]];};};

if(_vcl iskindof "VWGolf") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.6,0.2,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.7,-1.35]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.6,-0.7,-1.35]];};};

if(_vcl iskindof "UAZ_Unarmed_TK_CIV_EP1") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.6,0,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.5,-1.35]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.6,-0.5,-1.35]];};};

if(_vcl iskindof "UAZ_Unarmed_Base") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.6,0,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.5,-1.35]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.6,-0.5,-1.35]];};};

if(_vcl iskindof "UAZ_Base") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.6,0,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.5,-1.35]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.6,-0.5,-1.35]];};};

if(_vcl iskindof "ATV_Base_EP1") then {moveout player; player attachto [_vcl,[0.0,-0.7,-0.85]];};

if(_vcl iskindof "LandRover_Base") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.7,0.4,-0.9]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.6,-0.5,-0.9]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.6,-0.5,-0.9]];};};

if(_vcl iskindof "S1203_TK_CIV_EP1") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.85,1.1,-1]];}; if(_mySlot == 2) then { player attachto [_vcl,[0.85,0.1,-1]];}; if(_mySlot == 3) then { player attachto [_vcl,[-0.35,0.1,-1]];};};

if(_vcl iskindof "Volha_TK_CIV_Base_EP1") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.55,0.1,-1.25]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.55,-0.6,-1.25]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.55,-0.6,-1.25]];};};

if(_vcl iskindof "car_sedan") then {moveout player; if(_mySlot == 1) then { player attachto [_vcl,[0.55,0,-1.35]];}; if(_mySlot == 2) then { player attachto [_vcl,[-0.7,-0.6,-1.25]];}; if(_mySlot == 3) then { player attachto [_vcl,[0.55,-0.6,-1.25]];};};

driveby = 1;
player switchmove "amovpknlmstpsraswrfldnon";
format['%1 switchmove "amovpknlmstpsraswrfldnon";', player] call broadcast;
player groupchat "Press Backspace to get out of driveby mode.";
hintsilent "Press Backspace to get out of driveby mode.";
sleep 2;
format['%1 setvelocity %2', driveByCar, _oldVel] call broadcast;
player allowdamage true;
while{driveby == 1} do {if !(alive player) exitwith {player allowdamage true;};INV_shortcuts = false; if((animationState player) != "amovpknlmstpsraswrfldnon") then {player playmove "amovpknlmstpsraswrfldnon"}; sleep 2;};

Edited by zooloo75

Share this post


Link to post
Share on other sites

It's been done by Shactac for littlebirds, check the 2nd video:

http://www.armaholic.com/page.php?id=16497

At it's most basic you need to put an addaction on the vehicle that sets the player in a sitting animation and then use attachTo to put them in the right place.

http://community.bistudio.com/wiki/ArmA2:_Moves

http://community.bistudio.com/wiki/attachTo

Share this post


Link to post
Share on other sites

That's the only addon I know that does it, but it's for the LB. I made one for cars.

The passengers of a vehicle can press Backspace to enter driveby mode. It does an attachto, placing them at predefined points which I had to make for almost all of the base classnames for cars. It works flawlessly. It puts the player in a kneeling animation, (but I don't know how to force the player to stay like that and not go prone. I put an eventhandler for the keypress of the Z key, but for some reason it won't block that key. I also put a while do loop that runs every 2 seconds that puts them back into the kneel position, it works, but that effect isn't visually pleasing.), the player then uses Q and E to look back and forth, X and C to look left and right, and R to reload.

They then press backspace again to get back into a cargo seat of their vehicle.

The system works though.

If anyone would like to see the code, then I'd be happy to pretty it up and paste it here.

Share this post


Link to post
Share on other sites

Wouldnt mind seeing the code mate!! Or you could pm me the sqf file!

Thanks

Share this post


Link to post
Share on other sites
Wouldnt mind seeing the code mate!! Or you could pm me the sqf file!

Thanks

Edited first post :)

Share this post


Link to post
Share on other sites

AFAIK Shacktac also has a working drive-by system for vehicles such as the Humvee but they haven't released it yet. Dunno who created that though.

Share this post


Link to post
Share on other sites

I´ve tried to insert the script into a random editor mission, but it didn´t work.

when i press backspace nothing happens. I think the key isnt defined?

EDIT: can you explain to me how to correctly insert it / start it in the editor?

Edited by lennist

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  

×