SWEENNDAWG

USS Freedom with Traders Altis

25 posts in this topic

Posted (edited)

so after the jets DLC release i was curious as to how to implement the USS Freedom. and after reading it was done in editor i thought i would try and learn how to edit the map. it took a while to get it working and after some help from @Rafterman and @110  and also thanks to @Ambu5h for the  ExileServer_system_trading_network_purchaseVehicleRequest override he published. i've decided to include my files to help others implement the USS Freedom. :)

 

download and unpack your mission pbo, eg. Exile.Altis.pbo

Copy this code to the bottom of your initserver.sqf.

Spoiler

///////////////////////////////////////////////////////////////////////////////////////////////////
// USS Freedom
///////////////////////////////////////////////////////////////////////////////////////////////////

 _vehicles = [
["Land_Carrier_01_base_F", [15081.7, 8479.79, 0], [0, 1, 0], [0, 0, 1], true],
["Exile_Sign_Aircraft", [15060.2, 8589.56, 24.5597], [-0.999841, 0.0178356, 0], [0, 0, 1], true],
["Exile_Sign_AircraftCustoms", [15058.8, 8598.17, 24.5597], [-0.701865, -0.71231, 0], [0, 0, 1], true],
["Exile_Sign_Armory", [15057, 8573.6, 24.5597], [0, 1, 0], [0, 0, 1], true],
["Exile_Sign_Equipment", [15048.3, 8573.49, 24.5597], [0, 1, 0], [0, 0, 1], true],
["Exile_Sign_Food", [15049.6, 8579.27, 24.6098], [0.034548, -0.999403, 0], [0, 0, 1], true],
["Exile_Sign_Locker", [15051.5, 8588.62, 24.8974], [-0.0240819, -0.99971, 0], [0, 0, 1], true],
["Exile_Sign_WasteDump", [15041.8, 8484.79, 24.5597], [-0.61656, -0.787308, 0], [0, 0, 1], true],
["Land_Wreck_Heli_Attack_02_F", [15042.9, 8479.13, 26.3104], [-0.986637, -0.162933, 0], [0, 0, 1], true],
["Land_GarbageBarrel_01_F", [15041.2, 8486.71, 24.1325], [0, 1, 0], [0, 0, 1], true],
["Land_Tyres_F", [15048, 8493.16, 23.791], [-0.948936, 0.315468, 0], [0, 0, 1], true],
["Hostage_PopUp3_Moving_90deg_F", [15052.8, 8573.04, 24.5503], [-0.361163, 0.932503, 0], [0, 0, 1], true],
["Exile_Locker", [15049.7, 8588.69, 23.8459], [0.0540724, -0.998537, 0], [0, 0, 1], true],
["Land_CashDesk_F", [15049.5, 8581, 23.5687], [-0.297487, -0.954726, 0], [0, 0, 1], true],
["Land_MobileLandingPlatform_01_F", [15062.9, 8588.44, 23.6993], [0.844649, -0.53532, 0], [0, 0, 1], true],
["Land_Carrier_01_hull_08_GEO_2_F", [15056.7, 8599.79, 0], [0, 1, 0], [0, 0, 1], true],
["Land_Carrier_01_island_02_F", [15051.7, 8589.79, 23.5], [0, 1, 0], [0, 0, 1], true],
["Land_HelipadSquare_F", [15085.8, 8619.97, 180], [0, 1, 0], [0, 0, 1], true],
["Land_HelipadSquare_F", [15105.7, 8598.92, 180], [0, 1, 0], [0, 0, 1], true]

];

{
    private _vehicle = (_x select 0) createVehicle (_x select 1);
    _vehicle allowDamage false;
    _vehicle setPosWorld (_x select 1);
    _vehicle setVectorDirAndUp [_x select 2, _x select 3];
    _vehicle enableSimulationGlobal (_x select 4);
    _vehicle setVariable ["ExileIsLocked", -1, true];
    
}
forEach _vehicles;

