Jump to content

[Release] Vehicle Service Point (Refuel, Repair, Rearm) [Script]


Axe Cop

Recommended Posts

Sorry that's not what i meant, I know only gunners can rearm, what i meant is myself driving and another as a gunner, my gunner can't rearm, he doesn't get the option so he has to swap seats or jump out, then i move seats and get the option because i was the driver and swapped to gunner.

Link to comment
Share on other sites

Updated the script to use the (new?) variable "dayz_fuelpumparray" as default service point class list, defined in the epoch variables.sqf:

dayz_fuelpumparray = ["FuelPump_DZ","Land_A_FuelStation_Feed","Land_Ind_FuelStation_Feed_EP1","Land_FuelStation_Feed_PMC","FuelStation","Land_ibr_FuelStation_Feed","Land_fuelstation_army","Land_fuelstation","land_fuelstation_w","Land_benzina_schnell"];

so it should work on all maps by default, seems like they use different gas stations sometimes!

If you want to add vehicles to the class list you could use this (also from variables.sqf):

DZE_fueltruckarray = ["KamazRefuel_DZ","UralRefuel_TK_EP1_DZ","MtvrRefuel_DES_EP1_DZ","V3S_Refuel_TK_GUE_EP1_DZ","MtvrRefuel_DZ"];

to use fuel trucks as mobile service points, I use that on my server. Just change the config in the service_point.sqf like this:

_servicePointClasses = dayz_fuelpumparray + DZE_fueltruckarray; 

that is all to use all gas stations and fuel trucks as service points! :)

 

 

Also a small "fix" for some anti hack tools. I've made all action variables public by default, you should be able to whitelist these variables in your tool (if needed):

SP_refuel_action
SP_repair_action
SP_rearm_actions
SP_rearm_action

I've never noticed that, runs as expected.

Only snag is rearming, sometimes have to jump from drivers seat to gunners or even get out and back in, works in the end though :)

 

Yes you have to switch to the driver seat to change the locallity of the vehicle to your computer, I don't want to go into details of the ArmA engine here but this has to be done.. 

Link to comment
Share on other sites

Hey Axe Cop. Just wanted to say that I have your new script running (on my 1.0.3 server) and it's brilliant.  

Thank you for going out of your way to make those changes i enquired about, I can't thank you enough for that :)

 

You still need to add your donation link/button somewhere though :P

Link to comment
Share on other sites

Hey Axe Cop. Just wanted to say that I have your new script running (on my 1.0.3 server) and it's brilliant.  

Thank you for going out of your way to make those changes i enquired about, I can't thank you enough for that :)

 

You still need to add your donation link/button somewhere though :P

haha thanks hayward, if you really want to donate you can do that on my epoch server website: http://brsquad.enjin.com

 

anyway i am working on a new epic script but the next one requires some more changes to the epoch code and database eventually, i hope it will work out and change the way you play dayz, stay tuned :D

Link to comment
Share on other sites

After the help you've given me, I'm more than happy to throw a few £ your way towards your server costs at the end of the month :)

I appreciate this, but I still do this epoch additions for fun and I myself do learn new stuff while doing that every day, and I am a developer for some years now (Arma/Dayz just for some month) :)

Link to comment
Share on other sites

Since I tried to make this work with the antihack I broke it and didn't bother to look again. After the patch I tried getting it up again and I am running into an issue.

 

