Vehicle saving

  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2536

Vehicle saving

« posted: May 23, 2014, 06:21 PM »
So, a lot of people have been asking for vehicle saving to be implemented in the official version, therefore I would like to address this topic.

The main problem isn't isn't how to code it, but rather, deciding when saved vehicles are to be deleted.

As most of you already know, more vehicles = lag. Anyone can capture and buy any number of vehicles, therefore we can't allow all vehicles to be saved indefinitely like Breaking Point, which caps vehicle spawning to a certain quantity.

I have no idea about when saved vehicles should be deleted, so instead I am asking everyone: what rule(s) should be defined to limit the number of saved vehicles?

We could impose a quota, like max 1 vehicle saved per player, we could have a maximum lifetime like baseparts, depending on when the vehicle was created or the last time that someone got in, we could limit saving to specific vehicle types only, etc... It can be anything, simply suggest what restriction(s) should be put in place. Once we have something that we agree on, then I'll be able to implement it very easily.

Town vehicles will be excluded from saving, as a full rework of the respawning script is necessary before I consider anything in that regard.
  • Offline Jumbo
  • First Blood
  • ***
  • Posts: 82

Re: Vehicle saving

« Reply #1 posted: May 23, 2014, 07:04 PM »
An option might be to save a vehicle if the engine is off and the driver and owner (purchaser) presses escape. That way if he quits, the vehicle is removed and when he returns, the vehicle respawns with him. I could see that being abused though and it would be hard to tell if someone has teleported or hacked a vehicle in.

How about forcing players to go to a vehicle store, warchest or spawn beacon to recover their vehicle? That way when they logout, their saved vehicle disappears with them? Although if someone steals your vehicle and you quit out it would be a problem since your vehicle would disappear from under them :)

If you transfer ownership when someone steals a vehicle then it could lead to griefing as someone could hop in your car and log out with your car. Perhaps its best if a bought vehicle is automatically locked to the purchaser and no one can steal it? Maybe their is a better way?

As a group player I think one vehicle per player is plenty but the option to have at least two vehicles would keep the lone wolves happy.
  • Offline Jumbo
  • First Blood
  • ***
  • Posts: 82

Re: Vehicle saving

« Reply #2 posted: May 23, 2014, 07:16 PM »
I suppose if someone kills you then they should be entitled to steal your vehicle
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2536

Re: Vehicle saving

« Reply #3 posted: May 23, 2014, 07:30 PM »
As I said, I am not adding private banking of any kind, even for vehicles, so all saved vehicles are to remain spawned at all times until destroyed or deleted.

Persistent vehicle locking will not be added. I will eventually make it possible to lock vehicles if you are close to it, but the lock will deactivate if you move too far or disconnect.

Remember, this is survival, not an RPG. If people can store/hide/lock their valuables away from everyone else, then the element of risk is greatly diminished, and organized groups of server regulars will become overpowered very fast. In short, it's all for the sake of balance.
  • Offline pippen
  • Wasteland Warrior
  • First Blood
  • ***
  • Posts: 72

Re: Vehicle saving

« Reply #4 posted: May 23, 2014, 11:50 PM »
1 vehicle save per player, can only be saved for 2 server reboots or a option to change this perhaps. Only problem I see is people saving the main battle tanks and other powerful military vehicles and dominating the map (which is part of the game) So that being said a option to pick the time allowed for saving would be great. I would like the vehicles to be saved where they are and spawn back where they were saved, it will limit them to have to travel to their saved vehicle instead of them saving it near a saved vehicle respawn area, logging out then coming back in shortly after and dominating everyone, then doing the same over and over (combat logging type abuse). I'm always trying to balance my server...so my needs and opinions may be different than others  :P
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2536

Re: Vehicle saving

« Reply #5 posted: May 24, 2014, 01:24 AM »
I would like the vehicles to be saved where they are and spawn back where they were saved, it will limit them to have to travel to their saved vehicle instead of them saving it near a saved vehicle respawn area

Well, I think one of the main purposes of vehicle saving would be being able to pick up where you left off if the server restarts in the middle of a session, because let's be honest, you can't expect to find your vehicle where you left it if you're gone for anything more than a couple hours, unless there's someone protecting it, it's in a low pop server, or it's not valuable.
  • Offline NiiV
  • Geared Up
  • **
  • Posts: 40

Re: Vehicle saving

