Jump to content
  • 0

Spawning Vehicles via SQF file


Ferdinand das Frettchen

Question

Hey,

I'm trying to spawn Vehicles via SQF file so that they will be back every Server restart.

 

The vehicles I spawn like this:

_vehicle_1 = objNull;
if (true) then
{
  _this = createVehicle ["VEHICLEXYZ", [15286.053, 80.74379, 529.44104], [], 0, "CAN_COLLIDE"];
  _vehicle_1 = _this;
  _this setDir 89.986031;
  _this setPos [15286.053, 80.74379, 529.44104];
};

Just like you would a normal object like a house or a supermarket.

 

The vehicle is there I can get in and fly/drive it but if it takes any damage even if someone with a makarov shoots it it will just dissapear and I will get the animation you do when you exit the vehicle. I guess it's because it's not in the Database and when it takes damage that triggers and eventhandler which checks to see if the vehicle is valid which it isn't so it just gets rid of it.

 

I already tried editing the DayZ_Server.pbo/server_updateObject.sqf

 

and I edited the following line:

//Check if object has an ignore flag, set to false as the default//
_ignoreThis =_object getVariable ["ignoreThis",false];
if (_ignoreThis) exitWith {};

if ((typeName _objectID != "string") || (typeName _uid != "string")) then
{
    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
    //force fail
    _objectID = "0";
    _uid = "0";
};
if (!_parachuteWest) and !(locked _object)) then {
    if (_objectID == "0" && _uid == "0") then
    {
        _object_position = getPosATL _object;
            diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",
            typeOf _object,
            _object_position select 0,
            _object_position select 1,
            _object_position select 2]);
            _isNotOk = true;
    };
};

// do not update if buildable and not ok
if (_isNotOk and _isbuildable) exitWith {  };

// delete if still not ok
if (_isNotOk) exitWith { deleteVehicle _object; };

Anyone got any idea which server files I would have to edit to stop it from checking if the vehicle is valid or maybe that it just ignores that it is invalid and let's it "exist".

 

Would be glad if anyone could help!

Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

You need to stop the server cleanup from deleting the vehicles. Have a look at sarge ai and how that stops the cleanup from deleting stuff. Once I get home I will give you a more in depth explanation.

It is defo possible though, got it on my server.

Link to comment
Share on other sites

  • 0

You need to stop the server cleanup from deleting the vehicles. Have a look at sarge ai and how that stops the cleanup from deleting stuff. Once I get home I will give you a more in depth explanation.

It is defo possible though, got it on my server.

 

i have tried but everytime i want to edit my server files, i have "authentication"-problem and cant join the server anymore :(

 

Link to comment
Share on other sites

  • 0

I'm encountering a similar issue, the vehicles that are spawned in with this tool last approximately 10 seconds before being deleted. From what I've researched, it seems like a fairly common issue, but has no common fixes. We're using Epoch 1.0.1.5, sarge ai and several other mods - everything else in the script is working correctly. I didn't really change anything in regards to the sarge stuff that needed to be changed, since sarge is working perfectly on our server already. Is there something else that I should be looking for with Epoch that could be cleaning this up?

 

The only reference to this error that I can find is in the part that says:

 

if (!_parachuteWest) and !(locked _object)) then {

    if (_objectID == "0" && _uid == "0") then

    {

        _object_position = getPosATL _object;

            diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",

            typeOf _object,

            _object_position select 0,

            _object_position select 1,

            _object_position select 2]);

            _isNotOk = true;

    };

};

 

Would commenting all that out simply resolve the issue?

 

our servers RPT file shows 'Deleting Object [objectname] with invalid ID and pos [worldspace coords]' then keeps spamming an 'Object not found' error once in a while till server restart.

 

Whlie the object has disappeared, I can actually still go up and interact with the invisible object for a while if that helps.

Also - I should clarify that I'm using the Pheonix Admin tools scripts to spawn these vehicles

Link to comment
Share on other sites

  • 0

Look at the admin tools readme, the parachutewest change stops spawned in vehicles from despawning until restart. Bear in mind if you are also running SargeAI any AI helicopters that are shot down can be repaired and used by players until restart, at least it did with my one.

 

Dayz_server.pbo-->dayz_server\compile\server_updateObject.SQF

 