// 3 Simple Objects
private _invisibleSelections = ["zasleh", "zasleh2", "box_nato_grenades_sign_f", "box_nato_ammoord_sign_f", "box_nato_support_sign_f"];
private _simpleObjects = [
["a3\weapons_f\ammoboxes\wpnsbox_f.p3d", [15055.3, 8574.1, 23.7074], [0.548742, 0.835992, 0], [0, 0, 1]],
["a3\weapons_f\ammoboxes\supplydrop.p3d", [15054, 8573.86, 24.4111], [-0.998297, -0.0583417, 0], [0, 0, 1]],
["a3\supplies_f_heli\cargonets\cargonet_01_ammo_f.p3d", [15059, 8574.26, 24.3439], [0.867496, -0.497445, 0], [0, 0, 1]]
];

{
    private _simpleObject = createSimpleObject [_x select 0, _x select 1];
    _simpleObject setVectorDirAndUp [_x select 2, _x select 3];
    
    {
        if ((toLower _x) in _invisibleSelections) then 
        {
            _simpleObject hideSelection [_x, true];
        };
    }
    forEach (selectionNames _simpleObject);
}
forEach _simpleObjects;
 

Next add this to the bottom of your initplayerlocal.sqf

Spoiler

////////////////////////////////////////////////////////////////////////////
// USS Freedom
////////////////////////////////////////////////////////////////////////////

private _npcs = [
["Exile_Trader_WasteDump", [], "Exile_Trader_WasteDump", "WhiteHead_05", [[],[],[],["U_I_G_Story_Protagonist_F",[]],["V_Rangemaster_belt",[]],[],"H_MilCap_gry","G_Combat",[],["","","","","",""]], [15042.6, 8485.84, 23.5206], [0.952778, 0.303667, 0], [0, 0, 1]],
["Exile_Trader_Aircraft", [], "Exile_Trader_Aircraft", "WhiteHead_10", [[],[],[],["U_I_pilotCoveralls",[]],[],[],"H_PilotHelmetHeli_O","G_Aviator",[],["","","","","",""]], [15061.6, 8590.66, 23.52], [0.984038, 0.177961, 0], [0, 0, 1]],
["Exile_Trader_AircraftCustoms", [], "Exile_Trader_AircraftCustoms", "WhiteHead_17", [[],[],[],["Exile_Uniform_ExileCustoms",[]],["V_RebreatherB",[]],[],"H_PilotHelmetFighter_B","",[],["","","","","",""]], [15059.3, 8598.71, 23.5199], [0.793725, 0.608277, 0], [0, 0, 1]],
["Exile_Trader_Food", [], "Exile_Trader_Food", "AfricanHead_02", [[],[],[],["U_C_Poloshirt_blue",[]],[],[],"H_Cap_tan","G_Tactical_Clear",[],["","","","","",""]], [15049.4, 8580.44, 23.5697], [0, 1, 0], [0, 0, 1]],
["Exile_Trader_Equipment", [], "Exile_Trader_Equipment", "WhiteHead_20", [["arifle_MX_GL_Black_F","","","",[],[],""],[],[],["U_BG_Guerrilla_6_1",[]],["V_I_G_resistanceLeader_F",[]],[],"H_Watchcap_khk","",[],["","","","","",""]], [15047.4, 8572.7, 23.5198], [0.426048, -0.904701, 0], [0, 0, 1]],
["Exile_Trader_Armory", [], "Exile_Trader_Armory", "WhiteHead_02", [["srifle_DMR_06_olive_F","","","",[],[],""],[],[],["U_Rangemaster",[]],["V_Rangemaster_belt",[]],[],"H_Cap_headphones","G_Shades_Black",[],["","","","","",""]], [15058, 8572.08, 23.5202], [-0.667612, -0.74451, 0], [0, 0, 1]]
];

