Jump to content

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


Axe Cop

Recommended Posts

Couldn't sleep.. so tried your suggestion and I'm sorry but it didn't work either. 

 

I'm actually so tired right now though that I can't even remember whether (!(.... is saying NOT , so _vehicle NOT in _objects or the other way round lol.. Sorry Axe Cop, I don't want you to waste any more time on this either, as I'm sure you've got better stuff to be working on.  I'll figure it out at some point :) 

Link to comment
Share on other sites

Couldn't sleep.. so tried your suggestion and I'm sorry but it didn't work either. 

 

I'm actually so tired right now though that I can't even remember whether (!(.... is saying NOT , so _vehicle NOT in _objects or the other way round lol.. Sorry Axe Cop, I don't want you to waste any more time on this either, as I'm sure you've got better stuff to be working on.  I'll figure it out at some point :)

No problem dude, I just try it myself then... and yes "!" means "not"  :D

 

Edit: Ok it works perfectly on my test sever?!? explaaaaain :P

I've added an Ural to the service point list, other vehicles can be refueld and everything near it but you won't get any option if you are inside the ural itself!? I thought that is what you wanted..?

 

Here my debug putput with explanations:

if (_inRange) then {
	diag_log format ["service_point _vehicle = %1, _objects = %2, (_vehicle in _objects) = %3", typeOf _vehicle, _objects, (_vehicle in _objects)];
};

// in range of a service station (player inside of a service vehicle)
"service_point _vehicle = Ural_CDF, _objects = [B 1-1-B:1 (Axe Cop),2865d600# 965086: a_fuelstation_feed.p3d], (_vehicle in _objects) = true"

// driving around in the service vehicle
"service_point _vehicle = Ural_CDF, _objects = [B 1-1-B:1 (Axe Cop)], (_vehicle in _objects) = true"

// with another car in range of the service vehicle
"service_point _vehicle = GLT_M300_ST, _objects = [211c6080# 1056369: ural.p3d], (_vehicle in _objects) = false"

There you might see one drawback with that simple solution, you can't refuel or repair the service vehicle even if it is near another service point.. that can be fixed of course but try to get this running on your server first! Maybe you can fix that yourself ^^

 

Here my idea for a quick and dirty fix for that;

_inRange = (!(_vehicle in _objects) && (count _objects > 0)) || ((_vehicle in _objects) && (count _objects > 1));

only that line needed in addition to the original script! it just checks when you are inside a service vehice there has to be another service point nearby (> 1, so at least 2) or when you are not inside a service vehicle it's like before. should work. :)

Edited by Axe Cop
Link to comment
Share on other sites

Tried switching to axecop's version, and I noticed it does have some slight performance impact on the server. Not as bad as the old kh_actions auto refuel, but definitely enough to cause a bit of lag. Some of the code is similar, but I haven't tracked down exactly what in the code causes the problem. I believe MGT mentioned in a post some where they switched to a new kind of refuel script (that didnt save I believe) but didnt have any performance issues. The serverload FPS drop is minor, but thats not the main issue. Some how some way, if many players are all refueling at the same time, some players start spawning as birds when the server is full and under heavy load, something that did not happen prior to running this script over using default epoch refueling methods.

 

Any idea what could be causing it axecop?

Link to comment
Share on other sites

Tried switching to axecop's version, and I noticed it does have some slight performance impact on the server. Not as bad as the old kh_actions auto refuel, but definitely enough to cause a bit of lag. Some of the code is similar, but I haven't tracked down exactly what in the code causes the problem. I believe MGT mentioned in a post some where they switched to a new kind of refuel script (that didnt save I believe) but didnt have any performance issues. The serverload FPS drop is minor, but thats not the main issue. Some how some way, if many players are all refueling at the same time, some players start spawning as birds when the server is full and under heavy load, something that did not happen prior to running this script over using default epoch refueling methods.

 

Any idea what could be causing it axecop?

The script in general doesn't do much, just checking if a service point is near every 2 seconds by default, but you say it is only when many people are refueling at the same time?

you can change the config and do the auto refuel less often and more fuel at a time to improve the performance, since the "setFuel" command will be send to all players in multiplayer there may be some fps drops if many players doing that at once, nothing I can do about there is no local refuel command which is not send to every other player (as far as I know). So the only option you have is changing the config variables and play around with those values:

_refuel_updateInterval = 0.5; // update interval (in seconds)
_refuel_amount = 0.02; // amount of fuel to add with every update (in percent)

that are the default values in the config, meaning every 0.5 seconds 2% fuel is being added to the vehicle (should take about 25 seconds to refill a vehicle if it was empty before), change it to refuel faster and increase the update interval to reduce the data send to all clients, e.g. 10% steps every second. Hope that helps. :) (fun fact: some other old refuel script had like 1000 updates every second and took forever to refuel a vehicle, that would cause massive lag lol)

 

The other scripts (repair and rearm) should be fine, as they only send every repaired part or ammo box to the other clients..

 

this is still a problem with the ArmA engine and many players online at once, as ALL players receive all updates from other players no matter where they are on the map.. :/

Link to comment
Share on other sites

Just made a new script for proper vehicle service points where you are able to refuel, repair and rearm your vehicles! (I could not find a good one, so I did it myself)

"Proper" meaning everything is done like it should be in Epoch and saved to the database, e.g. the script is really repairing all vehicle parts and not just setting the damage to 0, so it's the same as if you would repair every damaged part yourself.

 

Main Features:

  • dynamic service points where you are able to select the options (default at every fuel station, if you want it's easy to add the epoch fuel pumps so you can build a service point in your base)
  • you can refuel and repair any vehicle by just sitting inside and get close to a service station (default 10m), then you get the actions menu attached to the vehicle, with rearm you have to be in the gunner seat because only that turret will be rearmed (for all cases the vehicle has to be local to your PC, so your have to be the driver/pilot or are alone in the vehicle)
  • the services don't have to be for free, you can add a price to every option like the traders (e.g. refuel is free but repair would cost 2 gold and rearm 3 10oz gold)
  • dynamic costs based on vehicle type
  • you can also disable any option if you don't want or need it, like disabling the rearm option completely
  • anything important is configurable in one place with config variables (there are comments in the config block, just take a look at the file service_point.sqf)

 

The Installation is pretty simple, it's just a client side script.

Add this to your init.sqf in the "if (!isDedicated) then { PUT HERE SOMEWHERE (at the end is ok) }" block (so it will only be started on your client and not the server):

execVM "service_point\service_point.sqf";

Download all files from here into a folder "service_point" inside your mission folder: https://github.com/vos/dayz/tree/master/service_point

If you want to change the path, there is one config variable in the file service_point.sqf called "_folder", you have to change that so it can access the other files needed for the script.

 

Here a screenshot how it looks like (click on the preview to show a full screenshot with the UAZ DShKM):

3IQOiUL.png

 

Feel free to add features and tell me your ideas. :)

how to add in the safe zone and fix refills?

Link to comment
Share on other sites

Is there a way to change how many magazines certain vehicles get?  Some vehicles I only want to receive 1 magazine, and others 4, and still others 3.  You get the idea...thanks!

there is always a way, but this is not supported by default.

you have to change the config a little to make it work, if you want i could tell you what to change... biut it should be pretty simple if you know how to do ArmA scripts :)

 