if (!_parachuteWest and !(locked _object)) then {
if (_objectID == "0" && _uid == "0" && (vehicle _object getVariable ["Sarge",0] != 1)) then 
{
_object_position = getPosATL _object;
    _isNotOk = true;
};
};

 

 

The above fixed the heli spawn in from admin tools disappearing for me. The vehicles that were despawning tended to be non-DayZ vehicles such as the Apache. 

Link to comment
Share on other sites

  • 0

You need to stop the server cleanup from deleting the vehicles. Have a look at sarge ai and how that stops the cleanup from deleting stuff. Once I get home I will give you a more in depth explanation.

It is defo possible though, got it on my server.

hi marca,

 

i'm trying something different, i have SargeAI installed on my 2 Epoch Server's. If Player shoot the Helicopter Patrols, so AI tries to Land, but after they land helicopter are despawns. Did you have any suggestion to prevent this ?

 

Thanks & Regards

Link to comment
Share on other sites

  • 0

Sorry for bumping an old thread but i have a problem, the vehicles spawn in fine, they work fine until you put an item in them, if you put anything in it then come out of the gear the vehicle will disappear (visibly) but the options to get in, repair/salvage, load and tow are still there just when you hit get in it will do the "get in" animation and nothing else happens, the options still come up though no matter what you do, i tried what Firefly said but it makes no difference, i'm running epoch 1.0.4.2 and WAI (WickedAI) but as for the vehicle spawning with WAI there is no adjustments to be made to server_updateObject.sqf

Link to comment
Share on other sites

  • 0

@KamikazeXeX

 

I don't use, nor ever have, used WAI but I can help you.

Find the part of WAI that spawns the vehicles in and if it's not already there put this in just after where it spawns the vehicle

_vehicle setVariable ["Sarge",true,true];

where '_vehicle' is the variable the vehicle is stored in, it may have a different name but I'm sure you can find it.

next, go into your 'server_functions.sqf' and go to line 796 where you'll find this -

server_checkHackers = {
	if (DZE_DYN_AntiStuck2nd > 3) then { DZE_DYN_HackerCheck = nil; DZE_DYN_AntiStuck2nd = 0; };
	if(!isNil "DZE_DYN_HackerCheck") exitWith {  DZE_DYN_AntiStuck2nd = DZE_DYN_AntiStuck2nd + 1;};
	DZE_DYN_HackerCheck = true;
	{
		if(vehicle _x != _x && !(vehicle _x in PVDZE_serverObjectMonitor) && (isPlayer _x)  && !((typeOf vehicle _x) in DZE_safeVehicle)) then {
			diag_log ("CLEANUP: KILLING A HACKER " + (name _x) + " " + str(_x) + " IN " + (typeOf vehicle _x));
			(vehicle _x) setDamage 1;
			_x setDamage 1;
			sleep 0.25;
		};
		sleep 0.001;
	} forEach allUnits;
	DZE_DYN_HackerCheck = nil;
};

now, change line 801 to this -

