Jump to content

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


Axe Cop

Recommended Posts

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)

I looked at a few other mission files from servers using the same mod, and it appears you have to add different options for the refuel stations on this map. 

_servicePointClasses = ["Land_A_FuelStation_Feed","Land_Ind_TankSmall","Land_Ind_TankSmall2","Land_Fuel_tank_big","Land_A_FuelStation_Build","Land_Ind_TankSmall2_EP1"]; // service point classes 

The above code appears to work, cheers!

Link to comment
Share on other sites

Infistar. What is the actual s_player action that is used for scroll menus? I tried these _refuel_action, _repair_action, _rearm_actions but no luck.

That may be because the actions are private to my script only, I am not sure how that works with the antihack tools but my actions are not accessible from any other scripts so you may have problems adding it to infistar.

One solution would be to make the actions global, this is not nessesary for the script but may help you whitelisting the actions I think:

change "_refuel_action" to "s_player_refuel_action" in the script (for the other actions as well, just search and replace all) that will make them global and you should be able to add them, you have to remove them in the "private" block above,

 

change

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"];

to

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","_fnc_removeActions","_fnc_getCosts","_fnc_actionTitle","_fnc_isArmed","_fnc_getWeapons"];

so just remove the actions ("_refuel_action","_repair_action","_rearm_actions") from that list and change the name to something without the "_" at the beginning should do it.

 

 

Btw I'm wondering how that would add a protection from a hacker, if you just use a variable name like that in your "hack" it won't protect anything I guess lol (but then again most hackers don't know what they are doing, you are lucky I don't develop hacks haha)

Link to comment
Share on other sites

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","_fnc_removeActions","_fnc_getCosts","_fnc_actionTitle","_fnc_isArmed","_fnc_getWeapons"];

so just remove the actions ("_refuel_action","_repair_action","_rearm_actions") from that list and change the name to something without the "_" at the beginning should do it.

 

so should i remove them and readd/rename them without "_" at the beginning correct?

 

or mabe it's the fact we use the first release for this script?

Link to comment
Share on other sites

I don't think that changed in the second release but why not upgrade to the newest version? :D

 

All you have to do is make those actions global, because if they are privat to the script the antihack can't find them I guess..

So you have to remove them from the private variable list and rename all variables so they become global (all variables starting with "_" are private in ArmA script, so just change it to something else not starting with "_").

if you want leave the old names in the "private" block at the top, it doesn't matter but they are not needed anymore so you should remove them.

Link to comment
Share on other sites

does not work on my map Panthera I must add special name for fuel obj ? somebody know list name all fuel station in panthera ? Pls help me

 

I go to  missions/epoch.panthera/and here create new folde ;service_point;  and inside i create 5files sqf from download link up

File Manager > \vilayercodecustom\missions\epoch.panthera\service_point   

 

and next step i go to \init.sqf and add comand like that

 

 

if (!isDedicated) then {
    //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";    
    _void = [] execVM "R3F_Realism\R3F_Realism_Init.sqf";
    
    //Lights
    //[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";
};
//Custom Loadouts
    [] ExecVM "Scripts\loadout.sqf";
execVM "service_point\ac_functions.sqf";
execVM "service_point\service_point.sqf";
execVM "service_point\service_point_rearm.sqf";
execVM "service_point\service_point_refuel.sqf";
execVM "service_point\service_point_repair.sqf";

 

Its 5last comand add its okay or i must change somethink

Link to comment
Share on other sites

You only need to add the "service_point.sqf" to your init.sqf, also put it below the "light" stuff so it wont be executed on the server.

About the gas stations idk, but there was another post on this forum where somebody said something about the class type, or just find it out yourself, i have an admin tool that just tells me the object name by looking at it :p

Link to comment
Share on other sites

Make it look like this

   //Lights
    //[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";
};
//Custom Loadouts
    [] ExecVM "Scripts\loadout.sqf";
//Service point by Axe Cop
[] execVM "service_point\service_point.sqf";

It works on mine, I just removed some of my stuff, that you don't have there

 

Bags

Link to comment
Share on other sites

// 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 = 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 = "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 = 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",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];
        _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

ok , yeah... What i did was uploaded my service_point.sqf to dropbox and you can D/L it from there...

Here is the link

https://www.dropbox.com/s/92c5cxvez7lothk/service_point.sqf

 

It works on my server, all you will need to do is, if you want, change the amount of gold it costs to repair things, mine is set to cost a BC for air vehicles and 5 10oz gold for everything else

and enable re-arm if you want it...I don't have it enabled on mine, currently

 

Bags

Link to comment
Share on other sites

Thanks bags, but can it be that hard to find out what the gas stations on panthera are called? You can open the map in the arma editor to see the object names i think, i cant do everthing myself :p

As i have said some hours ago it was here somewhere in the forums, try this: "Land_benzina_schnell" as the service point class

http://dayzepoch.com/forum/index.php?/topic/3469-auto-refueling-on-panthera/?hl=schnell

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