« Reply #6 posted: May 24, 2014, 05:44 PM »
What about a "vehicle beacon" something like:
-Buy beacon in store
-Place beacon in your base
-At each server restart on the beacon spawning vehicles by type
  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2536

Re: Vehicle saving

« Reply #7 posted: May 24, 2014, 05:47 PM »
What about a "vehicle beacon" something like:
-Buy beacon in store
-Place beacon in your base
-At each server restart on the beacon spawning vehicles by type

I'm not sure I understand... Besides, I'm not asking for a method to save vehicles, I'm asking for restrictions on the saving itself. People will be able to save a vehicle from anywhere without extra stuff.

Re: Vehicle saving

« Reply #8 posted: May 24, 2014, 08:15 PM »
I use your object saving script with some modifications where all vehicles with a variable containing the UID saves and saves for the same time as the objects on the map. As of now, after more that a month i have 65 vehicles saved around the map. But i guess a higher pop severe would have much more, i have 15-40 players a day i think, many of them regulars. They cannot lock their vehicles at all and players seem to make an effort to find each others bases and raid them for valuables as i allow for selling the vehicles too (ugly script, don't ask ;-) ). thus keeping the vehicles within tolerable amounts. i also provide a way to make vehicles savable also by using an ugly hack on a reloading script which cost different depending on the vehicle type/model.

For vehicles i would like to see.

  • Savable for a limited amount of time you as the admin can set in the main_config but i would like to see this timer reset if the vehicle is used or maybe refueled/repaired with the universal kit (should take some effort to keep it).
  • One or maybe two vehicles per player, if possible something you can set in the main_config. Personally i think 2, i would want one chopper and one land vehicle or boat.
  • Lockable, i like what AgentRev said about the player have to bee withing a certain range but i hope its possible to add time here too for sudden disconnects, not much say 10 minutes, again if you can set it youself you can tune it to what the players like and what works best for the server.

But when we talk about vehicles i remember someone mentioning a hackingtool for unlocking, also i had some lame idea of a lojack for recovering your vehicle if stolen or forgotten (its damn hard to find em in those reeds sometimes =) ). Could also be used for finding enemy bases and as i usually tack on some explosives to my vehicles its fun to see someone steal my vehicle run into their base and.... well.
  • Offline bodybag
  • Hardened
  • ****
  • Posts: 109
  • Gameaholic.se

Re: Vehicle saving

« Reply #9 posted: Jun 01, 2014, 05:03 AM »
I say one vehicle saved per player and you lose it if you die or get it destroyed.

  • Offline AgentRev
  • Developer
  • Veteran
  • ******
  • Posts: 2536

Re: Vehicle saving

« Reply #10 posted: Jun 01, 2014, 05:23 AM »
I say one vehicle saved per player and you lose it if you die or get it destroyed.

I'm not sure what's the point of vehicle saving if the car despawns when you die.
  • Offline bodybag
  • Hardened
  • ****
  • Posts: 109
  • Gameaholic.se

Re: Vehicle saving

« Reply #11 posted: Jun 04, 2014, 06:17 PM »
I mean when you die you loose all your money and Equipment, this  include your vehicle. The car can still be there, but you loose the claim of it, like a car key?

Re: Vehicle saving

« Reply #12 posted: Jun 05, 2014, 05:18 AM »
I would like a script that will save all vehicles just like with objects and crates but limit it to one or two vehicles per UID. If the player is killed the vehicle will no longer be saved and be gone after the server restarts in less they save it again.  Also a command like "A3W_objectLifetime = 5*24" but for vehicles would be cool. 

I've noticed with the current iniDBI vehicles save scripts that are out there after a restart the "Tow to a vehicle" option no longer works.  Also I don't know how you would implement this with the UAV or UGV and have it work after a server restart.
  • Offline CREAMPIE
  • Armaholic
  • Veteran
  • ******
  • Posts: 1078
  • ^_^;;

Re: Vehicle saving

« Reply #13 posted: Jun 05, 2014, 08:58 AM »
I'm using a variant of Cael's mission file with vehicle saving - for the most part people buy and save their vehicles on the server , I think there's rougly ~50 saved vehicles in play which are there until they are destroyed, thus no limit to UID or duration.

I have greatly reduced the default spawn vehicles on the server and messed with loot that spawns in houses and the vehicles themselves, to only include basic rifles , scopes and items to even out the server load.