if(vehicle _x != _x && !(vehicle _x in PVDZE_serverObjectMonitor) && (isPlayer _x)  && !((typeOf vehicle _x) in DZE_safeVehicle) && !((vehicle _x) getVariable ["Sarge",false])) then {

thios should stop your issues with WAI spawned vehicles

Link to comment
Share on other sites

  • 0

@KamikazeXeX

 

I don't use, nor ever have, used WAI but I can help you.

Find the part of WAI that spawns the vehicles in and if it's not already there put this in just after where it spawns the vehicle

_vehicle setVariable ["Sarge",true,true];

where '_vehicle' is the variable the vehicle is stored in, it may have a different name but I'm sure you can find it.

next, go into your 'server_functions.sqf' and go to line 796 where you'll find this -

server_checkHackers = {
	if (DZE_DYN_AntiStuck2nd > 3) then { DZE_DYN_HackerCheck = nil; DZE_DYN_AntiStuck2nd = 0; };
	if(!isNil "DZE_DYN_HackerCheck") exitWith {  DZE_DYN_AntiStuck2nd = DZE_DYN_AntiStuck2nd + 1;};
	DZE_DYN_HackerCheck = true;
	{
		if(vehicle _x != _x && !(vehicle _x in PVDZE_serverObjectMonitor) && (isPlayer _x)  && !((typeOf vehicle _x) in DZE_safeVehicle)) then {
			diag_log ("CLEANUP: KILLING A HACKER " + (name _x) + " " + str(_x) + " IN " + (typeOf vehicle _x));
			(vehicle _x) setDamage 1;
			_x setDamage 1;
			sleep 0.25;
		};
		sleep 0.001;
	} forEach allUnits;
	DZE_DYN_HackerCheck = nil;
};

now, change line 801 to this -

if(vehicle _x != _x && !(vehicle _x in PVDZE_serverObjectMonitor) && (isPlayer _x)  && !((typeOf vehicle _x) in DZE_safeVehicle) && !((vehicle _x) getVariable ["Sarge",false])) then {

thios should stop your issues with WAI spawned vehicles

I'm not sure if you've taken this as i'm using WAI to spawn the vehicles or not but i'm actually loading in vehicles via the server side pbo the same way i load in my custom map addons, all my WAI spawned vehicles function as they should but i'm doing this via server_functions, i just wasn't sure as to whether WAI was the problem, either way i just need static vehicle spawn locs and the vehicles to return to that location upon resart, its for player base vehicles that they can use to get out and about and transport gear back to their base, it doesn't need to save to db it just needs to be functioning transport and return to its origin co-ords after a restart

Link to comment
Share on other sites

  • 0

 

 

Would be glad if anyone could help!

 

In my server i make new folder called bases and inside i make the file tanks.sqf  inside file:

if (isServer) then {
private ["_object","_uniqueid"];

_vehicle_43 = objNull;
if (true) then
{
  _object = createVehicle ["T34", [13658.459, 3070.2783, -0.00037479401], [], 0, "CAN_COLLIDE"];
  _vehicle_43 = _object;
  _object setPos [13658.459, 3070.2783, -0.00037479401];
  _object setVariable ["malsar",1,true];
  _uniqueid = str(round(random 999999));
  _object setVariable ["ObjectID", _uniqueid, true];
  _object setVariable ["ObjectUID", _uniqueid, true];
};

_vehicle_44 = objNull;
if (true) then
{
  _object = createVehicle ["T34", [13661.459, 3091.2783, -0.00037479401], [], 0, "CAN_COLLIDE"];
  _vehicle_44 = _object;
  _object setPos [13661.459, 3091.2783, -0.00037479401];
  _object setVariable ["malsar",1,true];
  _uniqueid = str(round(random 999999));
  _object setVariable ["ObjectID", _uniqueid, true];
  _object setVariable ["ObjectUID", _uniqueid, true];
};
};

and in the end of init.sqf  this one [] execVM "bases\tanks.sqf";

 

 

So tanks spawn after restart same place, can be destroyed, Cleaned up after restart and spawn back again.

In my case its a tank, but you can spawn what u want.

 

b_560_95_1.png

Link to comment
Share on other sites

  • 0

 

In my server i make new folder called bases and inside i make the file tanks.sqf  inside file:

if (isServer) then {
private ["_object","_uniqueid"];

_vehicle_43 = objNull;
if (true) then
{
  _object = createVehicle ["T34", [13658.459, 3070.2783, -0.00037479401], [], 0, "CAN_COLLIDE"];
  _vehicle_43 = _object;
  _object setPos [13658.459, 3070.2783, -0.00037479401];
  _object setVariable ["malsar",1,true];
  _uniqueid = str(round(random 999999));
  _object setVariable ["ObjectID", _uniqueid, true];
  _object setVariable ["ObjectUID", _uniqueid, true];
};

_vehicle_44 = objNull;
if (true) then
{
  _object = createVehicle ["T34", [13661.459, 3091.2783, -0.00037479401], [], 0, "CAN_COLLIDE"];
  _vehicle_44 = _object;
  _object setPos [13661.459, 3091.2783, -0.00037479401];
  _object setVariable ["malsar",1,true];
  _uniqueid = str(round(random 999999));
  _object setVariable ["ObjectID", _uniqueid, true];
  _object setVariable ["ObjectUID", _uniqueid, true];
};
};

and in the end of init.sqf  this one [] execVM "bases\tanks.sqf";

 

 

So tanks spawn after restart same place, can be destroyed, Cleaned up after restart and spawn back again.

In my case its a tank, but you can spawn what u want.

 

b_560_95_1.png

Hey, its only just come to my attention but when i add _object setDir 64.111; for example just above setPos vehicles will no longer spawn in, is there any way that I can change the direction of the vehicles?

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