how to add in the safe zone and fix refills?

what? do you want to add the script in the safe zones? Just add a building only available in the safe zone to the service point classes or even a trader (havent't tested with a trader but it might work, if not it can be changed so the script works around specific traders only and not buildungs/vehicles.

Link to comment
Share on other sites

just updated the scripts.

 

nothing major just added a small "fix" if you want to use the script on dynamic vehicles like hayward and don't want that the vehicle can refuel or repair itself. :P

I've also tested the script on NPC traders, works out of the box so if you want add a trader class like "TK_GUE_Soldier_5_EP1" (vehicle part trader at trader city bash) to the service point classes and you will get the options  the same way if you are near him. :)

I tweaked the refuel config a little to refuel only every second at a 5% rate (before 2% every 0.5 seconds)

 

also the service point object is now available in every script (refuel, repair and rearm), not used atm but can be to determine where the action comes from and do something with that in case you want to custmoize the scripts.

Link to comment
Share on other sites

there is always a way, but this is not supported by default.

you have to change the config a little to make it work, if you want i could tell you what to change... biut it should be pretty simple if you know how to do ArmA scripts :)

 

Sure, let me tell you what I'm trying to achieve, and what I've done so far.  Every armed vehicle has a default number of magazines, smokes, or flares that they spawn in with in regular Arma 2, and I'm looking to make a script that will bring the ammo amounts and magazines to the correct default values.  Basically, to do what the vehicle service point is supposed to do in regular Arma 2 completely rearm and refuel the vehicle.  All the vehicles on my server spawn with the ammo stripped, and I'm using the repair centers ("Land_repair_center") you find on the map for repairs only, but for a price.  I then created an event to randomly spawn vehicle service points ("RU_WarfareBVehicleServicePoint"), this was a pain because some of these objects will give you gas or repair vehicle by default even without your script, but none of them would rearm like they are supposed to do.  Also, I had to run your script twice, one time for repair only ("Land_repair_center"), and another time for ammo and fuel ("RU_WarfareBVehicleServicePoint").  Ammo and fuel are free, since it runs as an event much like supply drops.

 