There are never more than about 200 vehicles in total on the server and yes , players make an effort to destroy each others bases / vehicles. We have about 4 choppers and 10 vehicles in our base permanently that we bought and saved or replenish when n00bie crashes one ><.

People don't like starting over every time - saving vehicles / player data , warchests encourages players to work and assault as a team.

I am also in the process of increasing alot of the prices on high end vehicles and gear to bring them in line with the money earned. Players need to play to get cash, do the objectives and plan their attacks :D


- from the grassy knoll -

Re: Vehicle saving

« Reply #14 posted: Aug 04, 2014, 04:15 PM »
I'm using a variant of Cael's mission file with vehicle saving - for the most part people buy and save their vehicles on the server

Could you share where to find his mission file and or how he does it? I really want to get vehicle saving implemented on my A3wasteland server.

I tried doing it on my own by extracting one of the servers that uses vehicle saving. Digging through the files I found that in the /persistence/world folder there were 2 files not contained in the main Dev branch Veh_oLoad.sqf and Veh_oSave.sqf.  I added these files to the persistence/world but in testing it does not give me the "save vehicle" scroll menu option when I walk up to a vehicle (as I saw on their server). Any idea what I'm missing/ need to change in some other file.

Or anyone else have a better way/ example / tutorial on how to add vehicle saving to the main branch

Thanks!

Q


Veh_oLoad.sqf
Code: [Select]
// @file Version: 1.2
// @file Name: oLoad.sqf
// @file Author: JoSchaap, AgentRev, Austerror
// @file Description: Basesaving load script

if (!isServer) exitWith {};

#include "functions.sqf"

_strToSide =
{
switch (toUpper _this) do
{
case "WEST":  { BLUFOR };
case "EAST":  { OPFOR };
case "GUER":  { INDEPENDENT };
case "CIV":   { CIVILIAN };
case "LOGIC": { sideLogic };
default       { sideUnknown };
};
};
/*
_isWarchestEntry = { [_variables, "a3w_warchest", false] call BIS_fnc_getFromPairs };
_isBeaconEntry = { [_variables, "a3w_spawnBeacon", false] call BIS_fnc_getFromPairs };
*/
_maxLifetime = ["A3W_objectLifetime", 0] call getPublicVar;
//_filename2 = Veh;
_exists = _filename2 call iniDB_exists;
_objectsCount = 0;

if (!isNil "_exists" && {_exists}) then
{
_objectsCount = [_filename2, "Info", "ObjCount", "NUMBER"] call iniDB_read;

if (!isNil "_objectsCount") then
{
for "_i" from 1 to _objectsCount do
{
_objName = format ["Veh%1", _i];

_class = [_filename2, _objName, "Class", "STRING"] call iniDB_read;
_pos = [_filename2, _objName, "Position", "ARRAY"] call iniDB_read;
_hoursAlive = [_filename2, _objName, "HoursAlive", "NUMBER"] call iniDB_read;

if (!isNil "_class" && {!isNil "_pos"} && {_maxLifetime <= 0 || {_hoursAlive < _maxLifetime}}) then
{
_variables = [_filename2, _objName, "Variables", "ARRAY"] call iniDB_read;

_allowed = switch (true) do
{
//case (call _isWarchestEntry): { _warchestSavingOn };
//case (call _isBeaconEntry):   { _beaconSavingOn };
//case (_class call _isBox):    { _boxSavingOn };
default                       { _baseSavingOn };
};

if (_allowed) then
{
_dir = [_filename2, _objName, "Direction", "ARRAY"] call iniDB_read;
_damage = [_filename2, _objName, "Damage", "NUMBER"] call iniDB_read;
_allowDamage = [_filename2, _objName, "AllowDamage", "NUMBER"] call iniDB_read;

_obj = createVehicle [_class, _pos, [], 0, "CAN_COLLIDE"];
_obj setPosATL _pos;

if (!isNil "_dir") then
{
_obj setVectorDirAndUp _dir;
};

_obj setVariable ["baseSaving_hoursAlive", _hoursAlive];
_obj setVariable ["baseSaving_spawningTime", diag_tickTime];
_obj setVariable ["objectLocked", true, true]; // force lock

if (_allowDamage > 0) then
{
_obj setDamage _damage;
_obj setVariable ["allowDamage", true];
}
else
{
_obj allowDamage false;
};

{
_var = _x select 0;
_value = _x select 1;

switch (_var) do
{
case "side": { _value = _value call _strToSide };
case "ownerName": { _value = _value call iniDB_Base64Decode };
};

_obj setVariable [_var, _value, true];
} forEach _variables;

clearWeaponCargoGlobal _obj;
clearMagazineCargoGlobal _obj;
clearItemCargoGlobal _obj;
clearBackpackCargoGlobal _obj;

_unlock = switch (true) do
{
case (_obj call _isWarchest): { true };
case (_obj call _isBeacon):
{
[pvar_spawn_beacons, _obj] call BIS_fnc_arrayPush;
publicVariable "pvar_spawn_beacons";
true
};
default { false };
};

if (_unlock) exitWith
{
_obj setVariable ["objectLocked", false, true];
};

if (_boxSavingOn) then
{
_weapons = [_filename2, _objName, "Weapons", "ARRAY"] call iniDB_read;
_magazines = [_filename2, _objName, "Magazines", "ARRAY"] call iniDB_read;
_items = [_filename2, _objName, "Items", "ARRAY"] call iniDB_read;
_backpacks = [_filename2, _objName, "Backpacks", "ARRAY"] call iniDB_read;

if (!isNil "_weapons") then
{
{ _obj addWeaponCargoGlobal _x } forEach _weapons;
};
if (!isNil "_magazines") then
{
{ _obj addMagazineCargoGlobal _x } forEach _magazines;
};
if (!isNil "_items") then
{
{ _obj addItemCargoGlobal _x } forEach _items;
};
if (!isNil "_backpacks") then
{
{ _obj addBackpackCargoGlobal _x } forEach _backpacks;
};
};
};
};
};
};
/*
if (_warchestMoneySavingOn) then
{
pvar_warchest_funds_west = ([_filename2, "Info", "WarchestMoneyBLUFOR", "NUMBER"] call iniDB_read) max 0;
publicVariable "pvar_warchest_funds_west";
pvar_warchest_funds_east = ([_filename2, "Info", "WarchestMoneyOPFOR", "NUMBER"] call iniDB_read) max 0;
publicVariable "pvar_warchest_funds_east";
};
*/
};

