Jump to content

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


Axe Cop

Recommended Posts

mm yeah that won't help much, maybe you put an error somewhere in the file with your change? it sure worked on my test server and for other admins as well..

so either way i need to see your changed code if you want some help.. e.g. upload it somewhere: http://pastebin.com/ 

 

I appreciate you looking into this for me: http://pastebin.com/Rw6Ts8qt

 

That's just the service_point. I didn't mess with the others.

Link to comment
Share on other sites

I appreciate you looking into this for me: http://pastebin.com/Rw6Ts8qt

 

That's just the service_point. I didn't mess with the others.

Ok I've tested with your file and it just works as it should be on my test server!? I played 10oz gold and it repaired one part every 4 seconds (damn that's slow haha)..??

so it might be a bug with another mod you are using or maybe antihacks or I don't know but the config works on my server.

Link to comment
Share on other sites

Just out of curiousity, there is only one array with which to add stations for? What would it take to seperate the stations? ie a refuel stations, repair station, rearm station and any combination of the 3? Shouldnt be able to rearm at a gas station for instance? If this is possible, that would just put this script over the top for me, awesome work mate!

Link to comment
Share on other sites

Just out of curiousity, there is only one array with which to add stations for? What would it take to seperate the stations? ie a refuel stations, repair station, rearm station and any combination of the 3? Shouldnt be able to rearm at a gas station for instance? If this is possible, that would just put this script over the top for me, awesome work mate!

Hey yeah that should be quite easy to add if you have a little knowledge in Arma scripting, but since you're asking I guess you have not? :D

there are at least 3 ways I can think of, depends what you wanna do exactly (just one build for each or do you wanna still be able repair at different repair stations etc)

 

maybe the easiest way would be to leave the array with service point classes as is (classes for all operations) and then have an extra array for each operation (repair, refuel and repair) and check for for those in the script below (just one extra condition should be easy to add).

pro tip: the array with all service point classes could also be merged form the 3 single arrays (so you don't have to have duplicate classes in different arrays and it's easier to change the config)

Link to comment
Share on other sites

Yes that would be excellent, and true, i wouldnt even classify myself as a script kiddie but i am learning and am going to school this summer for programming. Some direct uses i had in mind when i posted. Gas stations could be refuel only. Simple and effective plus they are all over (maybe incorporate some of the larger tanks/silos). then in some larger areas are the Land_repair_center buildings that i was going to make as repair/refuel stations and havent quite found one for rearming yet. maybe one of those bunker like buildings idk yet. Any tips to get this working like that would be awesome, maybe even an include on a future update   =p

 

Awesome scripts mate, im following a couple of them personally (SLOTS FTW!!)

Link to comment
Share on other sites

When I have some time I can try something out maybe, but i wasn't going to include it in the script because it only complicates things in the config and most admins don't even know how to use it as is.

That is a major problem I think, because most admins have never seen config files before and I have to do more support than programming new stuff sadly.. :D

Link to comment
Share on other sites

Quick question. Do i need to manually add in the service points to my map or are they included in the files?

no you don't have to do anything (but you can use custom locations if you want), by default it uses all gas stations as service points.

Link to comment
Share on other sites

Hey Axe, thanks for your work on this script, been running it since 1.0.3.1 without a hitch. I have one question, did you make changes after 1.0.4.0 to account for the currency conversion? With the version of the script I have it forces us to break the gold up prior to using the functions.

Link to comment
Share on other sites