The main reason I want this done is I have working MLRS and Strykers (had to add to your code to load right ammo type) with rockets and mortars on my server, and if I put the magazine count higher than 1, it will actually load well and beyond the 12 rockets, or 24 mortar rounds those vehicles would carry, not very realistic.  To complicate matters I have working static weapons (comes with key...lol) on my server, and none of them have an option to reload ammo at any service points, but do in regular Arma 2.

 

Anyway, I have it all working and functional, but not polished like I would like.  Any help would be greatly appreciated.

Link to comment
Share on other sites

Lysus yeah that sounds great, maybe there is a config variable in the cfgVehicles file that can be used to get the default magazine count, to be honest i did not check that and used a static amount in my script. Does anyone know if there is a config value like that for every vehicle?

i cant look myself atm because im not on my computer, but i will look into that tomorrow. It is almost 4am here and i need some sleep :p

Link to comment
Share on other sites

I stresstested my testserver with only this script running on the gas stations with 10 people in teamspeak. We all had a car with zero fuel standing ready to fill up our cars and the fps drop when people use this script at the same time on the server is  zero to NONE.

 

We had the setting:

 

_refuel_updateInterval = 1; // update interval (in seconds)
_refuel_amount = 0.04; // amount of fuel to add with every update (in percent)

 

Fact is, this script doesn't make ur fps drop ;)

Link to comment
Share on other sites

Hopefully Axecop or Fuchs can help me, I have changed my _refuel_actions,_repair_actions, and _rearm_actions in the private block and all instances within service_point.sqf to -refuel_actions,-repair_actions,-rearm_actions so they are no longer global. But the issue persist of only admins seeing the scroll menu and players see it for only a second then disappears.

I'm running infiSTAR AH0315 I have added both action types -refeul_actions and _refuel_actions to my actions whitelist.

Fuchs maybe if u could link your sqf files as a guide to get this working with infiSTAR?

Thanks guys!

Link to comment
Share on other sites

Hopefully Axecop or Fuchs can help me, I have changed my _refuel_actions,_repair_actions, and _rearm_actions in the private block and all instances within service_point.sqf to -refuel_actions,-repair_actions,-rearm_actions so they are no longer global. But the issue persist of only admins seeing the scroll menu and players see it for only a second then disappears.

I'm running infiSTAR AH0315 I have added both action types -refeul_actions and _refuel_actions to my actions whitelist.

Fuchs maybe if u could link your sqf files as a guide to get this working with infiSTAR?

Thanks guys!

What did you change? you need to convert all actions to global variables and use that with infistar, e.g. rename "_refuel_action" to "sp_refuel_action" or whatever (sp stands for service point in this case), that is all you have to do to make it accessible from infistar :)

 

@Lysus:

I took a look at the cfgVehicles config and you have a "magazines" config array, problem is with the epoch vehicles (DZE) thsi array is alway empty of course.. one solution to get the default magazine count would be to fall back to the DayZ vehicles (DZ) and use that, because they are still in the config and have the default ammo in there it seems.:

magazines[] = {};

for the ArmoredSUV_PMC_DZE, but

magazines[] = {"2000Rnd_762x51_M134"};

for the ArmoredSUV_PMC_DZ

 

so you could cut of the "E" at the end of the vehicle class name and get the config value that way, sadly cutting of a letter at the end is not easily done in SQF script.. :P

Link to comment
Share on other sites

I wonder if anyone else has noticed this issue?
Once you repair a vehicle if it gets shot or damaged everything stays green in the top vehicle Heath bars until server restart, then all the damage appears. I tested this by shooting a tire after a repair, then clicking repair vehicle and the tire damage was at %50 but the top vehicle health was still green, once I restarted it turned orange.

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