Vehicle Cruise Control (Server Side Script)

HELLO! I didn't make a post in a while, thought I would share a script I wrote a few weeks ago.
I originally created this for an Altis Life server, having speed limits and 25km one way trips made something like this essential. But I don't see why this can't work on any dayz server - even arma 2 (May need some adjustments in the hints formatting, since the hint box is not as wide in arma 2 as it is in arma 3).


How it works:
There are 4 preset cruising speeds: 50, 70, 120, 160 km/h <you'll need to understand the code and change it yourself if you like>

The vehicle must already be moving +/-5 km/h from the cruising speed so that the jump in velocity isn't that noticeable. From the mouse scroll menu, simply select Cruise Control.
If the vehicle is not within any speed range then a hint message comes up to display the possible cruising speeds.
If the vehicle is within a cruising speed range, then a loop activates that constantly gets the vehicle direction and sets its appropriate velocity. It also checks for vehicle fuel and damaged vehicles.

There is also a key listener that deactivates the cruising speed when the breaks (S) are applied.

cruisecontrol.png


Script Download:
https://github.com/allen-k/Arma3CruiseControl/blob/master/mod_cruiseControl.sqf

Script Install:
This is meant to go server side, so put the file server side.. I'll use the example from altis life, you'll need to figure out the proper path based on the mod your using this script on.

1. Create a folder called "mods" in the root directory of life_server folder.
2. Place the mod_cruiseControl.sqf file into the mods folder
3. In the servers init.sqf file, you'll want to add this line at the end of the file:
// cruise control
[] execVM "\life_server\mods\mod_cruiseControl.sqf";
4. In the Mission side of things, edit the init.sqf, at the end of the file add:
// mod cruise control
call mod_cruiseControl;

Lastly:
enjoy!
Also let me know if any of you try it out in Arma 2, and if the hints need to be adjusted due to text size.

EDIT!!!!! FOR ARMA 2 YOU NEED TO CHANGE THE FONT FOR THE HINTS!
change all instances of puristaLight and puristaMedium to Bitstream
 
i got an error now in my altis life setup...
its working... but still getting an error...

Code:
16:50:01 Error in expression <{isNull (findDisplay 49)};
};
};


call mod_cruiseControl;>
16:50:01   Error position: <mod_cruiseControl;>
16:50:01   Error Undefined variable in expression: mod_cruisecontrol
16:50:01 File mpmissions\Altis_Life.Altis\init.sqf, line 49
 
It could be your server variables aren't being initialized fast enough.. (mp mission loads before server sends variables)

on the mpmission side, you'd want to add something like this:

waitUntil { !isNil "mod_cruiseControl" }; <- double check the syntax, I didn't do anything with arma for a few months now.
 
yeah.... this seems to work ^^

Code:
// mod cruise control
waitUntil {!isNil "mod_cruiseControl"};
call mod_cruiseControl;

no error message so far...
 
Gagi2, A better way would be something like this:

spawn[] <- check the exact syntax of this, I dont remember exactly
{
waitUntil {!isNil "mod_cruiseControl"};
call mod_cruiseControl;
}

That way, any code afterwards isn't being held up if it doesn't have to.
 
it should be
Code:
[] spawn
{
waitUntil {!isNil "mod_cruiseControl"};
call mod_cruiseControl;
};
then i guess?

its the last entry in my init.sqf so its fine for the moment.. but i will try it this way...
 
ahhaaaaa it is not breaking or stopping with S..
Helllp even if i shutdown the engine it still cruising like a electric car
 
Back
Top