Jump to content

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


Axe Cop

Recommended Posts

Yeah thats what I though.

 

Second addition:

 

Could you add a variable cost for "LandVehicle" and "Air" so that we can make choppers more expensive to repair over LandVehicles?

 

Perhaps a _landvehicle = [xxx,xxx,xxx] option where we can customize unique vehicles for a higher price?

 

As for the repair change, that sounds good.. more risk to staying in the area or lose the money or lose your life! I like it.. the invisible attendant gets paid either way ;)

 

Could you perhaps make an NPC spawn during the refuel/repair or rearm and perform a "medical" action for the duration for a little bit of immersion?

Link to comment
Share on other sites

I will do that with the repair addition when I have some time.
About different prices yeah I was thinking about that, but it has to be simple enough so you can customize it and most people don't even know how to add objects to a list with arma scripts so I can't make the config too complicated :D
But I might have an idea where you can set different costs for different types of vehicles, just need to make sure what happens when the vehicle is in more then one list, hard to explain, maybe you can set a config like this:
// [[<vehicle type>, <costs>], ...]
_repair_costs = [
	["ATV_US_EP1", ["ItemSilverBar10oz",2]], // special price for a single vehicle
	["ArmoredSUV_PMC_DZE", ["ItemGoldBar10oz",2]], // special price for a single vehicle
	["LandVehicle", ["ItemGoldBar",2]], // repair price for land vehicles (cars)
	["AirVehicle", "ItemGoldBar10oz"], // price for air vehicles (helicopters and planes)
	["AllVehicles", "ItemSodaMdew"] // the price for all other vehicles not mentioned above (in this case only boats I guess)
];

what do you think about something like that? if you want you could set a price for every single car, or just use the base type "AirVehicle" so set a price for all air vehicles..

the order of that list will be important so my script will go through and takes the first costs of the matching type (e.g. if you put "LandVehicle" on the top it will use that instead of the ATV_US_EP1 even if you are in an ATV! this matters only if more than 1 type can match the vehicle of course)

 

So t the last one with the NPC doing an animation I don't know haha, what if there are more vehicles repairing at the same time, will it spawn one for each vehicles and stuff like that I have to figure out if that makes sense, also people trying to kill the NPC who repairs your vehicle lol

Link to comment
Share on other sites

Scripts updated!

 