if (!isDedicated) then {
//Conduct map operations
execVM "service_point\service_point.sqf";
 
0 fadeSound 0;
waitUntil {!isNil "dayz_loadScreenMsg"};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
 
//Run the player monitor
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
 
.....
 
 
 
I have the service point folder in the root of my mission file. Very confused why this wouldn't work. The structure matches from when I had it working.
 
 
 
Just tested by using the previous version, simply copy and paste the whole folder and it works alright. Very strange.
Link to comment
Share on other sites

 

Since I tried to make this work with the antihack I broke it and didn't bother to look again. After the patch I tried getting it up again and I am running into an issue.

 

if (!isDedicated) then {
//Conduct map operations
execVM "service_point\service_point.sqf";
 
0 fadeSound 0;
waitUntil {!isNil "dayz_loadScreenMsg"};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
 
//Run the player monitor
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
 
.....
 
 
 
I have the service point folder in the root of my mission file. Very confused why this wouldn't work. The structure matches from when I had it working.
 
 
 
Just tested by using the previous version, simply copy and paste the whole folder and it works alright. Very strange.

 

 

 

I changed the "free" price for refueling. I didn't match it to your "array" for pricing. Works great. Like the changes.

Link to comment
Share on other sites

self blood whit trade.

hi all, forgive me for not English I am translating with googletransalator, I have a problem with self blood car blood works fine but when I enter the trade does not leave the option to talk to the trade, but if I remove the script if you let me talk , you know what could be the problem??, use chenarus epoch.
thanks and regards.
Link to comment
Share on other sites

 

hi all, forgive me for not English I am translating with googletransalator, I have a problem with self blood car blood works fine but when I enter the trade does not leave the option to talk to the trade, but if I remove the script if you let me talk , you know what could be the problem??, use chenarus epoch.
thanks and regards.

 

I don't know, are you using the latest version? my script has nothing to do with the traders it is not even using the variables but it's own. :/

Link to comment
Share on other sites

 

hi all, forgive me for not English I am translating with googletransalator, I have a problem with self blood car blood works fine but when I enter the trade does not leave the option to talk to the trade, but if I remove the script if you let me talk , you know what could be the problem??, use chenarus epoch.
thanks and regards.

 

 

Hope I don't come over as rude when I suggest this, but you should probably get a friend who can speak English to translate next time for you.  This Google translation is horrible.  It's not you, it's the poor translation that Google offers  :P

Link to comment
Share on other sites

Hey Axe,

I have a question for you regarding the locality of the vehicle that you have often said you do not want to get into. I have tried scripting the following situation myself but since this would be my very first script I am banging my head against a wall on most areas.

The simple part of it is.. CfgVehicles come with a Turrets class that describes each turret. Then the Turrets class in turn comes with sub classes for each Turret. They in turn come with Weapons and Magazines properties. I am attempting to get these values out so that a vehicle e.g. HMMWV_M998A2_SOV_DES_EP1 does not rearm with a ridiculous amount of ammunition as your code just takes the max value each time it is rearmed. I would really like to extract that default weapon/magazine combo to set the max amount for the vehicle.

I do know you have said previously that it is hard due to the fact the class names have been altered with DZE but I believe I might have a way to get the default class name from the DZE class name. I have managed to traverse the class hierarchy to get to the Turrets class but since I am using your code as a basis the only way to get the Turret in question is by getting into the Turret and passing the Turret path from your code to the hierarchy extractor. And since turret paths are really horribly documented I simply cannot get any further with my code. But I was wondering if you knew a way I could simply get all the turrets + turret paths so that the driver (the owner of the vehicle afaik) can rearm the entire vehicle to the set amount.

P.S - if you are interested this is the string manipulation codes I will attempt to use to get the non-DZE names of the classes. http://kronzky.info/snippets/strings/index.htm

 

Thanks.

Link to comment
Share on other sites

Hi frod, well my first version of the ream script did exactely that and reamed all turrets from the driver seat, but it never worked so I have changed it to a stable script that will work all the time.

I don't knwo what the problem is but it seemed you have to sit in every single gunner seat and then you can ream from the driver seat, but that I could not integrate in a script like this because most players would never understand how this works and may think it is a bug or whatever.. don't ask me maybe it was a bug in my script but it never rearmed all turrets properly with that approch.

 

To get all turrents of a vehicle you should just look at the wiki there is a user provided function for doing that: http://community.bistudio.com/wiki/weaponsTurret (scroll down), that should help but maybe not an easy script to start with, I tell you that. :D

 

And of course your can just cut of the "E" from "DZE" to get the DayZ vehicle class, I can't tell you but there might be vehicles where that will not work because there are no DZ types but maybe EP or whatever.. you have to check every vehicle for that.

Link to comment
Share on other sites

Hi Axe,

Thanks for the prompt reply!

I have had a look at weaponsTurret and used that as the basis for getting the Turrets. But I cannot figure out how to get the Turret path for a weapon from the turrets class to use for the addMagazineTurret method (http://community.bistudio.com/wiki/addMagazineTurret). And since I am learning and doing from your code mostly the only way to get the turret path is from the player being in the turret himself and getting it through the role.

Any ideas on this would be appreciated.

P.S - I have noticed what might be a bug. Very well may not be one but thought I'd bring it your attention. I randomly tried to use the script on an Apache AH64D & AH6J_EP1 and noticed you cannot rearm the FFARLauncher because the _fnc_isArmed function checks for multiple values in the roles array while as a driver you only return the one value. Thus, determining the vehicle to not be armed.

Link to comment
Share on other sites

I have had a look at weaponsTurret and used that as the basis for getting the Turrets. But I cannot figure out how to get the Turret path for a weapon from the turrets class to use for the addMagazineTurret method (http://community.bistudio.com/wiki/addMagazineTurret). And since I am learning and doing from your code mostly the only way to get the turret path is from the player being in the turret himself and getting it through the role.

Any ideas on this would be appreciated.

That is what I send you the link for, the function returns all the turret paths, that's what it says in the title.."Returns information (including the turrets paths) about all weapons on turrets" ?? Isn't that what you need?

 

P.S - I have noticed what might be a bug. Very well may not be one but thought I'd bring it your attention. I randomly tried to use the script on an Apache AH64D & AH6J_EP1 and noticed you cannot rearm the FFARLauncher because the _fnc_isArmed function checks for multiple values in the roles array while as a driver you only return the one value. Thus, determining the vehicle to not be armed.

yeah my function _fnc_isArmed might not work for the driver, but none of the default armed vehicles in epoch have weapons in the driver seat so that works fine for epoch. Ream is a mess anyway, but good luck with that :)

Link to comment
Share on other sites

hi axe!

unfortunately i cant get this thing to work.

im loading this one serverside:

if (isServer) then {

_vehicle_999 = objNull;
if (true) then
{
  _this = createVehicle ["TK_WarfareBHeavyFactory_EP1", [6755.3481, 7503.8726, 0], [], 0, "CAN_COLLIDE"];
  _vehicle_999 = _this;
  _this setDir 20.960215;
  _this setPos [6755.3481, 7503.8726, 0];
};

_unit_998 = objNull;
if (true) then
{
  _this = createAgent ["CZ_Special_Forces_GL_DES_EP1_DZ", [6757.0991, 7501.5405, 0.25130782], [], 0, "CAN_COLLIDE"];
  _unit_998 = _this;
  _this setDir 190.36134;
  _this setPos [6757.0991, 7501.5405, 0.25130782];
  _this setVehicleInit "this allowDammage false; this disableAI 'FSM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0;";
  _this setUnitAbility 0.60000002;
  _this allowDammage false; _this disableAI 'FSM'; _this disableAI 'MOVE'; _this disableAI 'AUTOTARGET'; _this disableAI 'TARGET'; _this setBehaviour 'CARELESS'; _this forceSpeed 0;_this enableSimulation false;
};

};

which basically creates a "traderlike servicepoint"

and have set the service point class to "TK_WarfareBHeavyFactory_EP1"

 

but no options are appearing ...

 

am i not allowed to load such things serverside ? do this items need to be loaded threw database?

Link to comment
Share on other sites

which basically creates a "traderlike servicepoint"

and have set the service point class to "TK_WarfareBHeavyFactory_EP1"

 

but no options are appearing ...

 

am i not allowed to load such things serverside ? do this items need to be loaded threw database?

I don't see why this is not working, my script is just using the nearestObjects command to look for nearby service points.

Usually it doesn't matter if the object was created on the server, as long as you can see it in the game it should be detected!?

Maybe there is another bug or something wrong, needs some debugging which is not easy to do with ARmA scripts unfortunately :/

In general everyhting you create with "createVehicle" or "createUnit" should work.. (I am not sure about "createAgent" since trader creation has changed with Epoch 1.0.3 but I think it should also work)

 

I don't think you get any script errors in your log file, do you?

Link to comment
Share on other sites

nope no errors, would there be any possibility to trigger the service point effect through init of the building itself ??

 

like init= this execvm servicepoints.sqf ??

Well you need to start the service_point.sqf in the init.sqf anyway, if you don't do that no wonder your changes are not working!? But I guess you mean something else maybe ^^

You could post your changes of the service_point.sqf here, I can't help you without more details...

Link to comment
Share on other sites

okay my files look like this:

 

init.sqf:

/*	
	For DayZ Epoch
	Addons Credits: Jetski Yanahui by Kol9yN, Zakat, Gerasimow9, YuraPetrov, zGuba, A.Karagod, IceBreakr, Sahbazz
*/
startLoadingScreen ["","RscDisplayLoadCustom"];
cutText ["","BLACK OUT"];
enableSaving [false, false];

//REALLY IMPORTANT VALUES
dayZ_instance =	1;					//The instance
dayzHiveRequest = [];
initialized = false;
dayz_previousID = 0;

//disable greeting menu 
player setVariable ["BIS_noCoreConversations", true];
//disable radio messages to be heard and shown in the left lower corner of the screen
enableRadio false;
// May prevent "how are you civillian?" messages from NPC
enableSentences false;

// DayZ Epoch config
spawnShoremode = 1; // Default = 1 (on shore)
spawnArea= 1500; // Default = 1500
MaxHeliCrashes= 10; // Default = 5
MaxVehicleLimit = 800; // Default = 50
MaxDynamicDebris = 500; // Default = 100
dayz_MapArea = 14000; // Default = 10000
dayz_maxLocalZombies = 30; // Default = 30 
dayz_zedsAttackVehicles = true;
dayz_tameDogs = false;
DZE_DeathMsgTitleText = true;
DZE_DeathMsgGlobal = true;
DZE_buildinglimit = 300;
dayz_servername = "[GER] Banditparty";
DynamicVehicleDamageLow = 0; // Default: 0
dayz_maxAnimals = 8; // Default: 8
DynamicVehicleDamageHigh = 100; // Default: 100
DZE_ForceNameTags = true;
DZE_HumanityTargetDistance = 15;

dayz_paraSpawn = false;

dayz_minpos = -1; 
dayz_maxpos = 16000;

dayz_sellDistance_vehicle = 10;
dayz_sellDistance_boat = 30;
dayz_sellDistance_air = 40;

EpochEvents = [["any","any","any",0,5,"special1"],["any","any","any",3,5,"special1"],["any","any","any",6,5,"special1"],["any","any","any",9,5,"special1"],["any","any","any",12,5,"special1"],["any","any","any",15,5,"special1"],["any","any","any",18,5,"special1"],["any","any","any",21,5,"special1"],["any","any","any","any",30,"ammobox"],["any","any","any","any",45,"crash_spawner"],["any","any","any","any",15,"crash_spawner"],["any","any","any","any",0,"supply_drop"],["any","any","any","any",30,"supply_drop"]];
dayz_fullMoonNights = true;

//Load in compiled functions
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf";				//Initilize the Variables (IMPORTANT: Must happen very early)
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf";				//Initilize the publicVariable event handlers
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf";	//Functions used by CLIENT for medical
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "Custom\compiles.sqf";				//Compile regular functions
progressLoadingScreen 0.5;
call compile preprocessFileLineNumbers "server_traders.sqf";				//Compile trader configs
progressLoadingScreen 1.0;

"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";

if (isServer) then {
	call compile preprocessFileLineNumbers "\z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\dynamic_vehicle.sqf";
	//Compile vehicle configs
	
	// Add trader citys
	_nil = [] execVM "\z\addons\dayz_server\missions\DayZ_Epoch_11.Chernarus\mission.sqf";
	_serverMonitor = 	[] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
};

if (!isDedicated) then {
	execVM "service_point\service_point.sqf";
	[] execVM "Custom\credits.sqf";
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
	
	//Run the player monitor
	_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
	_playerMonitor = 	[] execVM "\z\addons\dayz_code\system\player_monitor.sqf";	
	
	// Anti Hack 
	if (true) then {
		[] execVM "\z\addons\dayz_code\system\antihack.sqf";
	};
	
		if (!isNil "dayz_servername") then {
	[] spawn {
		waitUntil {(!isNull Player) and (alive Player) and (player == player)};
		waituntil {!(isNull (findDisplay 46))};
		5 cutRsc ["wm_disp","PLAIN"];
		((uiNamespace getVariable "wm_disp") displayCtrl 1) ctrlSetText dayz_servername;
	};
};
	
	//Lights
	if (true) then {
		[0,0,true,true,true,58,280,600,[0.698, 0.556, 0.419],"Generator_DZ",0.1] execVM "\z\addons\dayz_code\compile\local_lights_init.sqf";
	};
};

if(true) then {
	#include "\z\addons\dayz_code\system\REsec.sqf"
};

//Start Dynamic Weather
if(true) then {
	execVM "\z\addons\dayz_code\external\DynamicWeatherEffects.sqf";
};

#include "\z\addons\dayz_code\system\BIS_Effects\init.sqf"
	[] execVM "Custom\DebugMonitor.sqf";
	[] execVM "admintools\Activate.sqf";
	[] execVM "Custom\faction.sqf";
_logistic = execVM "=BTC=_Logistic\=BTC=_Logistic_Init.sqf";

and my service_point.sqf looks like this:

// Vehicle Service Point by Axe Cop

private ["_folder","_servicePointClasses","_maxDistance","_actionTitleFormat","_actionCostsFormat","_costsFree","_message","_messageShown","_refuel_enable","_refuel_costs","_refuel_updateInterval","_refuel_amount","_repair_enable","_repair_costs","_repair_repairTime","_rearm_enable","_rearm_costs","_rearm_magazineCount","_lastVehicle","_lastRole","_refuel_action","_repair_action","_rearm_actions","_fnc_removeActions","_fnc_getCosts","_fnc_actionTitle","_fnc_isArmed","_fnc_getWeapons"];

// ---------------- CONFIG START ----------------

// general settings
_folder = "service_point\"; // folder where the service point scripts are saved, relative to the mission file
_servicePointClasses = ["TK_WarfareBHeavyFactory_EP1"]; // service point classes (add "FuelPump_DZ" to use the dynamic Epoch fuel pumps)
_maxDistance = 15; // maximum distance from a service point for the options to be shown
_actionTitleFormat = "%1 (%2)"; // text of the vehicle menu, %1 = action name (Refuel, Repair, Rearm), %2 = costs (see format below)
_actionCostsFormat = "%2 %1"; // %1 = item name, %2 = item count
_costsFree = "free"; // text for no costs
_message = "Vehicle Service Point nearby"; // message to be shown when in range of a service point (set to "" to disable)

// refuel settings
_refuel_enable = true; // enable or disable the refuel option
_refuel_costs = ["AllVehicles",["ItemGoldBar10oz",1]]; // free for all vehicles (equal to [["AllVehicles",[]]])
_refuel_updateInterval = 0.5; // update interval (in seconds)
_refuel_amount = 0.02; // amount of fuel to add with every update (in percent)

// repair settings
_repair_enable = true; // enable or disable the repair option
_repair_costs = [
	["Air",["ItemGoldBar10oz",5]], // 5 Gold for helicopters and planes
	["AllVehicles",["ItemGoldBar10oz",3]] // 2 Gold for all other vehicles
];
_repair_repairTime = 5; // time needed to repair each damaged part (in seconds)

// rearm settings
_rearm_enable = true; // enable or disable the rearm option
_rearm_costs = [
	["Air",["ItemBriefcase100oz",1]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemGoldBar10oz",5]] // 1 10oz Gold for all other vehicles
];
_rearm_magazineCount = 3; // amount of magazines to be added to the vehicle weapon

// ----------------- CONFIG END -----------------

call compile preprocessFileLineNumbers (_folder + "ac_functions.sqf");

_lastVehicle = objNull;
_lastRole = [];

_refuel_action = -1;
_repair_action = -1;
_rearm_actions = [];

_messageShown = false;

_fnc_removeActions = {
	if (isNull _lastVehicle) exitWith {};
	_lastVehicle removeAction _refuel_action;
	_refuel_action = -1;
	_lastVehicle removeAction _repair_action;
	_repair_action = -1;
	{
		_lastVehicle removeAction _x;
	} forEach _rearm_actions;
	_rearm_actions = [];
	_lastVehicle = objNull;
	_lastRole = [];
};

_fnc_getCosts = {
	private ["_vehicle","_costs","_cost"];
	_vehicle = _this select 0;
	_costs = _this select 1;
	_cost = [];
	{
		private "_typeName";
		_typeName = _x select 0;
		if (_vehicle isKindOf _typeName) exitWith {
			_cost = _x select 1;
		};
	} forEach _costs;
	_cost
};

_fnc_actionTitle = {
	private ["_actionName","_costs","_costsText","_actionTitle"];
	_actionName = _this select 0;
	_costs = _this select 1;
	_costsText = _costsFree;
	if (count _costs == 2) then {
		private ["_itemName","_itemCount","_displayName"];
		_itemName = _costs select 0;
		_itemCount = _costs select 1;
		_displayName = getText (configFile >> "CfgMagazines" >> _itemName >> "displayName");
		_costsText = format [_actionCostsFormat, _displayName, _itemCount];
	};
	_actionTitle = format [_actionTitleFormat, _actionName, _costsText];
	_actionTitle
};

_fnc_isArmed = {
	private ["_role","_armed"];
	_role = _this;
	_armed = count _role > 1;
	_armed
};

_fnc_getWeapons = {
	private ["_vehicle","_role","_weapons"];
	_vehicle = _this select 0;
	_role = _this select 1;
	_weapons = [];
	if (count _role > 1) then {
		private ["_turret","_weaponsTurret"];
		_turret = _role select 1;
		_weaponsTurret = _vehicle weaponsTurret _turret;
		{
			private "_weaponName";
			_weaponName = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
			_weapons set [count _weapons, [_x, _weaponName, _turret]];
		} forEach _weaponsTurret;
	};
	_weapons
};

while {true} do {
	private ["_vehicle","_inVehicle"];
	_vehicle = vehicle player;
	_inVehicle = _vehicle != player;
	if (local _vehicle && _inVehicle) then {
		private ["_pos","_objects","_inRange"];
		_pos = position _vehicle;
		_objects = nearestObjects [_pos, _servicePointClasses, _maxDistance];
		_inRange = count _objects > 0;
		if (_inRange) then {
			private ["_role","_actionCondition","_costs","_actionTitle"];
			_role = assignedVehicleRole player;
			if (((str _role) != (str _lastRole)) || (_vehicle != _lastVehicle)) then {
				// vehicle or seat changed
				call _fnc_removeActions;
			};
			_lastVehicle = _vehicle;
			_lastRole = _role;
			_actionCondition = "vehicle _this == _target && local _target";
			if (_refuel_action < 0 && _refuel_enable) then {
				_costs = [_vehicle, _refuel_costs] call _fnc_getCosts;
				_actionTitle = ["Refuel", _costs] call _fnc_actionTitle;
				_refuel_action = _vehicle addAction [_actionTitle, _folder + "service_point_refuel.sqf", [_costs, _refuel_updateInterval, _refuel_amount], -1, false, true, "", _actionCondition];
			};
			if (_repair_action < 0 && _repair_enable) then {
				_costs = [_vehicle, _repair_costs] call _fnc_getCosts;
				_actionTitle = ["Repair", _costs] call _fnc_actionTitle;
				_repair_action = _vehicle addAction [_actionTitle, _folder + "service_point_repair.sqf", [_costs, _repair_repairTime], -1, false, true, "", _actionCondition];
			};
			if ((_role call _fnc_isArmed) && (count _rearm_actions == 0) && _rearm_enable) then {
				private ["_weapons"];
				_costs = [_vehicle, _rearm_costs] call _fnc_getCosts;
				_weapons = [_vehicle, _role] call _fnc_getWeapons;
				{
					private ["_weaponName","_rearm_action"];
					_weaponName = _x select 1;
					_actionTitle = [format["Rearm %1", _weaponName], _costs] call _fnc_actionTitle;
					_rearm_action = _vehicle addAction [_actionTitle, _folder + "service_point_rearm.sqf", [_costs, _rearm_magazineCount, _x], -1, false, true, "", _actionCondition];
					_rearm_actions set [count _rearm_actions, _rearm_action];
				} forEach _weapons;
			};
			if (!_messageShown && _message != "") then {
				_messageShown = true;
				_vehicle vehicleChat _message;
			};
		} else {
			call _fnc_removeActions;
			_messageShown = false;
		};
	} else {
		call _fnc_removeActions;
		_messageShown = false;
	};
	sleep 2;
};

probably you can find an error in there.

 

What i basically meant up there is if you know a possibilty to change the script so that it works kinda like a safezone, in a radius around a specified point youll get options to use the service points without using the building but executing the service point when entering the area, like a sensor or something

 

and no: im not using any antihack

Link to comment
Share on other sites

okay my files look like this:


and my service_point.sqf looks like this:

// Vehicle Service Point by Axe Cop

private ["_folder","_servicePointClasses","_maxDistance","_actionTitleFormat","_actionCostsFormat","_costsFree","_message","_messageShown","_refuel_enable","_refuel_costs","_refuel_updateInterval","_refuel_amount","_repair_enable","_repair_costs","_repair_repairTime","_rearm_enable","_rearm_costs","_rearm_magazineCount","_lastVehicle","_lastRole","_refuel_action","_repair_action","_rearm_actions","_fnc_removeActions","_fnc_getCosts","_fnc_actionTitle","_fnc_isArmed","_fnc_getWeapons"];

// ---------------- CONFIG START ----------------

// general settings
_folder = "service_point\"; // folder where the service point scripts are saved, relative to the mission file
_servicePointClasses = ["TK_WarfareBHeavyFactory_EP1"]; // service point classes (add "FuelPump_DZ" to use the dynamic Epoch fuel pumps)
_maxDistance = 15; // maximum distance from a service point for the options to be shown
_actionTitleFormat = "%1 (%2)"; // text of the vehicle menu, %1 = action name (Refuel, Repair, Rearm), %2 = costs (see format below)
_actionCostsFormat = "%2 %1"; // %1 = item name, %2 = item count
_costsFree = "free"; // text for no costs
_message = "Vehicle Service Point nearby"; // message to be shown when in range of a service point (set to "" to disable)

// refuel settings
_refuel_enable = true; // enable or disable the refuel option
_refuel_costs = ["AllVehicles",["ItemGoldBar10oz",1]]; // free for all vehicles (equal to [["AllVehicles",[]]])
_refuel_updateInterval = 0.5; // update interval (in seconds)
_refuel_amount = 0.02; // amount of fuel to add with every update (in percent)

// repair settings
_repair_enable = true; // enable or disable the repair option
_repair_costs = [
	["Air",["ItemGoldBar10oz",5]], // 5 Gold for helicopters and planes
	["AllVehicles",["ItemGoldBar10oz",3]] // 2 Gold for all other vehicles
];
_repair_repairTime = 5; // time needed to repair each damaged part (in seconds)

// rearm settings
_rearm_enable = true; // enable or disable the rearm option
_rearm_costs = [
	["Air",["ItemBriefcase100oz",1]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemGoldBar10oz",5]] // 1 10oz Gold for all other vehicles
];
_rearm_magazineCount = 3; // amount of magazines to be added to the vehicle weapon

// ----------------- CONFIG END -----------------

call compile preprocessFileLineNumbers (_folder + "ac_functions.sqf");

_lastVehicle = objNull;
_lastRole = [];

_refuel_action = -1;
_repair_action = -1;
_rearm_actions = [];

_messageShown = false;

_fnc_removeActions = {
	if (isNull _lastVehicle) exitWith {};
	_lastVehicle removeAction _refuel_action;
	_refuel_action = -1;
	_lastVehicle removeAction _repair_action;
	_repair_action = -1;
	{
		_lastVehicle removeAction _x;
	} forEach _rearm_actions;
	_rearm_actions = [];
	_lastVehicle = objNull;
	_lastRole = [];
};

_fnc_getCosts = {
	private ["_vehicle","_costs","_cost"];
	_vehicle = _this select 0;
	_costs = _this select 1;
	_cost = [];
	{
		private "_typeName";
		_typeName = _x select 0;
		if (_vehicle isKindOf _typeName) exitWith {
			_cost = _x select 1;
		};
	} forEach _costs;
	_cost
};

_fnc_actionTitle = {
	private ["_actionName","_costs","_costsText","_actionTitle"];
	_actionName = _this select 0;
	_costs = _this select 1;
	_costsText = _costsFree;
	if (count _costs == 2) then {
		private ["_itemName","_itemCount","_displayName"];
		_itemName = _costs select 0;
		_itemCount = _costs select 1;
		_displayName = getText (configFile >> "CfgMagazines" >> _itemName >> "displayName");
		_costsText = format [_actionCostsFormat, _displayName, _itemCount];
	};
	_actionTitle = format [_actionTitleFormat, _actionName, _costsText];
	_actionTitle
};

_fnc_isArmed = {
	private ["_role","_armed"];
	_role = _this;
	_armed = count _role > 1;
	_armed
};

_fnc_getWeapons = {
	private ["_vehicle","_role","_weapons"];
	_vehicle = _this select 0;
	_role = _this select 1;
	_weapons = [];
	if (count _role > 1) then {
		private ["_turret","_weaponsTurret"];
		_turret = _role select 1;
		_weaponsTurret = _vehicle weaponsTurret _turret;
		{
			private "_weaponName";
			_weaponName = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
			_weapons set [count _weapons, [_x, _weaponName, _turret]];
		} forEach _weaponsTurret;
	};
	_weapons
};

while {true} do {
	private ["_vehicle","_inVehicle"];
	_vehicle = vehicle player;
	_inVehicle = _vehicle != player;
	if (local _vehicle && _inVehicle) then {
		private ["_pos","_objects","_inRange"];
		_pos = position _vehicle;
		_objects = nearestObjects [_pos, _servicePointClasses, _maxDistance];
		_inRange = count _objects > 0;
		if (_inRange) then {
			private ["_role","_actionCondition","_costs","_actionTitle"];
			_role = assignedVehicleRole player;
			if (((str _role) != (str _lastRole)) || (_vehicle != _lastVehicle)) then {
				// vehicle or seat changed
				call _fnc_removeActions;
			};
			_lastVehicle = _vehicle;
			_lastRole = _role;
			_actionCondition = "vehicle _this == _target && local _target";
			if (_refuel_action < 0 && _refuel_enable) then {
				_costs = [_vehicle, _refuel_costs] call _fnc_getCosts;
				_actionTitle = ["Refuel", _costs] call _fnc_actionTitle;
				_refuel_action = _vehicle addAction [_actionTitle, _folder + "service_point_refuel.sqf", [_costs, _refuel_updateInterval, _refuel_amount], -1, false, true, "", _actionCondition];
			};
			if (_repair_action < 0 && _repair_enable) then {
				_costs = [_vehicle, _repair_costs] call _fnc_getCosts;
				_actionTitle = ["Repair", _costs] call _fnc_actionTitle;
				_repair_action = _vehicle addAction [_actionTitle, _folder + "service_point_repair.sqf", [_costs, _repair_repairTime], -1, false, true, "", _actionCondition];
			};
			if ((_role call _fnc_isArmed) && (count _rearm_actions == 0) && _rearm_enable) then {
				private ["_weapons"];
				_costs = [_vehicle, _rearm_costs] call _fnc_getCosts;
				_weapons = [_vehicle, _role] call _fnc_getWeapons;
				{
					private ["_weaponName","_rearm_action"];
					_weaponName = _x select 1;
					_actionTitle = [format["Rearm %1", _weaponName], _costs] call _fnc_actionTitle;
					_rearm_action = _vehicle addAction [_actionTitle, _folder + "service_point_rearm.sqf", [_costs, _rearm_magazineCount, _x], -1, false, true, "", _actionCondition];
					_rearm_actions set [count _rearm_actions, _rearm_action];
				} forEach _weapons;
			};
			if (!_messageShown && _message != "") then {
				_messageShown = true;
				_vehicle vehicleChat _message;
			};
		} else {
			call _fnc_removeActions;
			_messageShown = false;
		};
	} else {
		call _fnc_removeActions;
		_messageShown = false;
	};
	sleep 2;
};

probably you can find an error in there.

 

What i basically meant up there is if you know a possibilty to change the script so that it works kinda like a safezone, in a radius around a specified point youll get options to use the service points without using the building but executing the service point when entering the area, like a sensor or something

 

and no: im not using any antihack

Take out the brackets and quotes around the TK_WarfareBHeavyFactory_EP1  and try it that way

 

Edit:

 

OK I thought it worked when I changed it that way on mine but it looks like I can refuel/repair from any vehicle anywhere now with 

 

_servicePointClasses = dayz_fuelpumparray + TK_WarfareBVehicleServicePoint_EP1 + US_WarfareBVehicleServicePoint_Base_EP1; // service point classes (can be house, vehicle and unit classes)

 

not what i really intended so I'll keep looking

Link to comment
Share on other sites

Take out the brackets and quotes around the TK_WarfareBHeavyFactory_EP1  and try it that way

 

Edit:

 

OK I thought it worked when I changed it that way on mine but it looks like I can refuel/repair from any vehicle anywhere now with 

 

_servicePointClasses = dayz_fuelpumparray + TK_WarfareBVehicleServicePoint_EP1 + US_WarfareBVehicleServicePoint_Base_EP1; // service point classes (can be house, vehicle and unit classes)

 

not what i really intended so I'll keep looking

what stupid idea is that? really you have no idea what you are doing, have you? lol sorry :D

his was was correct, i would say you could do it like this:

_servicePointClasses = dayz_fuelpumparray + ["TK_WarfareBVehicleServicePoint_EP1", "US_WarfareBVehicleServicePoint_Base_EP1"];
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
×
×
  • Create New...