Jump to content

Custom Buildings Permanent Vehicle System


Recommended Posts

Rai,

Badies of custom vehicles in custom buildings/bases/maps:

1) - They kill you if you enters it.

2) - If you solved 1). They dissapear at server restart. In other words, they back to the original point with the original status (fuel, loot and damage).

3) - People may get the vehicle, put valious loot in it, and then loose this loot after server restart.

*Glegs Script for vehicles in custom maps*

What is it? Glegs is a new way to spawn vehicles in your custom map. To use it you need to remove the original vehicle spawn entries generated by the map editor and add Glegs vehicle spawn entrie.

The Glegs premisses:

Premisse A: Custom map should spawn fixed vehicles that does not dissapears on server restart.

Glegs acomplishment: OK!

This alone creates a problem: After many servers restarts, you will have many vehicles spawned on the same point since vehicles are now fix and does not dissapears on serve start.

Premisse B On server restarts, new vehicles should spawn only if there is not another vehicle of the same type in a x meters radius arround the spawn point.

Glegs acomplishment: OK!

For Glegs to work, you need to colect 4 informations about the vehicles to spawn in your custom maps:

Vehicles position in map: [x, y, z] Example: [67555.3333, 14320.01333, 0.002]

OBS: if you don't know z, you can leave it as 0 or something positive but small, like 0.02.

Vehicle Classname: The Classname of the Vehicle Example: BRDM2_HQ_TK_GUE_EP1

Vehicle Check Radius: The x in Premisse B. The radius the vehicle need to leave before another one is able to spawn.

Vehicle Direction: The direction the vehicle will face (0 to 360, but any value can be used).

So now you can create the array with your vehicles, ready for Glegs:

Example:

[[x, y, z],"VehicleClassName", Vehicle_Radius_check, Direction]

[[63423, 13264, 0.2],"BRDM2_HQ_TK_GUE_EP1", 30, 90],
[[63646, 13247, 0.2],"SUV_Yellow", 5, -130.9335],
[[33431, 92343, 0.2],"SUV_Black", 5, -30.25],
[[53343, 73244, 0.2],"AW159_Lynx_BAF", 25, -112.3565]
And here is Glegs code:

if (isServer) then {
	_don_veh_data = [

	
	
	];
	{
		if (_forEachIndex == 0) then {sleep 15;};
		if (count ((_x select 0) nearEntities [[_x select 1],_x select 2]) == 0) then {
			_don_veh_obj = createVehicle [_x select 1,_x select 0,[],0,"CAN_COLLIDE"];
			_don_veh_obj setPos _x select 0;
			PVDZE_veh_Publish = [_don_veh_obj,[_x select 3,_x select 0],_x select 1,false,"0"];
			publicVariableServer  "PVDZE_veh_Publish";
		};
	} forEach _don_veh_data;
};	
Just insert your vehicles on the blank area:

if (isServer) then {
	_don_veh_data = [
                [[63423, 13264, 0.2],"BRDM2_HQ_TK_GUE_EP1", 30, 90],
                [[63646, 13247, 0.2],"SUV_Yellow", 5, -130.9335],
                [[33431, 92343, 0.2],"SUV_Black", 5, -30.25],
                [[53343, 73244, 0.2],"AW159_Lynx_BAF", 25, -112.3565]
	];
	{
		if (_forEachIndex == 0) then {sleep 15;};
		if (count ((_x select 0) nearEntities [[_x select 1],_x select 2]) == 0) then {
			_don_veh_obj = createVehicle [_x select 1,_x select 0,[],0,"CAN_COLLIDE"];
			_don_veh_obj setPos _x select 0;
			PVDZE_veh_Publish = [_don_veh_obj,[_x select 3,_x select 0],_x select 1,false,"0"];
			publicVariableServer  "PVDZE_veh_Publish";
		};
	} forEach _don_veh_data;
};	
Important: The last vehicle will not have a "," at the end of the line.

Put this code in the custom map sqf file, at the end of it.

Remove the old vehicles entryes, the ones created by the game editor. They are someting like:

_vehicle_357 = objNull;
if (true) then
{
  _this = createVehicle ["SUV Yellow", [63646, 13247, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_357 = _this;
  _this setDir -130.9335;
  _this setPos [63646, 13247, -3.0517578e-005];
};
_vehicle_357 = objNull;
if (true) then
{
  _this = createVehicle ["SUV Black", [33431, 92343, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_357 = _this;
  _this setDir -30.25;
  _this setPos [33431, 92343, -3.0517578e-005];
};
_vehicle_357 = objNull;
if (true) then
{
  _this = createVehicle ["AW159_Lynx_BAF", [53343, 73244, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
  _vehicle_357 = _this;
  _this setDir -112.3565;
  _this setPos [53343, 73244, -3.0517578e-005];
};
Now your custom map vehicles will be permanent.

RESULTS IN YOUR CUSTOM MAP:

- Permanent Vehicles that persist after server restart.

- You don't die after entering the vehicles.

- When you restart the server, new vehicles only spawn if the spawned vehicles of the previous restart have been moved away.

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...