diag_log format ["A3Wasteland - vehicle persistence loaded %1 objects from iniDB", _objectsCount];

execVM "persistence\world\Veh_oSave.sqf";

And Veh_oSave.sqf

Code: [Select]
// @file Version: 1.2
// @file Name: oSave.sqf
// @file Author: [GoT] JoSchaap, AgentRev
// @file Description: Basesaving save script

if (!isServer) exitWith {};

#include "functions.sqf"

_saveableObjects = [];

_isSaveable =
{
_result = false;
{ if (_this == _x) exitWith { _result = true } } forEach _saveableObjects;
_result
};

// Add objectList & general store objects
{
_index = _forEachIndex;

{
_obj = _x;
if (_index > 0) then { _obj = _x select 1 };

if (!(_obj isKindOf "AllVehicles") && {!(_obj call _isSaveable)}) then
{
[_saveableObjects, _obj] call BIS_fnc_arrayPush;
};

} forEach _x;
} forEach [civilianVehicles, call allVehStoreVehicles]; //objectList

_filename2 = "Veh" call PDB_databaseNameCompiler;

// If file doesn't exist, create Info section at the top
if !(_filename2 call iniDB_exists) then
{
[_filename2, "Info", "ObjCount", 0] call iniDB_write;
};

while {true} do
{
sleep 60;

_oldObjCount = [_filename2, "Info", "ObjCount", "NUMBER"] call iniDB_read;
_objCount = 0;

{
_obj = _x;

if (alive _obj) then
{
_class = typeOf _obj;
_ownerId = _x getVariable "ownerUID"; //if (_obj getVariable ["objectLocked", true]
if(!isNil "_ownerId" && {(_baseSavingOn && {_class call _isSaveable}) || {_boxSavingOn && {_obj isKindOf "AllVehicles"}}}) //||
  // {_warchestSavingOn && {_obj call _isWarchest}} ||
   //{_beaconSavingOn && {_obj call _isBeacon}})
   then
{
_netId = netId _obj;
_pos = getPosATL _obj;
_dir = [vectorDir _obj, vectorUp _obj];
_damage = damage _obj;
_allowDamage = if (_obj getVariable ["allowDamage", false]) then { 1 } else { 0 };

if (isNil {_obj getVariable "baseSaving_spawningTime"}) then
{
_obj setVariable ["baseSaving_spawningTime", diag_tickTime];
};

_hoursAlive = (_obj getVariable ["baseSaving_hoursAlive", 0]) + ((diag_tickTime - (_obj getVariable "baseSaving_spawningTime")) / 3600);

_variables = [];
/*
switch (true) do
{
case (_obj isKindOf "Land_Sacks_goods_F"):
{
[_variables, ["food", _obj getVariable ["food", 20]]] call BIS_fnc_arrayPush;
};
case (_obj isKindOf "Land_WaterBarrel_F"):
{
[_variables, ["water", _obj getVariable ["water", 20]]] call BIS_fnc_arrayPush;
};
};
*/
_owner = _obj getVariable ["ownerUID", ""];

if (_owner != "") then
{
[_variables, ["ownerUID", _owner]] call BIS_fnc_arrayPush;
};

/*
switch (true) do
{
case (_obj call _isWarchest):
{
[_variables, ["a3w_warchest", true]] call BIS_fnc_arrayPush;
[_variables, ["R3F_LOG_disabled", true]] call BIS_fnc_arrayPush;
[_variables, ["side", str (_obj getVariable ["side", sideUnknown])]] call BIS_fnc_arrayPush;
};
case (_obj call _isBeacon):
{
[_variables, ["a3w_spawnBeacon", true]] call BIS_fnc_arrayPush;
[_variables, ["R3F_LOG_disabled", true]] call BIS_fnc_arrayPush;
[_variables, ["side", str (_obj getVariable ["side", sideUnknown])]] call BIS_fnc_arrayPush;
[_variables, ["ownerName", (_obj getVariable ["ownerName", "[Beacon]"]) call iniDB_Base64Encode]] call BIS_fnc_arrayPush;
[_variables, ["packing", false]] call BIS_fnc_arrayPush;
[_variables, ["groupOnly", _obj getVariable ["groupOnly", false]]] call BIS_fnc_arrayPush;
};
};
*/

_weapons = [];
_magazines = [];
_items = [];
_backpacks = [];

//if (getNumber (configFile >> "CfgVehicles" >> _class >> "maximumLoad") > 0) then
//{
// Save weapons & ammo
_weapons = (getWeaponCargo _obj) call cargoToPairs;
_magazines = (getMagazineCargo _obj) call cargoToPairs;
_items = (getItemCargo _obj) call cargoToPairs;
_backpacks = (getBackpackCargo _obj) call cargoToPairs;
//};

_objCount = _objCount + 1;
_objName = format ["Veh%1", _objCount];

[_filename2, _objName, "Class", _class] call iniDB_write;
[_filename2, _objName, "Position", _pos] call iniDB_write;
[_filename2, _objName, "Direction", _dir] call iniDB_write;
[_filename2, _objName, "HoursAlive", _hoursAlive] call iniDB_write;
[_filename2, _objName, "Damage", _damage] call iniDB_write;
[_filename2, _objName, "AllowDamage", _allowDamage] call iniDB_write;
[_filename2, _objName, "Variables", _variables] call iniDB_write;

[_filename2, _objName, "Weapons", _weapons] call iniDB_write;
[_filename2, _objName, "Magazines", _magazines] call iniDB_write;
[_filename2, _objName, "Items", _items] call iniDB_write;
[_filename2, _objName, "Backpacks", _backpacks] call iniDB_write;

sleep 0.01;
};
};
} forEach allMissionObjects "All";

[_filename2, "Info", "ObjCount", _objCount] call iniDB_write;
/*
_fundsWest = 0;
_fundsEast = 0;

if (["A3W_warchestMoneySaving"] call isConfigOn) then
{
_fundsWest = ["pvar_warchest_funds_west", 0] call getPublicVar;
_fundsEast = ["pvar_warchest_funds_est", 0] call getPublicVar;
};

[_filename2, "Info", "WarchestMoneyBLUFOR", _fundsWest] call iniDB_write;
[_filename2, "Info", "WarchestMoneyOPFOR", _fundsEast] call iniDB_write;
*/
diag_log format ["A3W - %1 vehicles have been saved with iniDB", _objCount];

// Reverse-delete old objects
if (_oldObjCount > _objCount) then
{
for [{_i = _oldObjCount}, {_i > _objCount}, {_i = _i - 1}] do
{
[_filename2, format ["Veh%1", _i]] call iniDB_deleteSection;
};
};
};