{
    private _logic = "Logic" createVehicleLocal [0, 0, 0];
    private _trader = (_x select 0) createVehicleLocal [0, 0, 0];
    private _animations = _x select 1;
    
    _logic setPosWorld (_x select 5);
    _logic setVectorDirAndUp [_x select 6, _x select 7];
    
    _trader setVariable ["BIS_enableRandomization", false];
    _trader setVariable ["BIS_fnc_animalBehaviour_disable", true];
    _trader setVariable ["ExileAnimations", _animations];
    _trader setVariable ["ExileTraderType", _x select 2];
    _trader disableAI "ANIM";
    _trader disableAI "MOVE";
    _trader disableAI "FSM";
    _trader disableAI "AUTOTARGET";
    _trader disableAI "TARGET";
    _trader disableAI "CHECKVISIBLE";
    _trader allowDamage false;
    _trader setFace (_x select 3);
    _trader setUnitLoadOut (_x select 4);
    _trader setPosWorld (_x select 5);
    _trader setVectorDirAndUp [_x select 6, _x select 7];
    _trader reveal _logic;
    _trader attachTo [_logic, [0, 0, 0]];
    _trader switchMove (_animations select 0);
    _trader addEventHandler ["AnimDone", {_this call ExileClient_object_trader_event_onAnimationDone}];
}
forEach _npcs;

next add this to the bottom of your init.sqf

Spoiler

if (isServer) then {
    private _carrier = createVehicle ["Land_Carrier_01_base_F",[15081.7,8479.79,0],[],0,"NONE"];
    _carrier setPosWorld [15081.7,8479.79,0]; // [x,y,z] or positionWorld
    _carrier setDir 0; // North
    [_carrier] call BIS_fnc_Carrier01PosUpdate;
};

next  Create  a file named "ExileServer_system_trading_network_purchaseVehicleRequest.sqf" HAS to be exacly that name and place it in a folder called overrides in your mission file. And put the following code in it:

Spoiler