New features:

  • repair delay for each damaged part, will also display a message with the part currently being repaired (default 2 seconds, see config, if set to 0 the repair will be instant with no messages like before)  :)
  • dynamic costs based on vehicle type (similar as I've mentioned it in the post above)
  • display message in vehicle chat when near service point (can be disabled or customized in the config)

You can get the new version from the same place: https://github.com/vos/dayz/tree/master/service_point

Link to comment
Share on other sites

Awesome!

 

Answer:

NPCs can be made to have godmode on, I think it would make sense that an attendant spawns per action required.. then disappears after its done.. I dont mean for them to be there all the time. Perhaps for every vehicle that gets within X distance, the attendant spawns.. would having it set to something like 100-200m away from the service point cause any issues with performance do you think? I imagine its not a re-occuring check and as its client side it shouldnt matter, much like the safe zone script check.

 

Question:

_rearm_costs = [
	["ArmoredSUV_PMC_DZE",["ItemBriefcase100oz",3]], // special costs for a single vehicle type
	["Air",["ItemBriefcase100oz",3]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemBriefcase100oz",2]] // 1 10oz Gold for all other vehicles
];

Changing that to:

_rearm_costs = [
	["ArmoredSUV_PMC_DZE",["ItemBriefcase100oz",3]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",4]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",6]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",7]], // special costs for a single vehicle type
	["Air",["ItemBriefcase100oz",3]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemBriefcase100oz",2]] // 1 10oz Gold for all other vehicles
];

Would work I assume? Does the "AllVehicles" not override the previous settings and do the newvehicles have to be above both "Air" and "AllVehicles"?

 

Question / Addition:

_refuel_costs = [
	["ArmoredSUV_PMC_DZE",["ItemBriefcase100oz",3]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",4]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",6]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",7]], // special costs for a single vehicle type
	["Air",["ItemBriefcase100oz",3]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemBriefcase100oz",2]] // 1 10oz Gold for all other vehicles
];

Would that work to?

Link to comment
Share on other sites

Hmm getting this error now in my client side RPT:

Error in expression <;
{
private "_typeName";
_typeName = _x select 0;
if (_vehicle isKindOf _typeNam>
  Error position: <select 0;
if (_vehicle isKindOf _typeNam>
  Error select: Type String, expected Array,Config entry
File mpmissions\__CUR_MP.Chernarus\service_point\service_point.sqf, line 73

http://pastebin.com/80LvsJ8b - service_point.sqf - what did I break? :o

Link to comment
Share on other sites

Question / Addition:

_refuel_costs = [
	["ArmoredSUV_PMC_DZE",["ItemBriefcase100oz",3]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",4]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",6]], // special costs for a single vehicle type
	["NEWVEHICLE",["ItemBriefcase100oz",7]], // special costs for a single vehicle type
	["Air",["ItemBriefcase100oz",3]], // 2 10oz Gold for helicopters and planes
	["AllVehicles",["ItemBriefcase100oz",2]] // 1 10oz Gold for all other vehicles
];

Would that work to?

YES that should work, that was my intention, the only important part is the order of the entries. The vehicle types should get more general at the bottom, at the end should always be "AllVehicles" which will match all vehicles not mentioned above.

It works pretty simple, my script just goes through the list and takes the first costs for a vehicle type matching the current vehicle, e.g. when you are driving an armored SUV and using the list above it will match the first entry with ArmoredSUV_PMC_DZE and then skip the others. If you you understand what I mean, or just try it out on your test server :D

You can use all vehicle types or subtypes like "LandVehicle" or "car" should work too in DayZ, see this list for example: http://community.bistudio.com/wiki/ArmA_2:_CfgVehicles (you could use "Truck" to match all cargo trucks if you want, just keep in mind it will take the first matching entry when you define more types which will match a specific vehicle).

 

And I might try that with the NPC, but I don't want to change the service point detection, it just detects it in a 10m radius for now and so I can't spawn a NPC when you are 200m away or something that would costs much more (unesseary) performance I think, but could be done of course. Maybe I can spawn the NPC when you select a repair option but that might look weird and players panic haha. I also think it would be funny if you could kill the "mechanic NPC" so it would display a message like "repair stopped - your mechanic has been killed" :p

Link to comment
Share on other sites

Oh I like that! Yeah make the NPC killable, thats brilliant! There should certainly be timesinks and risks for it. Maybe you could add the gold to the NPCs inventory, add a small cut text saying "NPC is storing the gold in his safe" and then after this is done, remove the gold from the NPC and then continue with the repair.. that would mean that there is more time that it can be stolen if the NPC is killed :)

 

But to add ontop of this, if someone kills the NPC they are blacklisted from using the service points during that restart (persistence would require a database edit in my guess)

 

Dont know if you saw my error above, I triple checked everything but there seems to be a problem - with the new script, there are no repair/refuel/rearm options so I'm still using the older one at the moment :)

Link to comment
Share on other sites

Hmm getting this error now in my client side RPT:

Error in expression <;
{
private "_typeName";
_typeName = _x select 0;
if (_vehicle isKindOf _typeNam>
  Error position: <select 0;
if (_vehicle isKindOf _typeNam>
  Error select: Type String, expected Array,Config entry
File mpmissions\__CUR_MP.Chernarus\service_point\service_point.sqf, line 73

http://pastebin.com/80LvsJ8b - service_point.sqf - what did I break? :o

Sorry missed that post :D

 

Error is in this line:

_refuel_costs = ["ItemGoldBar10oz",1]; // free for all vehicles (equal to [["AllVehicles",[]]])

see my example in the comment, you need to put extra [] around, so change to this (the "[]" only work if you want to leave it for free):

_refuel_costs = [["AllVehicles",["ItemGoldBar10oz",1]]];

there is no easy way of adding an exception for all vehicles if you want to do it like you did, so you just have to save it like that and it should work...

I think you can leave out the "1" if its only 1 item but doesn't hurt to leave it in there, but this should work, too:

_refuel_costs = [["AllVehicles","ItemGoldBar10oz"]];

anyways it's pretty expensive to refuel at your server haha :D

 

Btw I'm testing this with the NPC, but I've never worked with Ai before I need to see how that works first..

Link to comment
Share on other sites

Always been against auto refuel mate - this is just an addition for the rich people on the server to sink their money! The reason I/We were always against it was that it was free and way too easy to do, same as auto repair.

 

This adds a different aspect to it and allows people to farm any area to earn enough currency to pay for repairs, refuelling or rearming along with the grinding way of actually finding what you need. Its kind of a case of, now everyone can pick everything up and still get the same out come as it is all tradeable for a universal item to pay for these repairs!

 

We may change it in the future but if its too cheap it becomes the only way to do something and I like there to be options. Its a luxury and should be treated as such!

 

1 10oz Gold isnt that expensive though, we have a high value military installation with probably too many barracks but it promotes PvP so it works. Most crappy vehicles sell for this and most players will keep a jerry can with them just incase!

 

Cheers for looking at my issue, will test now :)

Link to comment
Share on other sites

I am having troubles getting this to work. I have added the files to my PBO and added the below.

 

if (!isDedicated) then {


//Conduct map operations
0 fadeSound 0;
waitUntil {!isNil "dayz_loadScreenMsg"};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
execVM "service_point\service_point.sqf";

 

Let me know if I am doing something wrong.

 

Thanks

 

CodemanX

Link to comment
Share on other sites

Hello,

 

Firstly, Thank you for the script, its brilliant. 

 

For some reason, it all works well, execpt it isn;t charging players for the rearm/repair. I've changed the prices in the service_point.sqf but i didnt alter the format.

// 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 = ["Land_A_FuelStation_Feed"]; // 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 Rearm,Repair,Refuel"; // 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 = []; // 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",["ItemGoldBar",5]], // 5 Gold for helicopters and planes
        ["AllVehicles",["ItemGoldBar",1]] // 1 Gold for all other vehicles
];
_repair_repairTime = 2; // time needed to repair each damaged part (in seconds)

// rearm settings
_rearm_enable = true; // enable or disable the rearm option
_rearm_costs = [
        ["HMMWV_M1151_M2_CZ_DES_EP1","ArmoredSUV_PMC_DZE",["ItemGoldBar10oz",3]], // special costs for a single vehicle type
        ["Air",["ItemGoldBar10oz",2]], // 2 10oz Gold for helicopters and planes
        ["AllVehicles",["ItemGoldBar10oz",1]] // 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;
};
Link to comment
Share on other sites

I am having troubles getting this to work. I have added the files to my PBO and added the below.

 

if (!isDedicated) then {

//Conduct map operations

0 fadeSound 0;

waitUntil {!isNil "dayz_loadScreenMsg"};

dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

execVM "service_point\service_point.sqf";

 

Let me know if I am doing something wrong.

 

Thanks

 

CodemanX

Seems about right, did you save the scripts to the same folder (service_point\service_point.sqf")?

 

 

the scroll option flicks up and vanishes :-s any ideas ??

I guess that's a problem with your antihack tools?

 

 

 

Hello,

 

Firstly, Thank you for the script, its brilliant. 

 

For some reason, it all works well, execpt it isn;t charging players for the rearm/repair. I've changed the prices in the service_point.sqf but i didnt alter the format.

yeah well that's for single vehicles, so you've altered the format. :P 1 line for each vehicle like this (I can't do the configs in every way you want to use it, sorry haha):

["HMMWV_M1151_M2_CZ_DES_EP1",["ItemGoldBar10oz",3]], // special costs for a single vehicle type
["ArmoredSUV_PMC_DZE",["ItemGoldBar10oz",3]], // special costs for a single vehicle type

If you change the format weird things might happen (like wrong costs so players don't have to pay anything so check it first), I can't handle all that stuff in the scripts xD

Anyway this way you can have different costs for both vehicles or vehicle types ( I don't think there is a vehicle type for armed vehicles sadly..)

 

 

 

Would this work?

_rearm_magazineCount = [
    ["ArmoredSUV_PMC_DZE",[1]],
    ["AllVehicles",[3]]
];	

No and I have no idea what you are doing, 1 of what? you need to specify the item name, the amount can be omitted if it's only 1 but not the other way around.. unless you want to pay with your life with that "1" :D

Link to comment
Share on other sites

How would I go about getting this to work on the Panthera map? When ever I go to any fueling station it does not appear to give me any of these options when I scroll while in a vehicle. I've added everything as directed in the post, does this not work for Panthera or did I break something?

Check your report file on the client if there are errors. (file locationif you don't know where it is on your PC http://community.bistudio.com/wiki/Crash_Files#ARMA_2_OA)

As I've said before it should work on all maps as long as the fuel stations are the same (should be), the default config is looking for these fuel feed station things ("Land_A_FuelStation_Feed"): http://media.moddb.com/images/mods/1/18/17487/preview1.jpg ( the 4 small ones between the station, that's why also the small gas stations should work as there are 1 or 2 of those, too)

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