Jump to content
Sign in to follow this  
Rocketrolls

Help with a script

Recommended Posts

So I am completely new and just needed a bit of help with a script.

I want to make it save the owner of the vehicles and not save a type of vehicle.

 

So I am using the Nassau 1715 mod, when it saves, it copies all the cannons again that are attached to the vessel. I want to exclude the cannons from the save as the vessel spawns new cannons each time. Also using a script that you buy the vehicles and can unlock and lock them. When this script loads them I don't think it's saving the owner.

 

All help is appreciated, would love to add someone on discord who has the time and patience to help me.

 

/*
	File: 		saveVehicles.sqf
	Author: 	xBowBii (aka xbwb)
	
	08/03/15
*/
SURV_VehiclesLoaded = false;
waitUntil {SURV_VehiclesLoaded};

while {true} do
{
	profileNamespace setVariable ["SURV_Vehicles",[]];

	{
	
		_Vehs  = profileNamespace getVariable ["SURV_Vehicles",[]];
		_vehicle = _x;

		_xType = typeOf _x;
		_xPos  = getPos _x;
		_xDir  = getDir _x;
		_xDmg  = damage _x;
		_xOwns = _x getVariable ["YOUR_OWN_CUSTOMVAR",[]];
		_xFuel = fuel _x;
		_weapons = weaponCargo _x;
		_magazines = magazineCargo _x;

		_hitPoints = [];
		_cachekey = format["%1_HP", _xType];
		_hitpoints = missionNamespace getVariable[_cachekey, []];
		if (_hitpoints isEqualTo []) then
		{
			_na = configProperties[configFile >> "CfgVehicles" >> _xType >> "HitPoints", "_hitpoints pushBack configName _x; true", true];
			missionNamespace setVariable[_cachekey, _hitpoints];
		};

		_finalHitPs = [];
		{
			_finalHitPs = _finalHitPs + [[_x,_vehicle getHitPointDamage _x]];
		} forEach _hitPoints;

		profileNamespace setVariable ["SURV_Vehicles",(_vehs + [[_xtype,_xpos,_xdir,_xdmg,_xowns,_xFuel,_weapons,_magazines,_finalHitPs]])];

	} forEach vehicles;
	saveProfileNamespace;

	sleep 20;
};

and

 

/*
	File: 		loadVehicles.sqf
	Author: 	xBowBii (aka xbwb)

	08/03/15
*/

_vehicles = profileNamespace getVariable ["SURV_Vehicles",nil];

{

	private ["_log","_vtype","_vpos","_vdir","_vdam","_veh","_vFuel","_vWeap","_vMags"];

	_vType = _x select 0;
	_vPos  = _x select 1;
	_vDir  = _x select 2;
	_vDam  = _x select 3;
	_vVar1 = _x select 4;
	_vFuel = _x select 5;
	_vWeap = _x select 6;
	_vMags = _x select 7;
	_hitp  = _x select 8;

	//"extLOG" callExtension format["0:VehicleLogging: %1 at %2, with dmg %3. Fuel is %4, and Cargo is %5 && %6",_vType,_vPos,_vDam,_vFuel,_vWeap,_vMags];

	if (_vDam == 1) exitWith {/* useless to spawn it */};

	_veh = createVehicle [_vType, _vPos, [], 0, "CAN_COLLIDE"];
	_veh setDir _vDir;
	_veh setDamage _vDam;

	removeAllWeapons _veh;
	removeAllItems _veh;

	_veh setVariable ["YOUR_OWN_CUSTOMVAR",_vVar1,true];

	{
		_veh setHitPointDamage [(_x select 0), (_x select 1)];
	} forEach _hitp;

	_veh setFuel _vFuel;

	{
		_veh addWeaponCargoGlobal [_x,1];
	} forEach _vWeap;
	
	{
		_veh addMagazineCargoGlobal [_x,1];
	} forEach _vMags;

} forEach _vehicles;

sleep 20;
SURV_VehiclesLoaded = true; 

Thanks 🙂

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  

×