No I didn't make any changes to the currency system as you can see.. I don't know how Epoch does things but I guess there is no easy way to reuse the code from the traders for that because the Epoch devs rarely write code that can be reused in other scripts (don't ask me why) :D

I mean if I want to use the code I have to copy everything in this script etc, that's just a mess I think, but feel free to investigate that further, I didn't play Epoch for month myself ^^

Link to comment
Share on other sites

If you want you can do that by simply copying the service_point.sqf script 3 times and only enable one of repair, refuel or rearm in each script and then change the service point class and start all 3 in your init.sqf, I hope you know what i mean. :D

That should work, it's about the same performance as if the script itself would check 3 different buildings, not that the script uses much performance but still this is the easiest way without changing the whole script for what you want.

 

Here's what I did:

/ Vehicle Service Point by Axe Cop

private ["_folder","_servicePointClasses","_servicePointClassesFO","_servicePointClassesFR","_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 = ["INS_WarfareBAircraftFactory"]; // service point classes for complete service
_servicePointClassesFO = ["FuelPump_DZ","KamazRefuel_DZ","MtvrRefuel_DES_EP1_DZ","UralRefuel_TK_EP1_DZ","V3S_Refuel_TK_GUE_EP1_DZ","MtvrRefuel_DZ"]; // service point classes for fuel only
_servicePointClassesFR = ["Land_A_FuelStation_Feed"]; // service point classes for fuel and repair
_maxDistance = 20; // 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 = []; // free for all vehicles (equal to [["AllVehicles",[]]])
_refuel_updateInterval = 1; // update interval (in seconds)
_refuel_amount = 0.05; // 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",2]] // 2 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 = [
        //["ArmoredSUV_PMC_DZE",["ItemGoldBar10oz",2]], // 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];
				_objectsFO = nearestObjects [_pos, _servicePointClassesFO, _maxDistance];
				_objectsFR = nearestObjects [_pos, _servicePointClassesFR, _maxDistance];
                _inRange = count _objects > 0;
				_inRangeFO = count _objectsFO > 0;
				_inRangeFR = count _objectsFR > 0;
                if ((_inRange) || (_inRangeFO) || (_inRangeFR)) 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 ((_inRange) || (_inRangeFR)) then {
							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 ( _inRange && (_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;
};

This gives you 3 categories of objects, Fuel Only (_servicePointClassesFO), Fuel and Repair (_servicePointClassesFR), and Fuel, Repair and Rearm (_servicePointClasses).  In my case, I allow placed fuel pumps and fuel trucks to fuel only, map gas stations to fuel and repair, and then a special object that allows all three.  Each category is an array (like the default code), so can have multiple objects that provide those services.

 

Enjoy!

 

GT

Link to comment
Share on other sites

 

Infistar set filters for battles. 
Maybe I'm wrong to set up filters? 
Set them in the main folder server\BAttleye and the folder  \instance_\Battleye...

 

you may need custom action exception for this script, I've posted that many times here in this topic and I can't help you how to do it because I have no infistar ^^

Link to comment
Share on other sites

 

Infistar set filters for battles. 
Maybe I'm wrong to set up filters? 
Set them in the main folder server\BAttleye and the folder  \instance_\Battleye...

 

 

 

Menu actions to whitelist are in the link above. 

Link to comment
Share on other sites

did you see this post? 

I guess so, your script is quite similar I guess :D

I would do it in some other way as I have described before, but if it works you can do it this way...

I used that post as an example, but it seems to be for an older version so i tried to retrofit it to work with mine. There are no errors but it just doesnt work. Client or server side shows nothing.

Link to comment
Share on other sites

hi das script hat ein paar  Fehler. Ich kann an einer Tankstelle reparieren und es ist gleich alles repariert obwohl ich angegeben habe 10 sec für jedes teil und wenn ich dann wegfahre und die reifen und scheiben zerstöre kann ich über das Mausrad repair machen und es wird alles gleich repariert obwohl ich nicht mehr an der Tankstelle stehe und diese Reparatur ist dann kostenlos oder ist das so gewollt?

 

hier meine Configeinstellungen

 

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

 
// general settings
_folder = "service_point\"; // folder where the service point scripts are saved, relative to the mission file
_servicePointClasses = dayz_fuelpumparray; // service point classes (can be house, vehicle and unit classes)
_maxDistance = 10; // 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 = "Car 5 Gold Heli 10 Gold"; // 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 = [
["Air",["ItemGoldBar10oz",1]], // 5 Gold for helicopters and planes
["AllVehicles",["ItemGoldBar5oz",1]] // 2 Gold for all other vehicles
]; // free for all vehicles (equal to [["AllVehicles",[]]])
_refuel_updateInterval = 1; // update interval (in seconds)
_refuel_amount = 0.05; // 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",3]], // 5 Gold for helicopters and planes
["AllVehicles",["ItemGoldBar10oz",1]] // 2 Gold for all other vehicles
];
_repair_repairTime = 10; // time needed to repair each damaged part (in seconds)
 
// rearm settings
_rearm_enable = false; // enable or disable the rearm option
_rearm_costs = [
["ArmoredSUV_PMC_DZE",["ItemGoldBar10oz",2]], // 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 -----------------
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...