private["_sessionID","_parameters","_vehicleClass","_pinCode","_playerObject","_salesPrice","_playerMoney","_position","_vehicleObject","_logging","_traderLog","_responseCode"];
_sessionID = _this select 0;
_parameters = _this select 1;
_vehicleClass = _parameters select 0;
_pinCode = _parameters select 1;
try 
{
	_playerObject = _sessionID call ExileServer_system_session_getPlayerObject;
	if (isNull _playerObject) then
	{
		throw 1;
	};
	if !(alive _playerObject) then
	{
		throw 2;
	};
	if (_playerObject getVariable ["ExileMutex",false]) then
	{
		throw 12;
	};
	_playerObject setVariable ["ExileMutex", true];
	if !(isClass (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass) ) then
	{
		throw 3;
	};
	_salesPrice = getNumber (missionConfigFile >> "CfgExileArsenal" >> _vehicleClass >> "price");
	if (_salesPrice <= 0) then
	{
		throw 4;
	};
	_playerMoney = _playerObject getVariable ["ExileMoney", 0];
	if (_playerMoney < _salesPrice) then
	{
		throw 5;
	};
	if !((count _pinCode) isEqualTo 4) then
	{
		throw 11;
	};

	_spawnObject 	= "Land_HelipadSquare_F"; // the object you want to use for spawning, can't be a simple object
	_safeRadius 	= 5; // radius around the spawn object where it looks for room, must be 5 or higher
	_disableCheck	= 1; // set to 1 if you don't want to check if there is a vehicle near the spawn object
	_disableRadius 	= 1; // set to 1 if you want vehicles to only spawn at the exact coords of your spawn object, not recommended better to reduce _safeRadius
	_dirShip		= (random 360); // set rotation of ship vehicle spawning, default = random
	_dirAir			= (random 360); // set rotation of air vehicle spawning, default = random
	_dirOther		= (random 360); // set rotation of all other vehicles spawning, default = random
	_errorMessage 	= "There is no room to safely spawn this vehicle!"; // (toast)message to player when there is no room to spawn

	_nObject = nearestObject [(getPosATL _playerObject), _spawnObject];
	_throwError = 0;

	if (isNull _nObject) then
	{
		if (_vehicleClass isKindOf "Ship") then
		{
			_position = [(getPosATL _playerObject), 80, 10] call ExileClient_util_world_findWaterPosition;
			if (_position isEqualTo []) then 
			{
				throw 13;
			};
			_vehicleObject = [_vehicleClass, _position, (random 360), false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
		}
		else
		{
			_position = (getPos _playerObject) findEmptyPosition [10, 175, _vehicleClass];
			if (_position isEqualTo []) then 
			{
				throw 13;
			};
			_vehicleObject = [_vehicleClass, _position, (random 360), true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
		};
	}
	else
	{
		_position = getPos _nObject;

		if (_position isEqualTo []) then 
		{
			[_sessionID, "toastRequest", ["ErrorTitleAndText", ["Error: Unable to get the position of the Spawn Object."]]] call ExileServer_system_network_send_to;
			_throwError = 1;
		};

		if (_disableCheck isEqualTo 1) then
		{
			switch (true) do {
				case (_vehicleClass isKindOf "Ship"): {
					_vehicleObject = [_vehicleClass, _position, _dirShip, false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
				};
				case (_vehicleClass isKindOf "Air"): {
					_vehicleObject = [_vehicleClass, _position, _dirAir, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
				};
				default {
					_vehicleObject = [_vehicleClass, _position, _dirOther, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
				};
			};
		}
		else 
		{
			_findEmpty = _position findEmptyPosition [0, _safeRadius, _vehicleClass];
			if (_findEmpty isEqualTo []) then
			{
				[_sessionID, "toastRequest", ["ErrorTitleAndText", [_errorMessage]]] call ExileServer_system_network_send_to;
				_throwError = 1;
			}
			else
			{
				_isEmpty = _findEmpty isFlatEmpty [-1, -1, -1, -1, -1, false, _nObject];
				if (_isEmpty isEqualTo []) then
				{
					[_sessionID, "toastRequest", ["ErrorTitleAndText", [_errorMessage]]] call ExileServer_system_network_send_to;
					_throwError = 1;
				}
				else
				{
					switch (true) do {
						case (_vehicleClass isKindOf "Ship"): {
							if (_disableRadius isEqualTo 1) then
							{
								_vehicleObject = [_vehicleClass, _position, _dirShip, false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							}
							else
							{
								_vehicleObject = [_vehicleClass, _findEmpty, _dirShip, false, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							};
						};
						case (_vehicleClass isKindOf "Air"): {
							if (_disableRadius isEqualTo 1) then
							{
								_vehicleObject = [_vehicleClass, _position, _dirAir, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							}
							else
							{
								_vehicleObject = [_vehicleClass, _findEmpty, _dirAir, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							};
						};
						default {
							if (_disableRadius isEqualTo 1) then
							{
								_vehicleObject = [_vehicleClass, _position, _dirOther, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							}
							else
							{
								_vehicleObject = [_vehicleClass, _findEmpty, _dirOther, true, _pinCode] call ExileServer_object_vehicle_createPersistentVehicle;
							};
						};
					};
				};
			};
		};
	};

	if (_throwError isEqualTo 0) then
	{
		_vehicleObject setVariable ["ExileOwnerUID", (getPlayerUID _playerObject)];
		_vehicleObject setVariable ["ExileIsLocked",0];
		_vehicleObject lock 0;
		_vehicleObject call ExileServer_object_vehicle_database_insert;
		_vehicleObject call ExileServer_object_vehicle_database_update;
		_playerMoney = _playerMoney - _salesPrice;
		_playerObject setVariable ["ExileMoney", _playerMoney, true];
		format["setPlayerMoney:%1:%2", _playerMoney, _playerObject getVariable ["ExileDatabaseID", 0]] call ExileServer_system_database_query_fireAndForget;
		[_sessionID, "purchaseVehicleResponse", [0, netId _vehicleObject, _salesPrice]] call ExileServer_system_network_send_to;
		_logging = getNumber(configFile >> "CfgSettings" >> "Logging" >> "traderLogging");
		if (_logging isEqualTo 1) then
		{
			_traderLog = format ["PLAYER: ( %1 ) %2 PURCHASED VEHICLE %3 FOR %4 POPTABS | PLAYER TOTAL MONEY: %5",getPlayerUID _playerObject,_playerObject,_vehicleClass,_salesPrice,_playerMoney];
			"extDB2" callExtension format["1:TRADING:%1",_traderLog];
		};
	};
}
catch 
{
	_responseCode = _exception;
	[_sessionID, "purchaseVehicleResponse", [_responseCode, "", 0]] call ExileServer_system_network_send_to;
};
if !(isNull _playerObject) then 
{
	_playerObject setVariable ["ExileMutex", false];
};
true

Goto your config.cpp in your missionfile and at the "class CfgExileCustomCode" add the following line:

Spoiler

ExileServer_system_trading_network_purchaseVehicleRequest = "overrides\ExileServer_system_trading_network_purchaseVehicleRequest.sqf";

open your mission.sqm file and add the trader icon map marker using the same co-ordinates for "Land_Carrier_01_base_F" in initserver.sqf

Now repack your mission pbo and upload to your server, good luck.

Don't forget to hit like if this helps you :)

20170517221003_1.jpg

20170517221104_1.jpg

20170517221149_1.jpg

Edited by SWEENNDAWG
1 person likes this

Share this post


Link to post
Share on other sites

Moved and approved.

Share this post


Link to post
Share on other sites
Advertisement

Posted (edited)

Thanks for mentioning me in here. Interesting stuff, will add today.
Nothing like a good carrier as a tradezone.

However im not the original author of that script.
I mearly edited and debugged his script to make it work.
Unfortunately i cannot remember who made the original script.
(@BetterZedThenDead or @Kupilion since they are the first posters in the topic)

Eitherway, thx for the credits but i dont feel like i deserved them the most :p.

 

Edited by Ambu5h

Share this post


Link to post
Share on other sites

Super cool, I got it working on my server although without a map marker as of yet, but that's for tomorrow after a good sleep.

 

Thanks for posting this otherwise I'd have had several carriers in the water for decoration, now only 4/5 are :'D

Share this post


Link to post
Share on other sites

Hi guys I'm just a taddy bit confused with this, why is the carrier being called in the initserver.sqf and init.sqf?

there's obviously a good reason for it but would like to understand what's going on here please.

Cheers

Share this post


Link to post
Share on other sites

@wildernessI used the exile pluggin for placing the objects and exporting them which exports them to the initserver.sqf, I'm a noob at map editing so this was the easiest for me, I believe you can add them in the mission.sqm too and as to why it's called in the init.sqf, without that it wouldn't show, @Rafterman and @110 suggested that and it works, like I said I'm a noob so don't understand the complete Ins and outs 

Share this post


Link to post
Share on other sites

@Sweendawg ah ok that's interesting I used the editor and called it using this on the server:

the same way that I call all of my mapped scenery, including trader scenery (it just cuts some of the stuff from the mission file) it did spawn the carrier but it was half sunk with the wrong orientation!!!

When I added it in the init.sqf I had two over lapping carriers, though one was half sunk and facing the wrong way and one was perfect!

so I removed the carrier being spawned with the A3_custom.pbo (serverside) and just used the init.sqf to call it and it's perfect. I have no reference to the carrier in my initserver.sqf what so ever.

That's basically why I was asking, I just wondered if there was some advantage to having a reference to it in the initserver.sqf, but from my own experiments I don't think it needs to be in the initserver.sqf  if your calling it with the init.sqf ?

Don't get me wrong I'm no pro at this, but based on my experiments and observations it seems that you are calling the carrier twice maybe?

Share this post


Link to post
Share on other sites

Failed to purchase vehicle 13

My players cannot buy a vehicle at this trader.

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.